访问 Xarray 数据集时的 HDF5 警告

jam*_*lly 12 hdf5 netcdf python-xarray netcdf4

我想了解导致我在以下情况下收到警告消息的原因:

在之前的操作中,我创建了一些 NetCDF 文件并使用xarray.to_netcdf().

在 jupyter 笔记本中对这些数据集进行惰性评估完全没问题,并且在以下情况下我不会收到警告/错误:

  • .nc通过打开这些文件ds = xarray.open_mfdataset('/path/to/files/*.nc')
  • 通过以下方式将尺寸数据加载到内存中ds.time.values
  • 惰性选择通过ds.sel(time=starttime)

我似乎能够在对内存加载的数据进行计算时做我想做的一切。但是,我经常在以下情况下收到相同的错误集:

  • 通过加载数据来绘图ds.sel(time=starttime).SCALAR_DATA.plot()
  • 通过提取/加载数据ts = pd.Series(ds.SCALAR_DATA.loc[:,y,x], index=other_data.index)

请注意,尽管有这些警告,我执行的操作确实会产生预期的结果(绘图、时间序列结构等)。

生成以下错误的共同点似乎是从打开的数据集中加载数据。编辑:经过一些进一步的实验,我的工作环境中的软件包版本可能会导致依赖 HDF5 的软件包版本之间发生一些冲突。

以下错误重复多次。

HDF5-DIAG: Error detected in HDF5 (1.12.2) thread 1:
  #000: H5A.c line 528 in H5Aopen_by_name(): can't open attribute
    major: Attribute
    minor: Can't open object
  #001: H5VLcallback.c line 1091 in H5VL_attr_open(): attribute open failed
    major: Virtual Object Layer
    minor: Can't open object
  #002: H5VLcallback.c line 1058 in H5VL__attr_open(): attribute open failed
    major: Virtual Object Layer
    minor: Can't open object
  #003: H5VLnative_attr.c line 130 in H5VL__native_attr_open(): can't open attribute
    major: Attribute
    minor: Can't open object
  #004: H5Aint.c line 545 in H5A__open_by_name(): unable to load attribute info from object header
    major: Attribute
    minor: Unable to initialize object
  #005: H5Oattribute.c line 494 in H5O__attr_open_by_name(): can't locate attribute: '_QuantizeBitGroomNumberOfSignificantDigits'
    major: Attribute
    minor: Object not found

...

HDF5-DIAG: Error detected in HDF5 (1.12.2) thread 2:
  #000: H5A.c line 528 in H5Aopen_by_name(): can't open attribute
    major: Attribute
    minor: Can't open object
  #001: H5VLcallback.c line 1091 in H5VL_attr_open(): attribute open failed
    major: Virtual Object Layer
    minor: Can't open object
  #002: H5VLcallback.c line 1058 in H5VL__attr_open(): attribute open failed
    major: Virtual Object Layer
    minor: Can't open object
  #003: H5VLnative_attr.c line 130 in H5VL__native_attr_open(): can't open attribute
    major: Attribute
    minor: Can't open object
  #004: H5Aint.c line 545 in H5A__open_by_name(): unable to load attribute info from object header
    major: Attribute
    minor: Unable to initialize object
  #005: H5Oattribute.c line 476 in H5O__attr_open_by_name(): can't open attribute
    major: Attribute
    minor: Can't open object
  #006: H5Adense.c line 394 in H5A__dense_open(): can't locate attribute in name index
    major: Attribute
    minor: Object not found

Run Code Online (Sandbox Code Playgroud)

对于可能导致这些问题的任何建议,我们将不胜感激。

nbe*_*dou 8

这些警告可能是由netcdf4版本引起的1.6.X

降级以netcdf4=1.5.8解决我的问题。

另请参阅https://github.com/SciTools/iris/issues/5187


chr*_*ris 6

过去几天我一直在努力解决非常类似的错误,最终发现限制我的 dask 客户端每个工作线程使用 1 个线程解决了这个问题,即:

import xrarray as xr
from dask.distributed import Client
c = Client(n_workers=os.cpu_count()-2, threads_per_worker=1)

ds = xr.open_mfdataset('/path/to/files/*.nc')
ds.sel(.... )
Run Code Online (Sandbox Code Playgroud)

如果 jpolly 的解决方案不适合你,值得一试(就我而言,我没有使用 conda ...)


jam*_*lly 2

conda解决各个包之间的依赖关系最终成为我摆脱这些警告的解决方案。

当我手动安装所有不同的软件包,而没有仔细指定版本或解决conda依赖关系时,警告仍然存在。

编辑:这个答案对此有一个很好的解释