ecmwf / eccodes-python

Python interface to the ecCodes GRIB/BUFR decoder/encoder

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Module/attribute problem within Eccodes module

jcorner1 opened this issue · comments

I'm trying to use Eccodes in opening a file and I get this error message:

AttributeError Traceback (most recent call last)
in ()
----> 1 ds = xr.open_dataset(os.path.join(pathfiles,datafile), engine='cfgrib')

~\Anaconda3\lib\site-packages\xarray\backends\api.py in open_dataset(filename_or_obj, group, decode_cf, mask_and_scale, decode_times, autoclose, concat_characters, decode_coords, engine, chunks, lock, cache, drop_variables, backend_kwargs, use_cftime)
515 elif engine == "cfgrib":
516 store = backends.CfGribDataStore(
--> 517 filename_or_obj, lock=lock, **backend_kwargs
518 )
519

~\Anaconda3\lib\site-packages\xarray\backends\cfgrib_.py in init(self, filename, lock, **backend_kwargs)
36
37 def init(self, filename, lock=None, **backend_kwargs):
---> 38 import cfgrib
39
40 if lock is None:

~\Anaconda3\lib\site-packages\cfgrib_init_.py in ()
17
18 # cfgrib core API depends on the ECMWF ecCodes C-library only
---> 19 from .cfmessage import CfMessage
20 from .dataset import Dataset, DatasetBuildError, open_file, open_fileindex
21 from .messages import Message, FileStream

~\Anaconda3\lib\site-packages\cfgrib\cfmessage.py in ()
27 import numpy as np # noqa
28
---> 29 from . import messages
30
31 LOG = logging.getLogger(name)

~\Anaconda3\lib\site-packages\cfgrib\messages.py in ()
47 # MULTI-FIELD support is very tricky. Random access via the index needs multi support to be off.
48 #
---> 49 eccodes.codes_grib_multi_support_off()
50
51

AttributeError: module 'pyeccodes.compat' has no attribute 'codes_grib_multi_support_off'

Here is my line of code:
ds = xr.open_dataset(os.path.join(pathfiles,datafile), engine='cfgrib')

Not sure if it's a bug or just using pip instead of conda to install cfgrib as well as Eccodes. I tried to use conda but it wouldn't install in the base environment.

@jcorner1 this is a tricky one, cfgrib didn't yet announce compatibility with eccodes-python and the use of CFGRIB_USE_EXTERNAL_ECCODES_BINDINGS is experimental. And in fact the support is broken starting from version 0.9.8.2. Please use version 0.9.8.1 for now.

@shahramn I should have finally solved the MULTI-FIELD message issues but I needed to use a number of internal interfaces. Now is a good time to sync up.

I'll review the latest version of eccodes-python and report back here.

@alexamici That did indeed fix the issue I was having. Thanks!