diff --git a/src/toolbox_scs/load.py b/src/toolbox_scs/load.py index a038c025a619de85de53830d43aab567fc89d8bf..67a87d9d7b2b75b91f4bc175c4dafe94a55b1b84 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)