-
Notifications
You must be signed in to change notification settings - Fork 202
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
hdf5: Add demo for saving attributes
Signed-off-by: yuk <yuk@m-labs.hk>
- Loading branch information
1 parent
12c0385
commit 22e6db8
Showing
1 changed file
with
21 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"}) |