aodn / python-aodntools

Repository for templates and code relating to generating standard NetCDF files for the Australia Ocean Data Network
GNU Lesser General Public License v3.0
10 stars 3 forks source link

Aggregated Temperature Product: error relating to xarray NetCDF engine (solved) #166

Closed mphemming closed 1 year ago

mphemming commented 2 years ago

I was getting an error on line 227 similar to the below:

ValueError: unrecognized engine cfgrib must be one of: ['netcdf4', 'scipy', 'store']

I made the following changes on line 227: with xr.open_dataset(os.path.join(input_dir, file)) as nc: to with xr.open_dataset(os.path.join(input_dir, file), engine='netcdf4') as nc:

The script worked after this change.

However, today I deleted this extra code and ran again to test if I can replicate the error and I no longer receive it. It might have been that my version of xarray needed updating, and I have since done that.

mhidas commented 2 years ago

Thanks @mphemming . Good to know you have solved the issue. It seems strange that xarray would fail to automatically pick the right engine, unless your input file had something unusual about it?

mhidas commented 2 years ago

Package versions can definitely make a big difference. I've also found that with pandas and xarray, being quite actively developed. There can be significant changes in functionality between versions.

FYI, on our production servers we are still running this code under Python 3.5 (no longer supported!), with the following package versions:

netCDF4                1.5.3
pandas                 0.24.2
xarray                 0.11.3

Very soon we'll upgrade all that to python 3.8 with

netCDF4==1.5.8
pandas==1.3.5
xarray==2022.3.0
mhidas commented 1 year ago

Closing as it has been resolved. @mphemming feel free to reopen if this happens again