Skip to content
Merged
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
13 changes: 9 additions & 4 deletions pywt/_cwt.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,9 @@ def next_fast_len(n):
return 2**ceil(np.log2(n))


def cwt(data, scales, wavelet, sampling_period=1., method='conv', axis=-1):
def cwt(data, scales, wavelet, sampling_period=1., method='conv', axis=-1,
*, precision=12):
"""
cwt(data, scales, wavelet)

One dimensional Continuous Wavelet Transform.

Parameters
Expand Down Expand Up @@ -60,6 +59,12 @@ def cwt(data, scales, wavelet, sampling_period=1., method='conv', axis=-1):
axis: int, optional
Axis over which to compute the CWT. If not given, the last axis is
used.
precision: int, optional
Length of wavelet (``2 ** precision``) used to compute the CWT. Greater
will increase resolution, especially for higher scales, but will
compute a bit slower. Too low will distort coefficients and their
norms, with a zipper-like effect. The default is 12, it's recommended
to use >=12.

Returns
-------
Expand Down Expand Up @@ -116,7 +121,7 @@ def cwt(data, scales, wavelet, sampling_period=1., method='conv', axis=-1):

dt_out = dt_cplx if wavelet.complex_cwt else dt
out = np.empty((np.size(scales),) + data.shape, dtype=dt_out)
precision = 10

int_psi, x = integrate_wavelet(wavelet, precision=precision)
int_psi = np.conj(int_psi) if wavelet.complex_cwt else int_psi

Expand Down
2 changes: 1 addition & 1 deletion pywt/tests/test_matlab_compatibility_cwt.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def _load_matlab_result_psi(wavelet):

def _check_accuracy(data, w, scales, coefs, wavelet, epsilon):
# PyWavelets result
coefs_pywt, freq = pywt.cwt(data, scales, w)
coefs_pywt, freq = pywt.cwt(data, scales, w, precision=10)

# coefs from Matlab are from R2012a which is missing the complex conjugate
# as shown in Eq. 2 of Torrence and Compo. We take the complex conjugate of
Expand Down
Loading