ecmwf / cfgrib

A Python interface to map GRIB files to the NetCDF Common Data Model following the CF Convention using ecCodes
Apache License 2.0
409 stars 77 forks source link

to_grib not able to write ensemble forecasts in GRIB v1 ? #316

Open jodemaey opened 2 years ago

jodemaey commented 2 years ago

Hi there,

I'm presently trying to load, modify and rewrite ECMWF perturbed members using to_grib in GRIB v1, and despite all the other needed keys being there, the keys perturbationNumber and numberOfForecastsInEnsemble are not present in the final output file.

All the members are present in the output grib file but it is impossible to know which member is which one. Therefore, later I cannot reload correctly once gain using cf_grib.

Is there a way to do it properly or this is not yet implemented?

Thank you in advance,

Jonathan

shahramn commented 2 years ago

The GRIB edition 1 standard does not include ensemble forecasts. We have to use a "local definition" to store the perturbation number etc See https://apps.ecmwf.int/codes/grib/format/grib1/local/

jodemaey commented 2 years ago

Oh I see, then I guess using a local definition is not possible with to_grib , right? Or is it possible?

jodemaey commented 2 years ago

Ok I switched to v2 and it worked. Up to you to see if you want this to remain open or not.

Edit: FYI, even in v2, I had to impose the perturbationNumber by hand via grib_keys because to_grib was not picking it from my xarray dataset coordinate number.