From 90c9a732e22b0295c5e43ca255e1706a4e36ad48 Mon Sep 17 00:00:00 2001 From: Laurent Mercadier <laurent.mercadier@xfel.eu> Date: Thu, 20 Oct 2022 21:37:37 +0200 Subject: [PATCH] introduce extract_fadc, extract_adq412, etc... --- src/toolbox_scs/load.py | 56 ++++++++++++++++++++++++++++------------- 1 file changed, 38 insertions(+), 18 deletions(-) diff --git a/src/toolbox_scs/load.py b/src/toolbox_scs/load.py index e9c9417..8c4d96e 100644 --- a/src/toolbox_scs/load.py +++ b/src/toolbox_scs/load.py @@ -40,12 +40,16 @@ def load(proposalNB=None, runNB=None, validate=False, subset=ed.by_index[:], rois={}, - extract_tim=True, - extract_laser=True, + extract_adq412=True, + extract_fadc=True, extract_xgm=True, extract_bam=True, - tim_bp='sase3', - laser_bp='scs_ppl', + adq412_bp='sase3', + fadc_bp='scs_ppl', + extract_tim=None, + extract_laser=None, + tim_bp=None, + laser_bp=None, ): """ Load a run and extract the data. Output is an xarray with aligned @@ -82,12 +86,12 @@ def load(proposalNB=None, runNB=None, 'dim': ['ref_x', 'ref_y']}, 'sam': {'roi':by_index[1050:1210, 535:720], 'dim': ['sam_x', 'sam_y']}}} - extract_tim: bool - If True, extracts the peaks from TIM variables (e.g. 'MCP2raw', + extract_adq412: bool + If True, extracts the peaks from ADQ412 variables (e.g. 'MCP2raw', 'MCP3apd') and aligns the pulse Id with the sase3 bunch pattern. - extract_laser: bool + extract_fadc: bool If True, extracts the peaks from FastADC variables (e.g. 'FastADC5raw', - 'FastADC3peaks') and aligns the pulse Id with the PP laser bunch + 'FastADC3peaks') and aligns the pulse Id according to the fadc_bp bunch pattern. extract_xgm: bool If True, extracts the values from XGM variables (e.g. 'SCS_SA3', @@ -103,6 +107,12 @@ def load(proposalNB=None, runNB=None, bunch pattern used to extract the TIM pulses. Ignored if extract_tim=False. + DEPRECATED ARGUMENTS: + extract_tim: DEPRECATED. Use extract_adq412 instead. + extract_laser: DEPRECATED. Use extract fadc instead. + tim_bp: DEPRECATED. Use adq412_bp instead. + laser_bp: DEPRECATED. Use fadc_bp instead. + Returns ------- run, data: DataCollection, xarray.DataArray @@ -194,16 +204,26 @@ def load(proposalNB=None, runNB=None, data = xr.merge(data_arrays, join='inner') data.attrs['runFolder'] = runFolder - - tim = [k for k in run_mnemonics if 'MCP' in k and k in data] - if extract_tim and len(tim) > 0: - data = tbdet.get_tim_peaks(run, mnemonics=tim, merge_with=data, - bunchPattern=tim_bp) - - laser = [k for k in run_mnemonics if 'FastADC' in k and k in data] - if extract_laser and len(laser) > 0: - data = tbdet.get_laser_peaks(run, mnemonics=laser, merge_with=data, - bunchPattern=laser_bp) + + # backward compatibility with old-defined variables: + if extract_tim is not None: + extract_adq412 = extract_tim + if extract_laser is not None: + extract_fadc = extract_laser + if tim_bp is not None: + adq412_bp = tim_bp + if laser_bp is not None: + fadc_bp = laser_bp + + adq412 = [k for k in run_mnemonics if 'MCP' in k and k in data] + if extract_adq412 and len(adq412) > 0: + data = tbdet.get_digitizer_peaks(run, mnemonics=adq412, merge_with=data, + bunchPattern=adq412_bp) + + fadc = [k for k in run_mnemonics if 'FastADC' in k and k in data] + if extract_fadc and len(fadc) > 0: + data = tbdet.get_digitizer_peaks(run, mnemonics=fadc, merge_with=data, + bunchPattern=fadc_bp) xgm = ['XTD10_XGM', 'XTD10_XGM_sigma', 'XTD10_SA3', 'XTD10_SA3_sigma', 'XTD10_SA1', 'XTD10_SA1_sigma', 'SCS_XGM', 'SCS_XGM_sigma', -- GitLab