From 209b24a2d0ef60aaad93b104bb58c2c2813b6758 Mon Sep 17 00:00:00 2001 From: Joscha Schmiedt Date: Mon, 27 May 2019 10:20:43 +0200 Subject: [PATCH 1/2] Changed import of factorial for SciPy>1.0 The alias scipy.misc.factorial is deprecated sicne scipy 1.0. Instead, scipy.special.factorial should be used. --- wavelets/wavelets.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wavelets/wavelets.py b/wavelets/wavelets.py index 26c8134..7645ca5 100644 --- a/wavelets/wavelets.py +++ b/wavelets/wavelets.py @@ -5,7 +5,7 @@ import scipy.signal import scipy.optimize import scipy.special -from scipy.misc import factorial +from scipy.special import factorial __all__ = ['Morlet', 'Paul', 'DOG', 'Ricker', 'Marr', 'Mexican_hat'] From 4ec955838e0c3f070da901f96e3b14e6b2186e09 Mon Sep 17 00:00:00 2001 From: Stefan Fuertinger Date: Tue, 14 Jul 2020 17:08:37 +0200 Subject: [PATCH 2/2] NEW: Added scale conversion functionality for Paul + DOG wavelets - included missing `scale_from_period` class methods in `Paul` and `DOG` wavelet classes - fixed indexing in transform.py: `cwt_time` used a list of slices to index a 2D array. In future versions of NumPy this will trigger at best an `IndexError`, at worst NumPy might try to silently interpret the list as array index which will yield the wrong result. Changes to be committed: modified: wavelets/transform.py modified: wavelets/wavelets.py --- wavelets/transform.py | 1 + wavelets/wavelets.py | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/wavelets/transform.py b/wavelets/transform.py index aef2131..2605593 100644 --- a/wavelets/transform.py +++ b/wavelets/transform.py @@ -92,6 +92,7 @@ def cwt_time(data, wavelet, widths, dt, axis): # compute in time slices = [None for _ in data.shape] slices[axis] = slice(None) + slices = tuple(slices) for ind, width in enumerate(widths): # number of points needed to capture wavelet M = 10 * width / dt diff --git a/wavelets/wavelets.py b/wavelets/wavelets.py index 7645ca5..b741db2 100644 --- a/wavelets/wavelets.py +++ b/wavelets/wavelets.py @@ -186,7 +186,12 @@ def fourier_period(self, s): return 4 * np.pi * s / (2 * self.m + 1) def scale_from_period(self, period): - raise NotImplementedError() + """ + Compute the scale from the fourier period. + Returns the scale + """ + # Solve 4 * np.pi * scale / (2 * m + 1) for s + return period * (2 * self.m + 1) / (4 * np.pi) # Frequency representation def frequency(self, w, s=1.0): @@ -313,7 +318,12 @@ def fourier_period(self, s): return 2 * np.pi * s / (self.m + 0.5) ** .5 def scale_from_period(self, period): - raise NotImplementedError() + """ + Compute the scale from the fourier period. + Returns the scale + """ + # Solve 2 * np.pi * s / (np.sqrt(m + 1/2)) for s + return period * np.sqrt(self.m + 0.5) / (2 * np.pi) def frequency(self, w, s=1.0): """Frequency representation of derivative of Gaussian.