Closed blaylockbk closed 2 years ago
I'm not sure why this broke since 0.9.9.1, but is this on the right path to resolving this?
Replace https://github.com/ecmwf/cfgrib/blob/a0d9763ae5c14b0b180c15ac1090b695e437554c/cfgrib/xarray_plugin.py#L35-L36 with
import pathlib
if isinstance(filename, (str, pathlib.PurePath))
opener = dataset.open_file
Hi @blaylockbk ,
Many thanks for bringing this to our attention. Indeed your fix is absolutely correct! I implemented it myself, but in fact ended up doing exactly the same as your suggestion. The difference in the most recent version is that cfgrib can take more complex objects than strings and paths, and the code assumed that the input was 'string or complex object' but that was not quite sufficient.
Cheers, Iain
Thanks for the quick fix, @iainrussell
cfgrib 0.9.10.0 hits an error when attempting to open a file where the filename is expressed as a
pathlib.Path
object instead of a string. This is not a problem in cfgrib 0.9.9.1.The same is true with xarray:
xr.open_dataset(this_file, engine='cfgrib')