Skip to content

GRIB2 CCSDS reader fails to read messages with constant values #1498

@Armin-RS

Description

@Armin-RS

GRIB2_constant_fields_examples.zip

Versions impacted by the bug

Tested with Panoply 5.7.1 which uses netCDF-Java to v. 5.9.1 (snapshot 8/29)

What went wrong?

Support for CCSDS compressed GRIB2 files was recently added with #753.
While trying to incorporate this capability into tools used by the German Flood Forecasting Centers, we got an error message when reading GRIB2 files from forecasts by Deutscher Wetterdienst (DWD):
There was an exception performing initial data gridding: Allocation size must be greater than zero.
This happened when trying to read data from a precipitation, snowfall or solar radiation parameter with a time-step 0 which is constant 0.0 in the whole model domain.

The reason seems to be that in this case, the GRIB2 section 7 is empty, i.e. its length is only 5 bytes.

The correct contant value (0.0 in most cases) is coded as float "referenceValue" in bytes 12-15 of Section 5.
The correct number of grid points is also coded in Section 5 as "Number of data points" in bytes 6-9.

The attached testfiles for a small domain in Germany with identical content as uncompressed and CCSDS compressed GRIB2 files show that this is also the case for constant fields with non-zero values.
The testfiles contain:

  • Message 1: constant 0.0
  • Message 2: constant 5.5
  • Message 3: 80 in the south, 160 in the north
  • Message 4: typical precipitation field

For Messages 1 & 2, Section 7 contains only 5 bytes.
For Messages 3 & 4, Section 7 has its normal length.
Section 7 for Message 3 is strongly compressed in the CCSDS case since it contains only two distinct values.

While the testfiles contains artificial data, this case also arises for real-world forecasts and not only for time-step 0, e.g. in case of a small domain and dry conditions (i.e. no rainfall for longer time-periods) or for snowfall in summer (when temperatures are too high for snowfall).

Note that these cases are handled correctly in the case of the uncompressed GRIB2 example.
It would be very helpful, if this could be fixed for the CCSDS compressed GRIB2 example.

Relevant stack trace

Relevant log messages

Panoply error message when trying to plot the Total Precipitation parameter
"There was an exception performing initial data gridding: Allocation size must be greater than zero."

If you have an example file that you can share, please attach it to this issue.

If so, may we include it in our test datasets to help ensure the bug does not return once fixed?
Note: the test datasets are publicly accessible without restriction.

Yes

Code of Conduct

  • I agree to follow the UCAR/Unidata Code of Conduct

Metadata

Metadata

Assignees

Labels

bugSomething isn't workinggrib2

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions