-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problem parsing negative longitude values in Lambert Azimuthal Equal Area grid specs #427
Comments
@webisu is this the problem you were referring to between g2c and wgrib2? |
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.
Produces this output:
Note that 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: