Add WMO long-wave-downwards parameter (0,5,3) + fix zero-group constant-field decode - #4
Merged
oliverbrass merged 2 commits intoJul 21, 2026
Conversation
…5,3)
NGrib's parameter table only carried downward long-wave radiation as the NCEP-local
variant (category 5, number 192). ECCC MSC HRDPS - and the WMO standard - encode it as
category 5, number 3 ("Surface long-wave (thermal) radiation downwards"), which was
absent, so that record resolved to no parameter and consumers dropped it. Adds the WMO
entry (mirroring the existing category-4 number-7 short-wave downwards entry).
Tests: a direct Parameter.Get(0,5,3) lookup, and reading a real HRDPS DLWRF grib sample
(Jpeg2000 accumulation) asserting the parameter resolves and the decoded field matches an
independent OpenJPEG decode (min 522543.5 = referenceValue*100, max 1724543.5 J m-2).
Bumps the package version to 0.13.4.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
A field encoded with complex packing + spatial differencing but zero groups (NumberOfGroups == 0, e.g. a constant all-reference-value field such as an all-zero sea-ice-fraction field) was decoded as garbage: the group-decoding loop never writes the secondary-value buffer, which comes from ArrayPool.Rent and holds stale data, and that garbage then flows through the spatial-differencing reconstruction into the output. Zero the secondary-value buffer after renting so an unwritten (zero-group) field decodes to the reference value, matching eccodes (which returns all zeros for this field). Also corrects two pre-existing assertions in Grib2Reader_EastChinaJapan_Test that this exposes: the Ice test compared KeyValuePair elements against 0 (never valid) - it now asserts every decoded value is 0; and the U10 test's expected average was wrong (-0.0677 -> -0.6774, confirmed with eccodes; min/max already matched). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two related fixes for reading ECCC MSC HRDPS and similar GRIB2 data, shipping in 0.13.4.
1. Add WMO parameter (0, 5, 3) - surface long-wave (thermal) radiation downwards
NGrib's table carried downward long-wave radiation only as the NCEP-local variant (category 5, number 192). ECCC HRDPS and the WMO standard (code table 4.2-0-5) encode it as category 5, number 3, which was missing - so that record resolved to no
Parameterand consumers dropped it. Short-wave (category 4, number 7) already works. Added the WMO entry, mirroring the short-wave one; the reflection-based lookup picks it up automatically (purely additive).2. Fix template 5.3 (complex packing + spatial differencing) decode of zero-group constant fields
A constant field encoded with
NumberOfGroups == 0(e.g. an all-zero sea-ice-fraction field) decoded as garbage (max99785552): the group-decoding loop never writes the secondary-value buffer, which comes fromArrayPool.Rentand holds stale data, and that garbage flowed through the spatial-differencing reconstruction into the output. Zeroing the buffer after renting makes an unwritten (zero-group) field decode to the reference value - matching eccodes, which returns all zeros for this field.This also corrects two pre-existing broken assertions in
Grib2Reader_EastChinaJapan_Testthat the bug masked: the Ice test comparedKeyValuePairelements against0(never valid) - now asserts every decoded value is 0; and the U10 test's expected average was a wrong constant (-0.0677->-0.6774, confirmed with eccodes; min/max already matched).Verification
Grib2Reader_HrdpsLongWave_Test: directParameter.Get(0,5,3)lookup + reading a real HRDPS DLWRF grib, with the decoded field checked cell-for-cell against an independent OpenJPEG decode (min522543.5, max1724543.5J m-2).Bumps the package version to
0.13.4.