...
The different GRIB data structure of the EFAS and GloFAS datasets may require some additional configuration. -Read historical datasets
- Read historical datasets:
| Code Block | ||||||
|---|---|---|---|---|---|---|
| ||||||
import xarray as xr
ds = xr.open_dataset("glofas_historical_201901.grib",engine="cfgrib",backend_kwargs={'time_dims':['time']})
|
- Read
...
| title | How 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 | ||||||
|---|---|---|---|---|---|---|
| ||||||
import xarray as xr
# Filtering andReadingsaving 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 andReadingsaving 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")
|