Offset Longitude Values in FNL GRIB1 files.
abrammer opened this issue · comments
What happened?
Old FNL files return a longitude dimension of -1 to 358. This seems to be wrong and it should actually be 0 to 359.
Looking at the grib internals, the file seems to be encoded as 0 to -1 with a 1° increment and 360 values.
Dumping to netcdf and visualizing the orography field also suggests that everything is offset by 1°. Although it's kind of hard to tell as it's only 1 grid point.
What are the steps to reproduce the bug?
Grab a grib1 file from RDA
wget https://data.rda.ucar.edu/ds083.2/grib1/1999/1999.08/fnl_19990801_00_00.grib1
import cfgrib
import xarray as xr
local_file = "fnl_19990801_00_00.grib1"
ds = xr.open_dataset(local_file,
engine='cfgrib', backend_kwargs={'indexpath':''},
filter_by_keys={'typeOfLevel': 'surface' },
)
print(ds['longitude'])
<xarray.DataArray 'longitude' (longitude: 360)>
array([ -1., 0., 1., ..., 356., 357., 358.])
Version
0.9.10.4
Platform (OS and architecture)
x86_64 GNU/Linux
Relevant log output
The dataarray attributes reveal the grib encoding:
:GRIB_gridType = "regular_ll";
:GRIB_NV = 0L; // long
:GRIB_Nx = 360L; // long
:GRIB_Ny = 181L; // long
:GRIB_cfName = "geopotential_height";
:GRIB_cfVarName = "orog";
:GRIB_gridDefinitionDescription = "Latitude/Longitude Grid";
:GRIB_iDirectionIncrementInDegrees = 1.0; // double
:GRIB_iScansNegatively = 0L; // long
:GRIB_jDirectionIncrementInDegrees = 1.0; // double
:GRIB_jPointsAreConsecutive = 0L; // long
:GRIB_jScansPositively = 0L; // long
:GRIB_latitudeOfFirstGridPointInDegrees = 90.0; // double
:GRIB_latitudeOfLastGridPointInDegrees = -90.0; // double
:GRIB_longitudeOfFirstGridPointInDegrees = 0.0; // double
:GRIB_longitudeOfLastGridPointInDegrees = -1.0; // double
Accompanying data
Land-Sea Mask for UK and Europe highlights issue as well.
Organisation
No response