Skip to content

Functionality Not Enabled Error When Opening GEM GRIB Files #10767

@edrewitz

Description

@edrewitz

What happened?

Hi! I was trying to open a file that has GEM model data after downloading it with the following code:

import xarray as xr
ds = xr.open_dataset(f"GEM GLOBAL/ABSV_ISBL_200/CMC_glb_ABSV_ISBL_200_latlon.15x.15_2025091712_P000.grib2", engine='cfgrib')

This worked but then I got this Functionality Not Enabled Error when trying to see the data array of the variable via the following:

ds['absv'].values

This error has only showed up when dealing with the Canadian model so far. I haven't seen this when looking at any other model's GRIB data so far. I've also done this in the same environment with the other models.

What did you expect to happen?

I expected to see the values in the data array corresponding to the variable.

Minimal Complete Verifiable Example

# /// script
# requires-python = ">=3.11"
# dependencies = [
#   "xarray[complete]@git+https://github.com/pydata/xarray.git@main,
# ]
# ///
#
# This script automatically imports the development branch of xarray to check for issues

import xarray as xr
xr.show_versions()
# your reproducer code ...

Steps to reproduce

No response

MVCE confirmation

  • Minimal example — the example is as focused as reasonably possible to demonstrate the underlying issue in xarray.
  • Complete example — the example is self-contained, including all data and the text of any traceback.
  • Verifiable example — the example copy & pastes into an IPython prompt or Binder notebook, returning the result.
  • New issue — a search of GitHub Issues suggests this is not a duplicate.
  • Recent environment — the issue occurs with the latest version of xarray and its dependencies.

Relevant log output

---------------------------------------------------------------------------
FunctionalityNotEnabledError              Traceback (most recent call last)
Cell In[6], line 1
----> 1 ds['absv'].values

File ~\miniconda3\envs\wxdata\Lib\site-packages\xarray\core\dataarray.py:797, in DataArray.values(self)
    784 @property
    785 def values(self) -> np.ndarray:
    786     """
    787     The array's data converted to numpy.ndarray.
    788 
   (...)    795     to this array may be reflected in the DataArray as well.
    796     """
--> 797     return self.variable.values

File ~\miniconda3\envs\wxdata\Lib\site-packages\xarray\core\variable.py:556, in Variable.values(self)
    553 @property
    554 def values(self) -> np.ndarray:
    555     """The variable's data as a numpy.ndarray"""
--> 556     return _as_array_or_item(self._data)

File ~\miniconda3\envs\wxdata\Lib\site-packages\xarray\core\variable.py:336, in _as_array_or_item(data)
    322 def _as_array_or_item(data):
    323     """Return the given values as a numpy array, or as an individual item if
    324     it's a 0d datetime64 or timedelta64 array.
    325 
   (...)    334     TODO: remove this (replace with np.asarray) once these issues are fixed
    335     """
--> 336     data = np.asarray(data)
    337     if data.ndim == 0:
    338         kind = data.dtype.kind

File ~\miniconda3\envs\wxdata\Lib\site-packages\xarray\core\indexing.py:577, in ExplicitlyIndexed.__array__(self, dtype, copy)
    572 def __array__(
    573     self, dtype: np.typing.DTypeLike = None, /, *, copy: bool | None = None
    574 ) -> np.ndarray:
    575     # Leave casting to an array up to the underlying array type.
    576     if Version(np.__version__) >= Version("2.0.0"):
--> 577         return np.asarray(self.get_duck_array(), dtype=dtype, copy=copy)
    578     else:
    579         return np.asarray(self.get_duck_array(), dtype=dtype)

File ~\miniconda3\envs\wxdata\Lib\site-packages\xarray\core\indexing.py:943, in MemoryCachedArray.get_duck_array(self)
    942 def get_duck_array(self):
--> 943     duck_array = self.array.get_duck_array()
    944     # ensure the array object is cached in-memory
    945     self.array = as_indexable(duck_array)

File ~\miniconda3\envs\wxdata\Lib\site-packages\xarray\core\indexing.py:897, in CopyOnWriteArray.get_duck_array(self)
    896 def get_duck_array(self):
--> 897     return self.array.get_duck_array()

File ~\miniconda3\envs\wxdata\Lib\site-packages\xarray\core\indexing.py:737, in LazilyIndexedArray.get_duck_array(self)
    734 from xarray.backends.common import BackendArray
    736 if isinstance(self.array, BackendArray):
--> 737     array = self.array[self.key]
    738 else:
    739     array = apply_indexer(self.array, self.key)

File ~\miniconda3\envs\wxdata\Lib\site-packages\cfgrib\xarray_plugin.py:163, in CfGribArrayWrapper.__getitem__(self, key)
    159 def __getitem__(
    160     self,
    161     key: xr.core.indexing.ExplicitIndexer,
    162 ) -> np.ndarray:
--> 163     return xr.core.indexing.explicit_indexing_adapter(
    164         key, self.shape, xr.core.indexing.IndexingSupport.BASIC, self._getitem
    165     )

File ~\miniconda3\envs\wxdata\Lib\site-packages\xarray\core\indexing.py:1129, in explicit_indexing_adapter(key, shape, indexing_support, raw_indexing_method)
   1107 """Support explicit indexing by delegating to a raw indexing method.
   1108 
   1109 Outer and/or vectorized indexers are supported by indexing a second time
   (...)   1126 Indexing result, in the form of a duck numpy-array.
   1127 """
   1128 raw_key, numpy_indices = decompose_indexer(key, shape, indexing_support)
