cedadev / ceda-jaspy-envs

Conda (Jaspy) environments for CEDA/JASMIN
BSD 2-Clause "Simplified" License
5 stars 0 forks source link

add cfgrib #111

Closed alaniwi closed 1 year ago

alaniwi commented 2 years ago

Per user request (HS ticket 56226).

Conda package cfgrib - separate from, but can be used by, xarray.

To test:

# test file 2.5MB
wget https://github.com/pydata/xarray-data/raw/7d8290e0be9d2a8f4b4381641f20a97db6eaea3d/era5-2mt-2019-03-uk.grib

and then:

import xarray as xr
​ds = xr.open_dataset("era5-2mt-2019-03-uk.grib", engine="cfgrib")
print(ds)
t2m = ds.variables['t2m']
assert t2m.shape == (744, 33, 49)
assert 282.3 < float(t2m[2,3,4]) < 282.4
assert t2m.attrs['long_name'] == '2 metre temperature'
alaniwi commented 1 year ago

adding to Spring 2023 release (including test added)