diff --git a/artiq/examples/no_hardware/repository/hdf5_attributes.py b/artiq/examples/no_hardware/repository/hdf5_attributes.py new file mode 100644 index 0000000000..8237435569 --- /dev/null +++ b/artiq/examples/no_hardware/repository/hdf5_attributes.py @@ -0,0 +1,21 @@ +import numpy as np + +from artiq.experiment import * + + +class HDF5Attributes(EnvExperiment): + """Archive data to HDF5 with attributes""" + def run(self): + # Attach attributes to the HDF5 group `datasets` + self.set_dataset_metadata(None, { + "arr": np.array([1, 2, 3]), + "description": "demo", + }) + + dummy = np.empty(20) + dummy.fill(np.nan) + # `archive=True` is required in order to + # attach attributes to HDF5 datasets + self.set_dataset("dummy", dummy, + broadcast=True, archive=True) + self.set_dataset_metadata("dummy", {"k1": "v1", "k2": "v2"})