I'm trying to run through the provided notebook but encountered errors at safely_expand_dims due to a pre-existing valid_time coordinate in the GRIB file I'm working with.
The GRIB in question was downloaded today using cdsapi and can be acquired using the following snippet:
Download sample ERA5L GRIB
import cdsapi
dataset = "reanalysis-era5-land"
request = {
"product_type": ["reanalysis"],
"variable": ["10m_u_component_of_wind"],
"year": ["1993"],
"month": ["03"],
"day": [
"01", "02", "03",
"04", "05", "06",
"07", "08", "09",
"10", "11", "12",
"13", "14", "15",
"16", "17", "18",
"19", "20", "21",
"22", "23", "24",
"25", "26", "27",
"28", "29", "30",
"31"
],
"time": [
"00:00", "01:00", "02:00",
"03:00", "04:00", "05:00",
"06:00", "07:00", "08:00",
"09:00", "10:00", "11:00",
"12:00", "13:00", "14:00",
"15:00", "16:00", "17:00",
"18:00", "19:00", "20:00",
"21:00", "22:00", "23:00"
],
"data_format": "grib",
"download_format": "unarchived"
}
client = cdsapi.Client()
client.retrieve(dataset, request).download('era5l.1993.03.10m_u_component_of_wind.grib')
the exact error I am seeing is
ValueError: valid_time already exists as coordinate or variable name.
which makes sense because valid_time does exist as a coordinate in the cfgrib-parsed xarray dataset (see below), but is unused for the u10 variable. When the CDS provides a NetCDF version of a GRIB, do these "unused" coordinates get dropped altogether?
<xarray.Dataset> Size: 20GB
Dimensions: (time: 32, step: 24, latitude: 1801, longitude: 3600)
Coordinates:
number int64 8B ...
* time (time) datetime64[ns] 256B 1993-02-28 1993-03-01 ... 1993-03-31
* step (step) timedelta64[ns] 192B 01:00:00 ... 1 days 00:00:00
surface float64 8B ...
* latitude (latitude) float64 14kB 90.0 89.9 89.8 ... -89.8 -89.9 -90.0
* longitude (longitude) float64 29kB 0.0 0.1 0.2 0.3 ... 359.7 359.8 359.9
valid_time (time, step) datetime64[ns] 6kB ...
Data variables:
u10 (time, step, latitude, longitude) float32 20GB ...
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: 2025-06-26T16:02 GRIB to CDM+CF via cfgrib-0.9.1...
The history attr provides a clue but I am not sure what is meant by the encode_cf key:
2025-06-26T16:08 GRIB to CDM+CF via cfgrib-0.9.14.1/ecCodes-2.30.2 with {"source": "era5l.1993.03.10m_u_component_of_wind.grib", "filter_by_keys": {}, "encode_cf": ["parameter", "time", "geography", "vertical"]}
As an experiment, I also downloaded the experimental-netcdf version from CDS and see that most of the extra GRIB coordinates are dropped, but a new expver is added that seems to indicate preliminary vs official data releases. This expver isn't commented on in the notebook so I'm even more confused.
I would like to be able to replicate as-closely-as-possible the "Experimental NetCDF" delivery method that the CDS provides but I can't quite seem to figure out what's going on server-side. Is there a public repo containing the various conversion tools used at ECMWF CDS?
Thanks!
I'm trying to run through the provided notebook but encountered errors at
safely_expand_dimsdue to a pre-existingvalid_timecoordinate in the GRIB file I'm working with.The GRIB in question was downloaded today using
cdsapiand can be acquired using the following snippet:Download sample ERA5L GRIB
the exact error I am seeing is
which makes sense because
valid_timedoes exist as a coordinate in thecfgrib-parsedxarraydataset (see below), but is unused for theu10variable. When the CDS provides a NetCDF version of a GRIB, do these "unused" coordinates get dropped altogether?The
historyattr provides a clue but I am not sure what is meant by theencode_cfkey:As an experiment, I also downloaded the experimental-netcdf version from CDS and see that most of the extra GRIB coordinates are dropped, but a new
expveris added that seems to indicate preliminary vs official data releases. Thisexpverisn't commented on in the notebook so I'm even more confused.I would like to be able to replicate as-closely-as-possible the "Experimental NetCDF" delivery method that the CDS provides but I can't quite seem to figure out what's going on server-side. Is there a public repo containing the various conversion tools used at ECMWF CDS?
Thanks!