Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The different GRIB data structure of the EFAS and GloFAS datasets may require some additional configuration. -Read historical datasets 

  •  Read historical datasets:


Code Block
languagepy
titleRead historical
collapsetrue
import xarray as xr

ds = xr.open_dataset("glofas_historical_201901.grib",engine="cfgrib",backend_kwargs={'time_dims':['time']})


  • Read 

...

titleHow to correctly read GRIB with heterogeneous types

...

  • Read a GRIB file that has multiple product types:

There are 4 datasets that may have more that one product type in a GRIB file:

EFAS forecast:  "control reforecast", "ensemble perturbed reforecast", "high resolution forecast"

EFAS reforecast: "control reforecast", "ensemble perturbed reforecast" 

GloFAS historical: "consolidated", "intermediate"

GloFAS forecast:  "control reforecast", "ensemble perturbed reforecasts" 

GloFAS reforecast: "control reforecast", "ensemble perturbed reforecast" 

In order to read them you need to specify which product type you are reading using the backend_kwargs

Code Block
languagepy
titleRead GRIB file with 2 product types
collapsetrue
import xarray as xr

# 
Filtering and
Reading 
saving
the Control reforecast (cf) data

glofas_cf = xr.open_dataset("Glofas_forecast.grib",  engine='cfgrib', backend_kwargs={'filter_by_keys': {'dataType': 'cf'}, 'indexpath':''}
)  glofas_cf.to_netcdf("Glofas_forecast_cf.nc"



 # 
Filtering and
Reading 
saving
the Ensemble perturbed reforecasts (pf) data

glofas_pf = xr.open_dataset("Glofas_forecast.grib ",  engine='cfgrib', backend_kwargs={'filter_by_keys': {'dataType': 'pf'}, 'indexpath':''}
)  glofas_pf.to_netcdf("Glofas_forecast_pf.nc"