qmi.data.hdf5recorder

This module provides a class for recording data to an HDF5 file.

Classes

HDF5Recorder(filename[, write_interval, ...])

The HDF5Recorder class is used to record data to an HDF5 file while the experiment is running.

class qmi.data.hdf5recorder.HDF5Recorder(filename: str, write_interval: float = 30.0, keep_open: bool = False, backend: str = 'h5py')

The HDF5Recorder class is used to record data to an HDF5 file while the experiment is running. This is as opposed to the normal data saving routines, which are used to save data after the experiment has finished.

For example, we use the HDF5Recorder to record the data from the timetaggers, which can generate a large amount of data, that would not fit in RAM.

Example

>>> recorder = HDF5Recorder(path_to_hf5_file, write_interval=10.0)
>>> recorder.record("x0", timestamps)
close() None

Close the HDF5 file.

record(dset_name: str, dset_values: ndarray) None

Record data to the HDF5 file.

Parameters:
  • dset_name – the name of the dataset to write to, e.g. “x0”.

  • dset_values – the data to write to the dataset, should be a numpy array.

set_attribute(dset_name: str, attr_name: str, attr_val: int | float | str) None

Add or update a HDF5 attribute in the dataset.

Attributes can only be written to existing datasets. If the named dataset does not yet exist, the attribute will be cached in the HDF5Recorder until the dataset is created by recording data to it. If the dataset is never created, pending attribute values are lost when the HDF5Recorder is closed.

Parameters:
  • dset_name – Name of the dataset to write the attribute to.

  • attr_name – Attribute name.

  • attr_val – Attribute value. Only numbers and strings are currently supported.