find_peaks_cwt has undocumented behavior when window_size is None and wavelet is ricker
See original GitHub issueFrom the documentation for find_peaks_cwt (window_size):
Size of window to use to calculate noise floor. Default is cwt.shape[1] / 20.
However, when window_size is None and wavelet = ricker (default for find_peaks_cwt) this will also trigger special case handing in scipy.signal.wavelets.cwt:
if wavelet == ricker and window_size is None:
ceil = np.ceil(N)
if ceil != N:
N = int(N)
which affects the output with my supplied input: input.txt. So, in the end the result from find_peaks_cwt differs between when window_size is None and cwt.shape[1] / 20.
Reproducing code example:
>>> import json
>>> import numpy as np
>>> from scipy import signal
>>> vector = np.array(json.load(open('input.txt'))) # Attached file
>>> widths = np.linspace(1, 265)
>>> signal.find_peaks_cwt(vector, widths)
array([ 22, 436, 868, 1299, 1732, 2164, 2596, 3028, 3459, 3892, 4324, 4756, 5189, 5620, 6052, 6484, 6916, 7349, 7780, 8212, 8625])
# window_size gets computed in _filter_ridge_lines to 433
>>> window_size = int(np.ceil(len(vector) / 20))
# Now, I supply this computed window_size:
>>> signal.find_peaks_cwt(vector, widths, window_size=window_size)
array([ 23, 436, 868, 1300, 1732, 2164, 2596, 3028, 3460, 3892, 4325, 4757, 5189, 5621, 6053, 6485, 6917, 7349, 7781, 8213, 8626])
Scipy/Numpy/Python version information:
1.5.2 1.17.5 sys.version_info(major=3, minor=8, micro=5, releaselevel='final', serial=0)
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (5 by maintainers)
Top Results From Across the Web
scipy.signal.find_peaks_cwt — SciPy v1.9.3 Manual
Find peaks in a 1-D array with wavelet transformation. The general approach is to smooth vector by convolving it with wavelet(width) for each...
Read more >FindPeaksCWT — Peak finding with continuous wavelet ...
Should be normalized to unit area. Default: None (ricker wavelet). max_distances, (ndarray, optional) At each row, a ridge line is only connected if...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Today I am exceptionally stupid. Happened a few times with other PRs too. Sorry for that. I’ll fill the bathtub with coffee.
For the
1.6.0release, I believe we may be dropping that NumPy version range, so just deleting the shim might be ok.