From 1900b9613a799aa578c0a47cc7caa75d15517c55 Mon Sep 17 00:00:00 2001 From: Laurent Mercadier <laurent.mercadier@xfel.eu> Date: Thu, 27 Feb 2025 09:24:42 +0100 Subject: [PATCH] Add key argument to viking removePolyBaseline() --- src/toolbox_scs/detectors/viking.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/toolbox_scs/detectors/viking.py b/src/toolbox_scs/detectors/viking.py index 6372881..476c527 100644 --- a/src/toolbox_scs/detectors/viking.py +++ b/src/toolbox_scs/detectors/viking.py @@ -270,7 +270,7 @@ class Viking: ret['photoelectrons_per_count'] = self.e_per_counts(run, ret['gain']) return ret - def removePolyBaseline(self, data): + def removePolyBaseline(self, data, key='spectrum'): """ Removes a polynomial baseline to a spectrum, assuming a fixed position for the signal. @@ -279,6 +279,7 @@ class Viking: ---------- data: xarray Dataset The Viking data containing the variable "spectrum" + or given by argument key Output ------ @@ -287,10 +288,10 @@ class Viking: containing the baseline subtracted spectra. """ - if 'spectrum' not in data: + if key not in data: return x = data.newt_x - spectra = data['spectrum'] + spectra = data[key] mask = xr.ones_like(x, dtype=bool) if len(self.BL_SIGNAL_RANGE) > 0: if not hasattr(self.BL_SIGNAL_RANGE[0], '__len__'): @@ -307,7 +308,7 @@ class Viking: final_bl = np.empty(spectra.shape) for t in range(spectra.shape[0]): final_bl[t] = np.polyval(fit[:, t], x) - data['spectrum_nobl'] = spectra - final_bl + data[key+'_nobl'] = spectra - final_bl return data def xas(self, data, data_ref, thickness=1, plot=False, -- GitLab