I am wondering if there's a way to mix the high-level API with the low-level API using h5py.

Example: I have a hdf5 file I'm accessing through the high-level interface.

import h5py
f = h5py.File("Somefile.h5")
ds = f["/path/to/some/Dataset"]

Now, the ds object is a h5py.Dataset which is perfect for most of what I need to do. However, I'd like to figure out the size of this dataset as stored on disk. The low-level interface provides h5py.h5d.DatasetID.get_storage_space() which does exactly what I want, but I don't know how to call this from my high-level object.

Is there a way to find the underlying low-level object from the high-level API?

有帮助吗?

解决方案

Found a solution. Although not in the docs, searching through the highlevel object interactively using dir() showed the solution. The highlevel objects have links to their corresponding low level objects with non-obvious names.

In the question above, ds._id returns the DatasetID associated with the Dataset. Now I can call ds._id.get_storage_space().

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top