From c386fc88a2280f952852c24cf128ed2762a8501d Mon Sep 17 00:00:00 2001 From: rafael-desktop <rafael.gort@gmail.com> Date: Mon, 27 Apr 2020 11:53:09 +0200 Subject: [PATCH] Added wrappers for external bunch pattern decoding --- bunch_pattern_external.py | 115 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 bunch_pattern_external.py diff --git a/bunch_pattern_external.py b/bunch_pattern_external.py new file mode 100644 index 0000000..6fae700 --- /dev/null +++ b/bunch_pattern_external.py @@ -0,0 +1,115 @@ +""" +A collection of wrappers around the the euxfel_bunch_pattern pkg +---------------------------------------------------------------- + +The euxfel_bunch_pattern package provides generic methods to extract +information from the bunch pattern tables. To ease its use from within +the toolbox some of its methods are wrapped. Like this they show up in +the users namespace in a self-explanatory way. +""" + +import euxfel_bunch_pattern as ebp + +PPL_SCS = ebp.LASER_SEED6 + + +def is_sase_3(data): + """ + Check for prescence of a SASE3 pulse. + + Parameters + ---------- + data : numpy array, xarray DataArray + The bunch pattern data. + + Returns + ------- + boolean : numpy array, xarray DataArray + true if SASE3 pulse is present. + """ + return ebp.is_sase(data, 3) + + +def is_sase_1(data): + """ + Check for prescence of a SASE1 pulse. + + Parameters + ---------- + data : numpy array, xarray DataArray + The bunch pattern data. + + Returns + ------- + boolean : numpy array, xarray DataArray + true if SASE1 pulse is present. + """ + return ebp.is_sase(data, 1) + + +def is_ppl(data): + """ + Check for prescence of pp-laser pulse. + + Parameters + ---------- + data : numpy array, xarray DataArray + The bunch pattern data. + + Returns + ------- + boolean : numpy array, xarray DataArray + true if pp-laser pulse is present. + """ + return ebp.is_laser(data, laser=PPL_SCS) + + +def get_index_ppl(data): + """ + Check array index where pp-laser pulse is present. + + Parameters + ---------- + data : numpy array + The bunch pattern data. + + Returns + ------- + boolean : numpy array + The indices of the pp-laser pulses in the given array. + """ + return ebp.indices_at_laser(data, laser=PPL_SCS) + + +def get_index_sase1(data): + """ + Search for array index where SASE1 pulse is present. + + Parameters + ---------- + data : numpy array + The bunch pattern data. + + Returns + ------- + boolean : numpy array + The indices of the SASE1 pulses in the given array. + """ + return ebp.indices_at_sase(data, 1) + + +def get_index_sase3(data): + """ + Search for array index where SASE3 pulse is present. + + Parameters + ---------- + data : numpy array + The bunch pattern data. + + Returns + ------- + boolean : numpy array + The indices of the SASE3 pulses in the given array. + """ + return ebp.indices_at_sase(data, 3) -- GitLab