goldsluice.reference.subtract_line

Python mirror of src/subtract_line.rs: a trace minus the straight line fitted to its pretrigger samples (a transform: it returns a trace).

For one trace x of n samples, with the window i = glitch_samples .. fit_end_samples - 1:

  • the line y = a + b * i (i the sample index, 0 to n - 1) is the least-squares fit to x[i] over the window: b is sum((i - ib) * (x[i] - xb)) / sum((i - ib)^2) with ib, xb the means of the index and of the samples over the window, and a is such that the line passes through (ib, xb) (centring the index keeps the fit accurate for traces that sit far from zero);

  • the result is x[i] - (a + b * i) for every sample i of the trace (the glitch and everything after the window included).

This is the “pretrigger line” baseline: a line, not a constant, so a slow drift of the baseline is removed too. fit_end_samples is the first sample not in the window; a window that stops a little before the pulse starts (the exploration code stops 94 samples before the end of the pretrigger window) keeps the start of the pulse out of the fit. Both parameters are the readout’s and have no default. The fit is in the units of the trace (ADC counts).

This file is written in the kernel subset (see PORTING.md) so that it can be ported to Rust line by line; the sums run front to back. kernel returns a list of n floats, not a tuple of numbers (KIND = "trace").

Functions

bad_cases()

Inputs both versions must refuse, with the same message: [(traces, params), ...].

cases()

The standard inputs the parity test runs both versions on: [(traces, params), ...].

kernel(trace, glitch_samples, fit_end_samples)

problem(n_samples, glitch_samples, ...)

Why the parameters do not fit a trace of n_samples, or None if they do.

goldsluice.reference.subtract_line.problem(n_samples, glitch_samples, fit_end_samples)[source]

Why the parameters do not fit a trace of n_samples, or None if they do.

goldsluice.reference.subtract_line.kernel(trace, glitch_samples, fit_end_samples)[source]
goldsluice.reference.subtract_line.cases()[source]

The standard inputs the parity test runs both versions on: [(traces, params), ...].

goldsluice.reference.subtract_line.bad_cases()[source]

Inputs both versions must refuse, with the same message: [(traces, params), ...].