packages

signal::filter::resample

Changing the sample rate (Fourier method and decimation) and removing trends.

Enums

DetrendSource

pub enum Detrend

What detrend removes.

Functions

resampleSource

pub fn resample(x: some RealSamples, num: usize) throws (SignalError) -> Vector<f64>

x resampled to num samples by the Fourier method (as SciPy's resample): the spectrum is cut or zero-padded, splitting or joining the Nyquist bin, and transformed back. Exact for band-limited periodic signals; it treats x as one period, so an x whose ends do not meet rings at the edges (window it, or use decimate).

nabi
use core::array::Vector;

let x: Vector<f64> = [0, 1, 0, -1];
println(try signal::filter::resample(x, 8)); // [0.0, 0.7071.., 1.0, 0.7071.., 0.0, ..]

decimateSource

pub fn decimate(x: some RealSamples, q: usize, fir: bool = false) throws (SignalError) -> Vector<f64>

x low-pass filtered and kept every qth sample (as SciPy's decimate with zero phase): an order-8 Chebyshev I filter (0.05 dB ripple, cutoff 0.8 / q of Nyquist) run forward and backward, or with fir a Hamming-windowed FIR of 20 q + 1 taps. For large q decimate in stages (q up to about 13 each).

nabi
use core::array::{Array, Vector};

let x: Vector<f64> = Array::full([100], 1.0);
let y = try signal::filter::decimate(x, 4);
println(y.len()); // 25

detrendSource

pub fn detrend(x: some RealSamples, kind: Detrend = Detrend::Linear) throws (SignalError) -> Vector<f64>

x minus its mean (Detrend::Constant) or its least-squares line (Detrend::Linear, the default).

nabi
use signal::filter::{detrend, Detrend};
use core::array::Vector;

let x: Vector<f64> = [1, 2, 3, 4];
println(try detrend(x)); // [0.0, 0.0, 0.0, 0.0] (to rounding)
println(try detrend(x, Detrend::Constant)); // [-1.5, -0.5, 0.5, 1.5]