From 7ef1e48c5a5cd77580d3edf29b05281ebd29a853 Mon Sep 17 00:00:00 2001 From: Danilo Ferreira de Lima <danilo.enoque.ferreira.de.lima@xfel.de> Date: Thu, 5 Oct 2023 19:09:39 +0200 Subject: [PATCH] Fixed axis for fft. --- pes_to_spec/__init__.py | 2 +- pes_to_spec/model.py | 8 ++++---- pes_to_spec/test/prepare_plots.py | 7 ++++--- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/pes_to_spec/__init__.py b/pes_to_spec/__init__.py index a564b2c..5f0058f 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.3.1" +VERSION = "0.3.2" diff --git a/pes_to_spec/model.py b/pes_to_spec/model.py index 3eb39f4..57cf076 100644 --- a/pes_to_spec/model.py +++ b/pes_to_spec/model.py @@ -53,14 +53,14 @@ def deconv(y: np.ndarray, yhat: np.ndarray) -> Tuple[np.ndarray, np.ndarray, np. calculate the deconvolution between them. """ # subtract the mean spectra to remove the FEL bandwidth - yhat_s = yhat - np.mean(yhat, keepdims=True, axis=(0, 1)) - y_s = y - np.mean(y, keepdims=True, axis=(0, 1)) + yhat_s = yhat - np.mean(yhat, keepdims=True, axis=0) + y_s = y - np.mean(y, keepdims=True, axis=0) # Fourier transforms Yhat = np.fft.fft(yhat_s) Y = np.fft.fft(y_s) # spectral power of the assumed "true" signal (the grating spectrometer data) - Syy = np.mean(np.absolute(Y)**2, axis=(0, 1)) - Syh = np.mean(Y*np.conj(Yhat), axis=(0, 1)) + Syy = np.mean(np.absolute(Y)**2, axis=0) + Syh = np.mean(Y*np.conj(Yhat), axis=0) # approximate transfer function as the ratio of power spectrum densities H = Syh/Syy return np.fft.fftshift(np.fft.ifft(H)), H, Syy diff --git a/pes_to_spec/test/prepare_plots.py b/pes_to_spec/test/prepare_plots.py index caa569f..31ada1d 100755 --- a/pes_to_spec/test/prepare_plots.py +++ b/pes_to_spec/test/prepare_plots.py @@ -469,9 +469,10 @@ def plot_pes(df: pd.DataFrame, #cax[ch].xaxis.label.set_color(col[ch]) #cax[ch].title.set_color(col[ch]) if not tof: - locator = matplotlib.ticker.MultipleLocator(2) - locator.view_limits(1000, 1010) - cax[ch].xaxis.set_major_locator(locator) + #locator = matplotlib.ticker.MultipleLocator(2) + #locator.view_limits(1000, 1010) + #cax[ch].xaxis.set_major_locator(locator) + cax[ch].set_xticks(np.arange(998, 1010, 2)) ax.legend(frameon=False, loc='center') plt.tight_layout() fig.savefig(filename) -- GitLab