CEMS-Flood data comes primarily in GRIB2 format.
To read GRIB files we encourage using Python and the xarray's CFGRIB engine.
Follow the instructions below to install the required libraries, assuming you are working on a Linux OS.
First of all install Conda, a Python packages and environments manager.
Then open a terminal and type:
Start a python console (it is important that you have activated the local environment) and type:
The different GRIB data structure of the EFAS and GloFAS datasets may require some additional configuration.
-Read historical datasets
import xarray as xr ds = xr.open_dataset("glofas_historical_201901.grib",engine="cfgrib",backend_kwargs={'time_dims':['time']})
- Read
How to correctly read GRIB with heterogeneous types
If you download both 'control reforecast' and ‘ensemble perturbed reforecasts' products in a single GRIB file, in order to read it in Python you will need to pass a backward_kwargs dictionary in the open_dataset function, as in the examples below:
import xarray as xr # Filtering and 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 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")