From 2da69da10903280969d19b25de359bc32b51c7ec Mon Sep 17 00:00:00 2001 From: Martin Teichmann <martin.teichmann@xfel.eu> Date: Thu, 8 Feb 2024 21:57:07 +0100 Subject: [PATCH] add super-special code for the MTE3 the MTE3 is train-tagged too late, we need to date to the TPI. --- src/toolbox_scs/load.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/toolbox_scs/load.py b/src/toolbox_scs/load.py index a038c02..67a87d9 100644 --- a/src/toolbox_scs/load.py +++ b/src/toolbox_scs/load.py @@ -171,7 +171,24 @@ def load(proposalNB=None, runNB=None, log.warning(f'Source {v["source"]} not found in run. Skipping!') print(f'Source {v["source"]} not found in run. Skipping!') continue - if k not in rois: + if k == 'MTE3': + arr = run.get_array(v['source'], v['key'], + extra_dims=v['dim'], name=k) + tpi = run.get_array('SCS_XTD10_TPI/DCTRL/SHUTTER', + 'hardwareStatusBitField.value', name=k) + tpi_open = iter(tpi.trainId[tpi & (1 << 12) > 0]) + + mte3_tids = [] + last = 0 + current = next(tpi_open) + for tid in arr.trainId: + while current < tid: + last = current + current = next(tpi_open, tid) + mte3_tids.append(last) + data_arrays.append( + arr.assign_coords(trainId=np.array(mte3_tids, dtype='u8'))) + elif k not in rois: # no ROIs selection, we read everything arr = run.get_array(v['source'], v['key'], extra_dims=v['dim'], name=k) -- GitLab