Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions wavelets/transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 13 additions & 3 deletions wavelets/wavelets.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']

Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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.
Expand Down