Skip to content

Commit

Permalink
hdf5: Add demo for saving attributes
Browse files Browse the repository at this point in the history
Signed-off-by: yuk <yuk@m-labs.hk>
  • Loading branch information
yuk-m-labs committed Oct 17, 2022
1 parent 12c0385 commit 22e6db8
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions artiq/examples/no_hardware/repository/hdf5_attributes.py
Original file line number Diff line number Diff line change
@@ -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"})

0 comments on commit 22e6db8

Please sign in to comment.