The simplest is to use the .valueHDF5 dataset attribute .
>>> hf = h5py.File('/path/to/file', 'r')
>>> data = hf.get('dataset_name').value
You can also slice the dataset that creates the actual ndarray with the requested data:
>>> hf['dataset_name'][:10] # produces ndarray as well
, h5py ndarray. , , , NumPy. , , : np.mean(hf.get('dataset_name')).
EDIT:
. , , HDF5. , h5py. . .
:
>>> f = h5py.File('tmp.h5', 'w')
>>> ds = f.create_dataset('data', data=np.zeros(10,))
.
>>> ref_dtype = h5py.special_dtype(ref=h5py.Reference)
>>> ref_ds = f.create_dataset('data_refs', data=(ds.ref, ds.ref), dtype=ref_dtype)
, , , .
>>> name = h5py.h5r.get_name(ref_ds[0], f.id)
>>> print(name)
b'/data'
>>> out = f[name]
>>> print(out.shape)
(10,)
, , , . TL; DR: .
:
h5py.h5r.dereference , . . , ( ). .