I have an issue for few days with xarray and CDS.
The issue
I download data from CDS Copernicus using this link
import cdsapi
c = cdsapi.Client()
c.retrieve(
'reanalysis-era5-single-levels',
{
'product_type': 'reanalysis',
'variable': '2m_temperature',
'year': '2017',
'month': '01',
'day': '01',
'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',
],
'format': 'netcdf',
},
'download.nc')
and then I open the file with:
file = 'download.nc'
ds = xarray.open_mfdataset(file, engine="netcdf4")
However, the data are not correct.
Here you can see an example for 2017-01-01 12:00
To create the plot, I use this method:
def scalarPlot(
ax,
data: Dataset,
variable: List[str],
geoPosition: Optional[Tuple[float, float, float, float]],
cmap: Colormap,
normalizer: Normalize,
x: str = "longitude",
y: str = "latitude",
transform: crs.Projection = crs.PlateCarree(),
**kwargs,
):
data[variable[0]].plot(
ax=ax,
x=x,
y=y,
transform=transform,
cmap=cmap,
norm=normalizer,
cbar_kwargs={
"label": FigureUtils.getLabel(data=data, variable=variable),
"boundaries": numpy.linspace(normalizer.vmin, normalizer.vmax, 250),
"ticks": numpy.linspace(normalizer.vmin, normalizer.vmax, 11),
"orientation": "vertical",
"shrink": 0.5,
"extend": "both",
},
**kwargs,
)
Data is provide in a dataset and I use the xarray.plot()
method to display the data. However, the issue seems to come from the reading of the downloaded file (see raw data screenshot).
When I use the CDS toolbox, data is shown correctly
My setup
The current libraries I installed are:
xarray: 2022.3.0
pandas: 1.4.3
numpy: 1.23.1
scipy: 1.8.1
netCDF4: 1.6.0
pydap: None
h5netcdf: None
h5py: None
Nio: None
zarr: None
cftime: 1.6.1
nc_time_axis: None
PseudoNetCDF: None
rasterio: None
cfgrib: 0.9.10.1
iris: None
bottleneck: None
dask: 2022.7.0
distributed: None
matplotlib: 3.5.2
cartopy: 0.20.3
seaborn: None
numbagg: None
fsspec: 2022.5.0
cupy: None
pint: 0.19.2
sparse: None
setuptools: 59.6.0
pip: 22.1.2
conda: None
pytest: None
IPython: None
sphinx: None
Questions
Is there a known issue with this library ?
Few weeks ago, CDS experienced an important disturbance. But it has been solved. https://confluence.ecmwf.int/pages/viewpage.action?pageId=278543465 Does the issue impact also something else ?
Best regards, Thomas