From 69e6b0e2135b77e236568ef7b9e9f0965b828589 Mon Sep 17 00:00:00 2001 From: Danilo Ferreira de Lima <danilo.enoque.ferreira.de.lima@xfel.de> Date: Wed, 1 Mar 2023 14:15:27 +0100 Subject: [PATCH] Switched back to fftconvolve. --- pes_to_spec/__init__.py | 2 +- pes_to_spec/model.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pes_to_spec/__init__.py b/pes_to_spec/__init__.py index cc1b4a3..1f74782 100644 --- a/pes_to_spec/__init__.py +++ b/pes_to_spec/__init__.py @@ -2,4 +2,4 @@ Estimate high-resolution photon spectrometer data from low-resolution non-invasive measurements. """ -VERSION = "0.1.6" +VERSION = "0.1.7" diff --git a/pes_to_spec/model.py b/pes_to_spec/model.py index f17347a..0dcb032 100644 --- a/pes_to_spec/model.py +++ b/pes_to_spec/model.py @@ -3,7 +3,7 @@ from __future__ import annotations import joblib import numpy as np -from scipy.signal import convolve +from scipy.signal import fftconvolve #from scipy.signal import find_peaks_cwt from scipy.optimize import fmin_l_bfgs_b from sklearn.decomposition import PCA @@ -331,7 +331,7 @@ class HighResolutionSmoother(TransformerMixin, BaseEstimator): gaussian = np.exp(-0.5*(energy - mu)**2/self.high_res_sigma**2) gaussian /= np.sum(gaussian, axis=1, keepdims=True) # apply it to the data - high_res_gc = convolve(X, gaussian, mode="same", axes=1) + high_res_gc = fftconvolve(X, gaussian, mode="same", axes=1) return high_res_gc def inverse_transform(self, Xt: np.ndarray) -> np.ndarray: @@ -519,7 +519,7 @@ class SelectRelevantLowResolution(TransformerMixin, BaseEstimator): 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 = convolve(sum_low_res, gaussian, mode="same", axes=0) + smoothened = fftconvolve(sum_low_res, gaussian, mode="same", axes=0) peak_idx = [np.argmax(smoothened)] if len(peak_idx) < 1: raise PromptNotFoundError() @@ -1011,7 +1011,7 @@ class Model(TransformerMixin, BaseEstimator): M = self.wiener_filter.shape[0] B = expected.shape[0] assert expected.shape[1] == M - deconvolved = convolve(expected, + deconvolved = fftconvolve(expected, np.broadcast_to(self.wiener_filter.reshape(1, -1), (B, M)), mode="same", axes=1) -- GitLab