You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Running wgrib2 -v prints the specification of the Lambert Azimuthal Equal Area grid on which this data resides.
wgrib2 -V ukv_agl_temperature_1.5_12.grib2
Lambert Azimuthal Equal Area grid: (1042 x 970) input WE:SN output WE:SN res 48
Lat1 44.517153 Lon1 2164.600777 Cen Lon -2.500000 Std Par 54.900000
Dx 2000.000000 m Dy 2000.000000 m mode 48
The problem is in this Lon1 2164.600777 value. That should actually be -17.11713 instead!
This can be seen by running the following wgrib2 command:
The GRIB2 Template 3.140 (for LAEA grids), indicates that "LO1" is stored in bytes 43 to 46. The -get_int option for bytes 43 to 46 correctly returns a value of -17117129 in micro-degrees, or -17.117129 in degrees.
Note that I also confirmed this by running the grib_dump utility from ECMWF:
The issue seems to be that the grib2c library isn't correctly parsing the leading negative sign when populating the igdstmpl array. This issue may also exist for the central longitude value of -2.5. While wgrib2 does correctly report its negative value, the MET code on which I work did not. You can see a comment about this issue in this line of the MET code.
FYI, my current workaround in the MET code is calling the following parse_int4() utility to reprocess the bytes checking for the leading negative sign.
The grib2 standard sets the convention that longitudes are between 0 and 360 degrees. So Sec 3, Octets 43-46 and Octets 51-54 should be interpreted as an unsigned integer. Strictly speaking, the original grib file is encoded incorrectly. However, there is no drawback if one interprets the values to be a 4-byte signed integer, So wgrib2 v3.1.2 interprets "lon1" and "Cen lon" to be a signed integers. How other libraries handle poorly encoded grib files is up to their maintainers.
@webisu thanks for the followup. So perhaps this issue belongs to wgrib2 more so than the grib2c library?
Although, I did discuss this with @GwenChen-NOAA at the METplus NOAA User Telecon this morning. She pointed me to a more recent version of wgrib2 (v3.1.4b2) on Hera with which I could test. And indeed, the problem is resolved in that version.
Lambert Azimuthal Equal Area grid: (1042 x 970) input WE:SN output WE:SN res 48
Lat1 44.517153 Lon1 -17.117129 Cen Lon -2.500000 Std Par 54.900000
Dx 2000.000000 m Dy 2000.000000 m mode 48
Note that Lon1 -17.117129 replaces Lon1 2164.600777.
So I'd say that this issue can probably just be closed as being no longer relevant... but will leave it to the repo managers to do so.
I'm writing to inform you of a potential bug in the grib2c library revealed via testing with the wgrib2 utility.
Here's the GRIB2 file to demonstrate the issue:
ukv_agl_temperature_1.5_12.grib2.gz
Running
wgrib2 -v
prints the specification of the Lambert Azimuthal Equal Area grid on which this data resides.The problem is in this
Lon1 2164.600777
value. That should actually be -17.11713 instead!This can be seen by running the following
wgrib2
command:The GRIB2 Template 3.140 (for LAEA grids), indicates that "LO1" is stored in bytes 43 to 46. The
-get_int
option for bytes 43 to 46 correctly returns a value of-17117129
in micro-degrees, or-17.117129
in degrees.Note that I also confirmed this by running the
grib_dump
utility from ECMWF:The issue seems to be that the grib2c library isn't correctly parsing the leading negative sign when populating the
igdstmpl
array. This issue may also exist for the central longitude value of -2.5. Whilewgrib2
does correctly report its negative value, the MET code on which I work did not. You can see a comment about this issue in this line of the MET code.FYI, my current workaround in the MET code is calling the following parse_int4() utility to reprocess the bytes checking for the leading negative sign.
The text was updated successfully, but these errors were encountered: