Add support to write a `xarray.Dataset` to a GRIB file.
See original GitHub issueDue to the fact that the NetCDF data model is much more free and extensible than the GRIB one, it is not possible to write a generic xarray.Dataset
to a GRIB file. The aim for cfgrib
is to implement write support for a subset of carefully crafted datasets that fit the GRIB data model.
In particular the only coordinates that we target at the moment are the one returned by opening a GRIB with the cfgrib
flavour of cfgrib.open_dataset
, namely:
number
, time
, step
, a vertical coordinate (isobaricInhPa
, heightAboveGround
, surface
, etc), and the horizontal coordinates (for example latitude
and longitude
for a regular_ll
grid type).
Note that all passed GRIB_
attributes are used to set keys in the output file, it is left to the user to ensure coherence among them.
Some of the keys are autodetected from the coordinates, namely:
Horizontal coordinates gridType
s:
- regular:
regular_ll
andregular_gg
- not target: projected:
lambert
, etc (can be controlled withGRIB_
attributes) - not target: reduced:
reduced_ll
andreduced_gg
(can be controlled withGRIB_
attributes)
Vertical coordinates typeOfLevel
:
- single level:
surface
,meanSea
, etc. - pressure:
isobaricInhPa
andisobaricInPa
- other:
hybrid
GRIB edition:
- GRIB2
- GRIB1
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:10 (3 by maintainers)
Top GitHub Comments
@alexamici - thanks for the very quick response! I can confirm that the code in the master branch works perfectly for this file now, and I plotted the fields with metview to check that they look identical (they do)!
Another error:
Update
We should import to_grib using the newest name.