Skip to content
Snippets Groups Projects
Commit 69e6b0e2 authored by Danilo Ferreira de Lima's avatar Danilo Ferreira de Lima
Browse files

Switched back to fftconvolve.

parent cc7a024b
No related branches found
No related tags found
No related merge requests found
...@@ -2,4 +2,4 @@ ...@@ -2,4 +2,4 @@
Estimate high-resolution photon spectrometer data from low-resolution non-invasive measurements. Estimate high-resolution photon spectrometer data from low-resolution non-invasive measurements.
""" """
VERSION = "0.1.6" VERSION = "0.1.7"
...@@ -3,7 +3,7 @@ from __future__ import annotations ...@@ -3,7 +3,7 @@ from __future__ import annotations
import joblib import joblib
import numpy as np import numpy as np
from scipy.signal import convolve from scipy.signal import fftconvolve
#from scipy.signal import find_peaks_cwt #from scipy.signal import find_peaks_cwt
from scipy.optimize import fmin_l_bfgs_b from scipy.optimize import fmin_l_bfgs_b
from sklearn.decomposition import PCA from sklearn.decomposition import PCA
...@@ -331,7 +331,7 @@ class HighResolutionSmoother(TransformerMixin, BaseEstimator): ...@@ -331,7 +331,7 @@ class HighResolutionSmoother(TransformerMixin, BaseEstimator):
gaussian = np.exp(-0.5*(energy - mu)**2/self.high_res_sigma**2) gaussian = np.exp(-0.5*(energy - mu)**2/self.high_res_sigma**2)
gaussian /= np.sum(gaussian, axis=1, keepdims=True) gaussian /= np.sum(gaussian, axis=1, keepdims=True)
# apply it to the data # 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 return high_res_gc
def inverse_transform(self, Xt: np.ndarray) -> np.ndarray: def inverse_transform(self, Xt: np.ndarray) -> np.ndarray:
...@@ -519,7 +519,7 @@ class SelectRelevantLowResolution(TransformerMixin, BaseEstimator): ...@@ -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.exp(-0.5*(axis - sum_low_res.shape[0]//2)**2/20**2)
gaussian /= np.sum(gaussian, axis=0, keepdims=True) gaussian /= np.sum(gaussian, axis=0, keepdims=True)
# apply it to the data # 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)] peak_idx = [np.argmax(smoothened)]
if len(peak_idx) < 1: if len(peak_idx) < 1:
raise PromptNotFoundError() raise PromptNotFoundError()
...@@ -1011,7 +1011,7 @@ class Model(TransformerMixin, BaseEstimator): ...@@ -1011,7 +1011,7 @@ class Model(TransformerMixin, BaseEstimator):
M = self.wiener_filter.shape[0] M = self.wiener_filter.shape[0]
B = expected.shape[0] B = expected.shape[0]
assert expected.shape[1] == M assert expected.shape[1] == M
deconvolved = convolve(expected, deconvolved = fftconvolve(expected,
np.broadcast_to(self.wiener_filter.reshape(1, -1), (B, M)), np.broadcast_to(self.wiener_filter.reshape(1, -1), (B, M)),
mode="same", mode="same",
axes=1) axes=1)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment