find_peaks_cwt(vector, widths, wavelet=None, max_distances=None, gap_thresh=None, min_length=None, min_snr=1, noise_perc=10, window_size=None)
The general approach is to smooth :None:None:`vector`
by convolving it with :None:None:`wavelet(width)`
for each width in :None:None:`widths`
. Relative maxima which appear at enough length scales, and with sufficiently high SNR, are accepted.
This approach was designed for finding sharp peaks among noisy data, however with proper parameter selection it should function well for different peak shapes.
The algorithm is as follows:
Perform a continuous wavelet transform on :None:None:`vector`
, for the supplied :None:None:`widths`
. This is a convolution of :None:None:`vector`
with :None:None:`wavelet(width)`
for each width in :None:None:`widths`
. See cwt
.
Identify "ridge lines" in the cwt matrix. These are relative maxima at each row, connected across adjacent rows. See identify_ridge_lines
Filter the ridge_lines using filter_ridge_lines.
1-D array in which to find the peaks.
Single width or 1-D array-like of widths to use for calculating the CWT matrix. In general, this range should cover the expected width of peaks of interest.
Should take two parameters and return a 1-D array to convolve with :None:None:`vector`
. The first parameter determines the number of points of the returned wavelet array, the second parameter is the scale (:None:None:`width`
) of the wavelet. Should be normalized and symmetric. Default is the ricker wavelet.
At each row, a ridge line is only connected if the relative max at row[n] is within max_distances[n]
from the relative max at row[n+1]
. Default value is widths/4
.
If a relative maximum is not found within :None:None:`max_distances`
, there will be a gap. A ridge line is discontinued if there are more than :None:None:`gap_thresh`
points without connecting a new relative maximum. Default is the first value of the widths array i.e. widths[0].
Minimum length a ridge line needs to be acceptable. Default is cwt.shape[0] / 4
, ie 1/4-th the number of widths.
Minimum SNR ratio. Default 1. The signal is the value of the cwt matrix at the shortest length scale ( cwt[0, loc]
), the noise is the :None:None:`noise_perc'th percentile of datapoints contained within a
window of 'window_size`
around cwt[0, loc]
.
When calculating the noise floor, percentile of data points examined below which to consider noise. Calculated using :None:None:`stats.scoreatpercentile`
. Default is 10.
Size of window to use to calculate noise floor. Default is cwt.shape[1] / 20
.
Indices of the locations in the :None:None:`vector`
where peaks were found. The list is sorted.
Find peaks in a 1-D array with wavelet transformation.
cwt
Continuous wavelet transform.
find_peaks
Find peaks inside a signal based on peak properties.
>>> from scipy import signalSee :
... xs = np.arange(0, np.pi, 0.05)
... data = np.sin(xs)
... peakind = signal.find_peaks_cwt(data, np.arange(1,10))
... peakind, xs[peakind], data[peakind] ([32], array([ 1.6]), array([ 0.9995736]))
The following pages refer to to this document either explicitly or contain code examples using this.
scipy.signal._peak_finding.find_peaks
scipy.signal._peak_finding.find_peaks_cwt
Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.
Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)
SVG is more flexible but power hungry; and does not scale well to 50 + nodes.
All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them