From d0c9fa19e38c727c793f09fdefee257fc801b6a5 Mon Sep 17 00:00:00 2001 From: Danilo Ferreira de Lima <danilo.enoque.ferreira.de.lima@xfel.de> Date: Mon, 16 Oct 2023 14:29:43 +0200 Subject: [PATCH] Subtract PES pedestal when finding RoI. --- pes_to_spec/model.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pes_to_spec/model.py b/pes_to_spec/model.py index 389c082..911ddd4 100644 --- a/pes_to_spec/model.py +++ b/pes_to_spec/model.py @@ -337,13 +337,14 @@ class SelectRelevantLowResolution(TransformerMixin, BaseEstimator): """ # reduce on channel and on train ID sum_low_res = - np.mean(sum(list(X.values())), axis=0) + zero_level = np.amin(sum_low_res) axis = np.arange(0.0, sum_low_res.shape[0], 1.0) #widths = np.arange(10, 50, step=5) #peak_idx = find_peaks_cwt(sum_low_res, widths) gaussian = np.exp(-0.5*(axis - sum_low_res.shape[0]//2)**2/20**2) gaussian /= np.sum(gaussian, axis=0, keepdims=True) # apply it to the data - smoothened = fftconvolve(sum_low_res, gaussian, mode="same", axes=0) + smoothened = fftconvolve(sum_low_res - zero_level, gaussian, mode="same", axes=0) peak_idx = [np.argmax(smoothened)] if len(peak_idx) < 1: raise PromptNotFoundError() -- GitLab