HDF5 recordings#

Configure writing with dendra.models.callbacks.Recorder.set_hdf5() and close the recorder before opening the file. H5Reader provides lazy Dask arrays; compute values while the reader remains open:

from dendra.data import H5Reader

with H5Reader("recording.h5") as reader:
    voltage = reader["v"][0][:].compute()

The first index selects a recorded variable, the second selects its run, and the final index slices the concatenated time axis. See Recording and online analysis for writing and cadence.

class H5Reader(path)[source]#

Read a Recorder HDF5 file as lazily concatenated Dask arrays.

Parameters:

path (str or path-like) – Existing HDF5 recording file. Finish and close the recorder before reading.

Notes

Use as a context manager. reader[variable][run_index] selects a run; indexing that run returns a lazy Dask array. Compute the array while the reader is open. Access through a closed reader raises ValueError.

property closed#

Whether the underlying HDF5 file handle is closed.

__getitem__(key)[source]#

Return the named recorded variable as an H5Var handle.

close()[source]#

Close the underlying HDF5 file handle; repeated calls are safe.

__enter__()[source]#
__exit__(exc_type, exc_value, traceback)[source]#
vars()[source]#

Return recorded variable names in natural sort order.

class H5Var(group, reader, name)[source]#

Variable handle returned by H5Reader.

Index with a non-negative integer to select run_0, run_1, and so on. The parent reader must remain open while reading a run.

__getitem__(key)[source]#

Return the numbered run as an H5Rec handle.

n()[source]#

Return the number of stored runs for this variable.

keys()[source]#

Return stored run names in natural sort order.

class H5Rec(group, reader, name, run)[source]#

One run returned by indexing an H5Var handle.

data#

Recording chunks concatenated along the leading time axis in natural chunk order. Other axes preserve the Recorder’s selected layout.

Type:

dask.array.Array

Notes

Indexing this handle returns a lazy slice of data. Compute it before closing the parent H5Reader.

__getitem__(key)[source]#

Return a lazy slice of the concatenated recording.