goldsluice.reference.lowpass¶
Python mirror of src/lowpass.rs: a zero-phase Butterworth low-pass filter of a trace (a transform: it returns a trace).
This mirror is a *reference*, not in the kernel subset (see “When the kernel cannot be written this way” in PORTING.md): the filter
is made with the FFT, so kernel uses numpy, and the Rust kernel uses the rustfft crate. The two agree to rounding, not bit for bit,
which is why ATOL is set.
The recipe is the one of goldpan.algorithms.lowpass (the two must give the same numbers; goldsluice never imports goldpan, so it is
written out here). For one trace x of n samples, with dt = sample_period_s:
pad = min(n - 1, 3 * round(1 / (cutoff_hz * dt)) + 1), whereroundrounds half to even (Python’s ownround, as ingoldpan; Rust’sround_ties_even). A tie is realistic:1 / (cutoff_hz * dt)is 12.5 for 100 kHz and 0.8 us per sample;both ends are extended by
padsamples with odd symmetry about the end points (2 * x[0] - x[pad .. 1]in front,2 * x[n-1] - x[n-2 .. n-1-pad]behind), so that the edges do not ring, givingN = n + 2 * padsamples;the spectrum of the extended trace is multiplied by
1 / (1 + (f / cutoff_hz) ** (2 * order))(the magnitude response of a Butterworth filter, applied forwards and backwards, so there is no phase shift),fbeing the frequency of the bin;the result is the middle
nsamples of the inverse transform.
cutoff_hz (below the Nyquist frequency), order (1 or more) and sample_period_s are the filter’s and the readout’s and have no
default. kernel returns a list of n floats (KIND = "trace").
Functions
Inputs both versions must refuse, with the same message: |
|
|
The standard inputs the parity test runs both versions on: |
|
The same numbers from |
|
|
|
Why the parameters do not fit a trace of |
- goldsluice.reference.lowpass.goldpan_expected(traces, params)[source]¶
The same numbers from
goldpan’s own function (the analysis side):{output: array}.
- goldsluice.reference.lowpass.problem(n_samples, cutoff_hz, order, sample_period_s)[source]¶
Why the parameters do not fit a trace of
n_samples, orNoneif they do.