简体   繁体   English

无法在 Python 中创建 HDF5 数据集的引用

[英]Unable to create reference of HDF5 dataset in Python

I am using the HDF5 python lib h5py and want to create a reference from an HDF5 dataset by我正在使用 HDF5 python lib h5py 并希望通过以下方式从 HDF5 数据集创建引用

ref = DATASET.regionref[:, :, 0]

However, I receive an error但是,我收到一个错误

 ValueError: Unable to create reference (No write intent on file)

In fact, I haven't and don't want to open the file with write access.事实上,我没有也不想用写权限打开文件。 What can I do?我能做什么?

It seems h5py does not allow region references if the file isn't opened with write access.如果文件没有以写访问权限打开,似乎 h5py 不允许区域引用。 The reason may be that these references act as numpy arrays allowing reading and writing .原因可能是这些引用充当允许读取和写入的numpy 数组。

I didn't find much mentioning of region references in the HDF5 format specification , so I guess one could in principle make them read only.我在 HDF5格式规范中没有发现太多提到区域引用的内容,所以我想原则上可以使它们只读。 This might be a possible request for enhancement for h5py.这可能是对 h5py 的增强请求。

For the time being I would rather use views/slices on the numpy array directly if that is okay with your needs.目前,如果您的需求没问题,我宁愿直接在 numpy 数组上使用视图/切片。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM