From 609a6daea001694c50b8bbfd8ceef38de56a6029 Mon Sep 17 00:00:00 2001 From: Philipp Niedermayer <p.niedermayer@gsi.de> Date: Wed, 4 May 2022 17:38:54 +0200 Subject: [PATCH] Support data saved via DCCT --- common/utils.py | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/common/utils.py b/common/utils.py index 1e4e31f..ea62c03 100644 --- a/common/utils.py +++ b/common/utils.py @@ -28,7 +28,7 @@ from .bdiolib.bdio import bdio @dataclass class LassieSpillData(Trace): - """Container for time series data from lassie spill application + """Container for time series data from lassie spill or DCCT application t - time array in seconds v - value array in unit @@ -36,14 +36,13 @@ class LassieSpillData(Trace): """ t: np.ndarray v: np.ndarray - unit: str = 'a.u.' + unit: str = 'particles' @classmethod - def from_file(cls, fname, calibrated=True, from_event=None, verbose=1): - """Read in time series data from a *.tdf file saved with lassiespill application + def from_file(cls, fname, from_event=None, verbose=1): + """Read in time series data from a *.tdf file saved with lassiespill or DCCT application :param fname: path to filename - :param calibrated: use calibrated or raw data :param from_event: return data from this event, time will also be relative to this event References: https://git.acc.gsi.de/bi/bdiolib.python @@ -56,36 +55,36 @@ class LassieSpillData(Trace): fs = None t0 = 0 t1 = None - unit = 'a.u.' + unit = 'particles' blocks = b.get_directory() for bi in blocks: b.seek(bi.get_pos()) block = b.next_block() - #print(bi) - #print(block) + if verbose: print(bi.get_title(), block) #if hasattr(block, 'get_rows'): # for row in block.get_rows(): # print(row) ############### - if bi.is_header_block(): + if bi.is_header_block(): appname = block.get_app_name() device = block.get_device() + if verbose: print(device, 'data saved from', appname) elif bi.get_title() == 'TraceInfo': for row in block.get_rows(): if verbose: print(row) - if row.get_tag() == 'sampling frequency': + if row.get_tag() == ('intensity frequency' if appname=='DCCT' else 'sampling frequency'): assert row.get_unit().lower() == 'hz', 'sampling frequency has unexpected unit {}'.format(row.get_unit()) fs = row.get_value() elif bi.get_title() == 'Integrals': for row in block.get_rows(): if verbose: print(row) - if row.get_tag() == ('Calibrated' if calibrated else 'Raw') + ': beam in integral': + if row.get_tag() == 'Calibrated: beam in integral': unit = row.get_unit() - elif bi.get_title() == ('Calibrated' if calibrated else 'Raw'): + elif bi.is_double_array_block() and bi.get_title() == ('Intensity' if appname=='DCCT' else 'Calibrated'): values = np.array(block.get_array()) elif bi.is_event_table_block(): -- GitLab