From ac5e32e54606470bddcf8416f46ce490e05badaf Mon Sep 17 00:00:00 2001 From: Philipp Schmidt <philipp.schmidt@xfel.eu> Date: Wed, 6 Mar 2024 10:27:32 +0100 Subject: [PATCH] Support different attributes for parent group, value and timestamp datasets in DataFile API --- src/exdf/write/datafile.py | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/exdf/write/datafile.py b/src/exdf/write/datafile.py index 32fc13d..82c2cab 100644 --- a/src/exdf/write/datafile.py +++ b/src/exdf/write/datafile.py @@ -470,7 +470,7 @@ class ControlSource(Source): return self.file.require_group(f'INDEX/{self._exdf_source}') def create_key(self, key, values=None, timestamps=None, run_entry=None, - attrs=None): + attrs=None, attrs_value=None, attrs_timestamp=None): """Create datasets for a key varying each train. Args: @@ -506,13 +506,21 @@ class ControlSource(Source): if attrs is not None: grp.attrs.update(attrs) + if attrs_value is not None: + grp['value'].attrs.update(attrs_value) + + if attrs_timestamp is not None: + grp['timestamp'].attrs.update(attrs_timestamp) + if run_entry is not False: if run_entry is None and values is not None: run_entry = (values[0], timestamps[0]) - self.create_run_key(key, *run_entry, attrs) + self.create_run_key(key, *run_entry, attrs, attrs_value, + attrs_timestamp) - def create_run_key(self, key, value, timestamp=None, attrs=None): + def create_run_key(self, key, value, timestamp=None, attrs=None, + attrs_value=None, attrs_timestamp=None): """Create datasets for a key constant over a run. Args: @@ -560,6 +568,12 @@ class ControlSource(Source): if attrs is not None: grp.attrs.update(attrs) + if attrs_value is not None: + grp['value'].attrs.update(attrs_value) + + if attrs_timestamp is not None: + grp['timestamp'].attrs.update(attrs_timestamp) + return grp def create_index(self, num_trains, per_train=None): -- GitLab