NOAA-MDL / grib2io

Python interface to the NCEP G2C Library for reading and writing GRIB2 messages.
https://noaa-mdl.github.io/grib2io
MIT License
30 stars 11 forks source link

grib2io v2.0.0b1 - xarray backend on Hera? #64

Closed lgramer closed 1 year ago

lgramer commented 1 year ago

We are interested in testing with the xarray backend for grib2io v2. We followed the suggested directions for testing on Hera as below. We did not expect the open_dataset call to succeed (these GRB2 output files include pressure coordinates, height coordinates, and "other" - reading them with xarray and the cfgrib engine, for example, is quite complicated). But it seems that xarray does not "see" the grib2io backend yet either. Please see below:

# module use /scratch1/NCEPDEV/mdl/apps/modulefiles
# module load python/3.10
# module list

Currently Loaded Modules:
  1) intel/2022.1.2   2) hpss/hpss   3) rocoto/1.3.1   4) ncview/2.1.7   5) sutils/default   6) python/3.10

# python3
Python 3.10.8 (main, Nov 24 2022, 14:13:03) [GCC 11.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 
>>> import grib2io
>>> import xarray as xr
>>> 
>>> print(grib2io.__version__)
2.0.0b1
>>>
>>> ds = xr.open_dataset('/scratch2/AOML/aoml-hafs1/Lew.Gramer/ocean/hafsv1_fnl.hycom_hfsb_RiC_0p20/coupled/grb2/2022092518/09l.2022092022092518.hfsb.storm.atm.f126.grb2',engine='grib2io')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/scratch1/NCEPDEV/mdl/apps/python/3.10/lib/python3.10/site-packages/xarray/backends/api.py", line 526, in open_dataset
    backend = plugins.get_backend(engine)
  File "/scratch1/NCEPDEV/mdl/apps/python/3.10/lib/python3.10/site-packages/xarray/backends/plugins.py", line 185, in get_backend
    raise ValueError(
ValueError: unrecognized engine grib2io must be one of: ['netcdf4', 'scipy', 'gini', 'store']
EricEngle-NOAA commented 1 year ago

@lgramer - Thanks for letting us know about this. We did fix this issue in the repo with e0b9acec6d49c75fd428f5a0187d96d7067f2e44 and will be fixed in Beta 2.

Specifically related to Hera, I just applied a patch to MDL's Python 3.8 and 3.10 which fixes the issue for Beta 1 installations.