Skip to content
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

Offset Longitude Values in FNL GRIB1 files. #367

Open
abrammer opened this issue Jan 17, 2024 · 0 comments
Open

Offset Longitude Values in FNL GRIB1 files. #367

abrammer opened this issue Jan 17, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@abrammer
Copy link

abrammer commented Jan 17, 2024

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.

orog_in_fnl

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.
lsm_in_fnl

Organisation

No response

@abrammer abrammer added the bug Something isn't working label Jan 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant