Era5 data for wind
grib_ls -p shortName,name,paramId,table2Version,indicatorOfParameter era5_wdir-ws.grib
ws Wind speed 10 128 10
ws Wind speed 10 128 10
ws Wind speed 10 128 10
...
wdir Wind direction 3031 3 31
wdir Wind direction 3031 3 31
wdir Wind direction 3031 3 31
So, grib_ls gives the proper variable name. Under python, using xarray with cfgrib backend:
ws_dataset = xr.open_dataset(
grib_file_path_wind_str,
engine='cfgrib',
indexpath='', # Evita que cfgrib cree un fichero índice
backend_kwargs={'filter_by_keys': {'table2Version': 128,
'indicatorOfParameter': 10}}
)
wdir_dataset = xr.open_dataset(
grib_file_path_wind_str,
engine='cfgrib',
indexpath='',
backend_kwargs={'filter_by_keys': {'table2Version': 3,
'indicatorOfParameter': 31}}
)
And ws_dataset is:
<xarray.Dataset>
Dimensions: (time: 8760, latitude: 13, longitude: 23)
Coordinates:
number int64 0
* time (time) datetime64[ns] 2010-01-01 ... 2010-12-31T23:00:00
step timedelta64[ns] 00:00:00
surface float64 0.0
* latitude (latitude) float64 30.0 29.75 29.5 29.25 ... 27.5 27.25 27.0
* longitude (longitude) float64 -18.5 -18.25 -18.0 ... -13.5 -13.25 -13.0
valid_time (time) datetime64[ns] ...
Data variables:
ws (time, latitude, longitude) float32 ...
Attributes:
GRIB_edition: 1
GRIB_centre: ecmf
GRIB_centreDescription: European Centre for Medium-Range Weather Forecasts
GRIB_subCentre: 0
Conventions: CF-1.7
institution: European Centre for Medium-Range Weather Forecasts
history: 2024-01-16T10:25 GRIB to CDM+CF via cfgrib-0.9.1...
So, the variable name has been properly set, but for wdir_dataset:
<xarray.Dataset>
Dimensions: (time: 8760, latitude: 13, longitude: 23)
Coordinates:
number int64 ...
* time (time) datetime64[ns] 2010-01-01 ... 2010-12-31T23:00:00
step timedelta64[ns] ...
surface float64 ...
* latitude (latitude) float64 30.0 29.75 29.5 29.25 ... 27.5 27.25 27.0
* longitude (longitude) float64 -18.5 -18.25 -18.0 ... -13.5 -13.25 -13.0
valid_time (time) datetime64[ns] ...
Data variables:
p3031 (time, latitude, longitude) float32 ...
Attributes:
GRIB_edition: 1
GRIB_centre: ecmf
GRIB_centreDescription: European Centre for Medium-Range Weather Forecasts
GRIB_subCentre: 0
Conventions: CF-1.7
institution: European Centre for Medium-Range Weather Forecasts
history: 2024-01-16T10:25 GRIB to CDM+CF via cfgrib-0.9.1...
Why does the grib tool grib_ls get the proper variable name and cfgrib not? I have installed both grib tools and python/xarray/cfgrib under a conda environment, and use them from that conda environment.