From 1745bb1b7fdab84e3e3e589b983cc9f8099c0ddb Mon Sep 17 00:00:00 2001 From: Laurent Mercadier <laurent.mercadier@xfel.eu> Date: Tue, 20 Feb 2024 09:24:32 +0100 Subject: [PATCH] Fix ADC mnemonic dim names, add more mnemonics for grid sample and TPI, fix loading bpt in digitizers --- src/toolbox_scs/constants.py | 31 ++++++++++++++++++++----- src/toolbox_scs/detectors/digitizers.py | 22 +++++++++++------- 2 files changed, 39 insertions(+), 14 deletions(-) diff --git a/src/toolbox_scs/constants.py b/src/toolbox_scs/constants.py index ac2673c..eb57f0c 100644 --- a/src/toolbox_scs/constants.py +++ b/src/toolbox_scs/constants.py @@ -70,6 +70,7 @@ mnemonics = { 'dim': ['BAMbunchId'], 'extract': 'BAM'},), + # SA3 "nrj": ({'source': 'SA3_XTD10_MONO/MDL/PHOTON_ENERGY', 'key': 'actualEnergy.value', @@ -86,6 +87,9 @@ mnemonics = { "tpi": ({'source': 'SCS_XTD10_TPI/DCTRL/SHUTTER', 'key': 'operationModePLC.value', 'dim': None},), + "TPI_STATE": ({'source': 'SCS_XTD10_TPI/DCTRL/SHUTTER', + 'key': 'hardwareStatusBitField.value', + 'dim': None},), "VSLIT": ({'source': 'SA3_XTD10_VSLIT/MDL/BLADE', 'key': 'actualGap.value', 'dim': None},), @@ -397,6 +401,9 @@ mnemonics = { "PP800_FocusLens": ({'source': 'SCS_ILH_LAS/MOTOR/LT_SPARE1', 'key': 'actualPosition.value', 'dim': None},), + "PP800_HWP_POLARIZATION": ({'source': 'SCS_CDIFFT_FDM/MOTOR/FOCUS_1', + 'key': 'actualPosition.value', + 'dim': None},), "LIN_FocusLens": ({'source': 'SCS_CDIFFT_FDM/MOTOR/FOCUS_2', 'key': 'actualPosition.value', 'dim': None},), @@ -544,6 +551,12 @@ mnemonics = { "scannerY_enc": ({'source': 'SCS_CDIFFT_SAM/ENC/SCANNERY', 'key': 'value.value', 'dim': None},), + "sampleH": ({'source': 'SCS_CDIFFT_SAM/MDL/GRIDSAMPLE', + 'key': 'actualH.value', + 'dim': None},), + "sampleK": ({'source': 'SCS_CDIFFT_SAM/MDL/GRIDSAMPLE', + 'key': 'actualK.value', + 'dim': None},), "FFT_SAM_Z": ({'source': 'SCS_CDIFFT_MOV/MOTOR/SAM_Z', 'key': 'actualPosition.value', 'dim': None},), @@ -715,6 +728,12 @@ mnemonics = { "MTE3": ({'source': 'SCS_CDIDET_MTE3/CAM/CAMERA:daqOutput', 'key': 'data.image.pixels', 'dim': ['x', 'y']},), + "GRID_H": ({'source': 'SCS_CDIFFT_SAM/MDL/GRIDSAMPLE', + 'key': 'actualH.value', + 'dim': None},), + "GRID_K": ({'source': 'SCS_CDIFFT_SAM/MDL/GRIDSAMPLE', + 'key': 'actualK.value', + 'dim': None},), # Andor Newton CCD camera "newton": ({'source': 'SCS_EXP_NEWTON/CAM/CAMERA:daqOutput', @@ -929,27 +948,27 @@ mnemonics = { 'extract': 'peaks'},), "FFT_PD2raw": ({'source': 'SCS_FFT_DIAG/ADC/PD2:output', 'key': 'data.rawData', - 'dim': ['fadc2_samplesId'], + 'dim': ['fftpd2_samplesId'], 'extract': 'peaks'},), "FFT_MCPraw": ({'source': 'SCS_FFT_MCP/ADC/MCP:output', 'key': 'data.rawData', - 'dim': ['fadc2_samplesId'], + 'dim': ['fftmcp_samplesId'], 'extract': 'peaks'},), "FFT_REFLraw": ({'source': 'SCS_FFT_REFL/ADC/DIODE_UP:output', 'key': 'data.rawData', - 'dim': ['fadc2_samplesId'], + 'dim': ['fftrefl_samplesId'], 'extract': 'peaks'},), "I0_ILHraw": ({'source': 'SCS_ILH_LAS/ADC/I0_ILH:output', 'key': 'data.rawData', - 'dim': ['fadc2_samplesId'], + 'dim': ['i0ilh_samplesId'], 'extract': 'peaks'},), "I0_LINraw": ({'source': 'SCS_LIN_LAS/ADC/I0:output', 'key': 'data.rawData', - 'dim': ['fadc2_samplesId'], + 'dim': ['i0lin_samplesId'], 'extract': 'peaks'},), "REFLECTOMETERraw": ({'source': 'SCS_LIN_LAS/ADC/REFLECTOMETER:output', 'key': 'data.rawData', - 'dim': ['fadc2_samplesId'], + 'dim': ['linrefl_samplesId'], 'extract': 'peaks'},), # KARABACON diff --git a/src/toolbox_scs/detectors/digitizers.py b/src/toolbox_scs/detectors/digitizers.py index 2fb86b5..d69efd4 100644 --- a/src/toolbox_scs/detectors/digitizers.py +++ b/src/toolbox_scs/detectors/digitizers.py @@ -240,9 +240,10 @@ def get_peaks(run, arr = run.get_array(source, key) if isinstance(data, str): log.debug(f'Loading array from mnemonic {data}') - arr = run.get_array(*run_mnemonics[data].values()) - source = run_mnemonics[data]['source'] - key = run_mnemonics[data]['key'] + m = run_mnemonics[data] + source = m['source'] + key = m['key'] + arr = run.get_array(source, key, m['dim']) if arr is None: log.debug('Using array provided in data argument.') if source is None or key is None: @@ -257,7 +258,8 @@ def get_peaks(run, extra_dims=['pulse_slot']) pattern = bunchPattern['pattern'] if 'bunchPatternTable' in run_mnemonics: - bpt = run.get_array(*run_mnemonics['bunchPatternTable'].values()) + m = run_mnemonics['bunchPatternTable'] + bpt = run.get_array(m['source'], m['key'], m['dim']) pattern = bunchPattern else: pattern = bunchPattern @@ -397,7 +399,8 @@ def get_dig_avg_trace(run, mnemonic, ntrains=None): total_tid = len(run.train_ids) stride = int(np.max([1, np.floor(total_tid/ntrains)])) sel = run.select_trains(np.s_[0:None:stride]) - raw_trace = sel.get_array(*run_mnemonics[mnemonic].values()) + m =run_mnemonics[mnemonic] + raw_trace = sel.get_array(m['source'], m['key'], m['dim']) raw_trace = raw_trace.mean(dim='trainId') return raw_trace @@ -729,7 +732,8 @@ def check_peak_params(run, mnemonic, raw_trace=None, ntrains=200, params=None, if 'bunchPatternTable' in run_mnemonics and bunchPattern != 'None': sel = run.select_trains(np.s_[:ntrains]) bp_params = {} - bpt = sel.get_array(*run_mnemonics['bunchPatternTable'].values()) + m = run_mnemonics['bunchPatternTable'] + bpt = sel.get_array(m['source'], m['key'], m['dim']) mask = is_pulse_at(bpt, bunchPattern) pid = np.sort(np.unique(np.where(mask)[1])) bp_params['npulses'] = len(pid) @@ -1012,10 +1016,12 @@ def get_digitizer_peaks(run, mnemonics=None, merge_with=None, bpt = merge_with['bunchPatternTable'] log.debug('Using bpt from merge_with dataset.') elif 'bunchPatternTable' in run_mnemonics: - bpt = run.get_array(*run_mnemonics['bunchPatternTable'].values()) + m = run_mnemonics['bunchPatternTable'] + bpt = run.get_array(m['source'], m['key'], m['dim']) log.debug('Loaded bpt from DataCollection.') elif 'bunchPatternTable_SA3' in run_mnemonics: - bpt = run.get_array(*run_mnemonics['bunchPatternTable_SA3'].values()) + m = run_mnemonics['bunchPatternTable_SA3'] + bpt = run.get_array(m['source'], m['key'], m['dim']) log.debug('Loaded bpt from DataCollection.') else: bpt = None -- GitLab