signal::peaks
Peak finding as SciPy's find_peaks: local maxima (a flat top counts
once, at its middle), then filtered by height, by distance (highest
first) and by topographic prominence.
Structs
PeaksSource
pub struct PeaksThe peaks find_peaks kept, in increasing position, with the
properties it measured.
Sample positions of the peaks.
xat each peak.How far each peak stands above the higher of its two bases.
The lowest point between each peak and the next higher sample on its left (or the start).
The same on the right.
The number of peaks.
Functions
find_peaksSource
pub fn find_peaks(x: some RealSamples, height: f64? = none, distance: usize? = none, prominence: f64? = none) throws (SignalError) -> Peaks The peaks of x: samples higher than both neighbours (a flat top
counts once, at its middle; the ends never count). Then, each only
when given: keep peaks at least height high; keep peaks at least
distance samples apart, the highest first; keep peaks with
prominence at least prominence. NaN samples are never peaks.
use core::array::Vector;
let x: Vector<f64> = [0, 2, 0, 1, 0, 3, 3, 0, 1, 0];
let p = try signal::find_peaks(x);
println(p.indices); // [1, 3, 5, 8]
let tall = try signal::find_peaks(x, height: 1.5, distance: 2);
println(tall.indices); // [1, 5]
println(tall.prominences); // [2.0, 3.0]