From 11657af3660fb097b5b08dec83defdf986ff275e Mon Sep 17 00:00:00 2001 From: OverLordGoldDragon <16495490+OverLordGoldDragon@users.noreply.github.com> Date: Thu, 1 Oct 2020 18:56:37 +0400 Subject: [PATCH 1/3] Allow user to set `precision`, increase default to 12 --- pywt/_cwt.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pywt/_cwt.py b/pywt/_cwt.py index a47cf9885..35abc1fd4 100644 --- a/pywt/_cwt.py +++ b/pywt/_cwt.py @@ -34,7 +34,7 @@ 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', precision=12, axis=-1): """ cwt(data, scales, wavelet) @@ -67,6 +67,11 @@ def cwt(data, scales, wavelet, sampling_period=1., method='conv', axis=-1): The ``fft`` method is ``O(N * log2(N))`` with ``N = len(scale) + len(data) - 1``. It is well suited for large size signals but slightly slower than ``conv`` on small ones. + precision: int, optional + Length of wavelet (2 ** precision) used to compute the CWT. Greater + will increase resolution, especially for lower and higher scales, + but compute a bit slower. Too low will distort coefficients + and their norms, with a zipper-like effect; recommended >= 12. axis: int, optional Axis over which to compute the CWT. If not given, the last axis is used. @@ -122,7 +127,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 From 421b134d1743a380bb247065807f6c1f53d83b67 Mon Sep 17 00:00:00 2001 From: OverLordGoldDragon <16495490+OverLordGoldDragon@users.noreply.github.com> Date: Thu, 1 Oct 2020 19:17:29 +0400 Subject: [PATCH 2/3] Edit docstring Higher `precision` doesn't help with lower scales --- pywt/_cwt.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pywt/_cwt.py b/pywt/_cwt.py index 35abc1fd4..1944d2151 100644 --- a/pywt/_cwt.py +++ b/pywt/_cwt.py @@ -69,9 +69,9 @@ def cwt(data, scales, wavelet, sampling_period=1., method='conv', precision=12, signals but slightly slower than ``conv`` on small ones. precision: int, optional Length of wavelet (2 ** precision) used to compute the CWT. Greater - will increase resolution, especially for lower and higher scales, - but compute a bit slower. Too low will distort coefficients - and their norms, with a zipper-like effect; recommended >= 12. + 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; recommended >= 12. axis: int, optional Axis over which to compute the CWT. If not given, the last axis is used. From d0fd274e278b7333652718b1264bfc63c484d3f3 Mon Sep 17 00:00:00 2001 From: OverLordGoldDragon <16495490+OverLordGoldDragon@users.noreply.github.com> Date: Mon, 5 Oct 2020 18:38:16 +0400 Subject: [PATCH 3/3] Newline to meet line length limit --- pywt/_cwt.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pywt/_cwt.py b/pywt/_cwt.py index 1944d2151..f2c1be967 100644 --- a/pywt/_cwt.py +++ b/pywt/_cwt.py @@ -34,7 +34,8 @@ def next_fast_len(n): return 2**ceil(np.log2(n)) -def cwt(data, scales, wavelet, sampling_period=1., method='conv', precision=12, axis=-1): +def cwt(data, scales, wavelet, sampling_period=1., method='conv', + precision=12, axis=-1): """ cwt(data, scales, wavelet)