-> 1129 result = raw_indexing_method(raw_key.tuple)
   1130 if numpy_indices.tuple:
   1131     # index the loaded duck array
   1132     indexable = as_indexable(result)

File ~\miniconda3\envs\wxdata\Lib\site-packages\cfgrib\xarray_plugin.py:172, in CfGribArrayWrapper._getitem(self, key)
    167 def _getitem(
    168     self,
    169     key: T.Tuple[T.Any, ...],
    170 ) -> np.ndarray:
    171     with self.datastore.lock:
--> 172         return self.array[key]

File ~\miniconda3\envs\wxdata\Lib\site-packages\cfgrib\dataset.py:374, in OnDiskArray.__getitem__(self, item)
    372     # NOTE: fill a single field as found in the message
    373     message = self.index.get_field(message_ids[0])  # type: ignore
--> 374     values = get_values_in_order(message, array_field[tuple(array_field_indexes)].shape)
    375     array_field.__getitem__(tuple(array_field_indexes)).flat[:] = values
    377 array = np.asarray(array_field[(Ellipsis,) + item[-self.geo_ndim :]])

File ~\miniconda3\envs\wxdata\Lib\site-packages\cfgrib\dataset.py:329, in get_values_in_order(message, shape)
    326 def get_values_in_order(message, shape):
    327     # type: (abc.Field, T.Tuple[int]) -> np.ndarray
    328     # inform the data provider to return missing values as missing_value
--> 329     values = message["values"]
    330     # for 2D array (lat/lon) re-arrange if alternative row scanning
    331     if len(shape) == 2 and message.get("alternativeRowScanning", False):

File ~\miniconda3\envs\wxdata\Lib\site-packages\cfgrib\messages.py:247, in ComputedKeysAdapter.__getitem__(self, item)
    245     return getter(self)
    246 else:
--> 247     return self.context[item]

File ~\miniconda3\envs\wxdata\Lib\site-packages\cfgrib\messages.py:169, in Message.__getitem__(self, item)
    167     raise ValueError("key type not supported %r" % key_type_text)
    168 key_type = KEY_TYPES[key_type_text]
--> 169 return self.message_get(key, key_type=key_type)

File ~\miniconda3\envs\wxdata\Lib\site-packages\cfgrib\messages.py:132, in Message.message_get(self, item, key_type, default)
    130 try:
    131     if eccodes.codes_get_size(self.codes_id, item) > 1:
--> 132         values = eccodes.codes_get_array(self.codes_id, item, key_type)
    133     else:
    134         values = [eccodes.codes_get(self.codes_id, item, key_type)]

File ~\miniconda3\envs\wxdata\Lib\site-packages\gribapi\gribapi.py:2028, in grib_get_array(msgid, key, ktype)
   2026     result = grib_get_long_array(msgid, key)
   2027 elif ktype is float or ktype is np.float64:
-> 2028     result = grib_get_double_array(msgid, key)
   2029 elif ktype is np.float32:
   2030     result = grib_get_float_array(msgid, key)

File ~\miniconda3\envs\wxdata\Lib\site-packages\gribapi\gribapi.py:1196, in grib_get_double_array(msgid, key)
   1194 vals_p = ffi.cast("double *", arr.ctypes.data)
   1195 err = lib.grib_get_double_array(h, key.encode(ENC), vals_p, length_p)
-> 1196 GRIB_CHECK(err)
   1197 return arr

File ~\miniconda3\envs\wxdata\Lib\site-packages\gribapi\gribapi.py:226, in GRIB_CHECK(errid)
    218 """
    219 Utility function checking the ecCodes error code and raising
    220 an error if that was set.
   (...)    223 @exception CodesInternalError
    224 """
    225 if errid:
--> 226     errors.raise_grib_error(errid)

File ~\miniconda3\envs\wxdata\Lib\site-packages\gribapi\errors.py:381, in raise_grib_error(errid)
    377 def raise_grib_error(errid):
    378     """
    379     Raise the GribInternalError corresponding to ``errid``.
    380     """
--> 381     raise ERROR_MAP[errid](errid)

FunctionalityNotEnabledError: Functionality not enabled

Anything else we need to know?

No response

Environment

INSTALLED VERSIONS ------------------ commit: None python: 3.13.5 | packaged by conda-forge | (main, Jun 16 2025, 08:20:19) [MSC v.1943 64 bit (AMD64)] python-bits: 64 OS: Windows OS-release: 11 machine: AMD64 processor: Intel64 Family 6 Model 186 Stepping 3, GenuineIntel byteorder: little LC_ALL: None LANG: None LOCALE: ('English_United States', '1252') libhdf5: 1.14.4 libnetcdf: 4.9.2

xarray: 2025.7.1
pandas: 2.3.1
numpy: 2.3.2
scipy: 1.16.0
netCDF4: 1.7.2
pydap: None
h5netcdf: None
h5py: None
zarr: None
cftime: 1.6.4.post1
nc_time_axis: None
iris: None
bottleneck: None
dask: 2025.7.0
distributed: None
matplotlib: 3.10.3
cartopy: 0.24.1
seaborn: None
numbagg: None
fsspec: 2025.7.0
cupy: None
pint: 0.24.4
sparse: None
flox: None
numpy_groupies: None
setuptools: 80.9.0
pip: 25.1.1
conda: None
pytest: None
mypy: None
IPython: 9.4.0
sphinx: None

Metadata

Metadata

Assignees

No one assigned

    Labels

    plan to closeMay be closeable, needs more eyeballs

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions