API python script no longer working following netcdf era5 change

HEllo,

Apparently there was a change mentioned in:

Which causes my script to no longer work
I used to download my data by envoking:
wave_variables = ['mean_direction_of_total_swell', 'significant_height_of_total_swell', 'mean_wave_period_of_first_swell_partition']

kwargs_wave_limits_1day = { 'variable': wave_variables, 'product_type': 'reanalysis', 'year': '2022', 'month': '1', 'day': ['01'], 'area': limits, 'time': '00:00', 'format': 'netcdf', }
cds_file_path_wave = os.path.join(os.getcwd(), 'tmp_working_dir', 'wave_limits_1day_download_lat%s.nc' % lat)

ct.retrieve(dataset, kwargs_wave_limits_1day, cds_file_path_wave)

Then I would access the data using
import xarray as xr
wave_variables_1day = xr.open_dataset(os.path.join(cds_file_path_wave))

But this no longer works.
I then tried using
from netCDF4 import Dataset
nc = Dataset(cds_file_path_wave 'r')

But this also doesn’t work.

for xr attempt I get the following error:
ValueError: did not find a match in any of xarray’s currently installed IO backends [‘netcdf4’, ‘h5netcdf’, ‘scipy’, ‘cfgrib’, ‘zarr’]. Consider explicitly selecting one of the installed engines via the engine parameter, or installing additional IO dependencies, see:.......
But this script works on old downloaded .nc files.
Any suggestions?

Thank you

Hi Jim,

I suspect this may be because the file provided by the CDS for download may be a zip archive. Can you try unzipping the file before using it?

Thank you for that.

I was tricked by the fact that it is a zipped file with a .nc extension.

By implementing a “is this file zipped” test I am now able to get it to work.