diff --git a/pes_to_spec/__init__.py b/pes_to_spec/__init__.py index cc1b4a38efdd3d7366c91f28c4aa276bd6a5fb6b..1f747822ee6f034d8a4187097c908045560ba40b 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 f17347aa4bfdf30d74ebf450b29c95c74057c451..0dcb032fe304e2b4fcfb59646bd2bae32300422d 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)