Skip to content

Signal processing¤

This module holds various methods to do signal processing.

Fast timing discrimination¤

extra.signal.dled method descriptor ¤

dled(signal, threshold, ratio_max=0.6, width=0.0, interp=<EdgeInterpolation.LINEAR: 1>, edges=None, amplitudes=None)

Dynamic leading edge discriminator.

This algorithm finds the leading edge of pulses in a 1D signal located at a certain ratio to the pulse's peak value.

As with the constant fraction discriminator, it is assumed the rising pulse slope points away from zero.

This discriminator can use sinc interpolation to find the optimal edge position, please see config_ftd_interpolation for more details.

Parameters:

Name Type Description Default
signal ArrayLike

1D input array with analog signal.

required
threshold float32 or float64

Trigger threshold, positive values imply a positive pulse slope while negative values correspondingly imply a negative pulse slope.

required
ratio_max float32 or float64

Ratio of leading edge to peak value, must be in (0.0, 1.0] and is 0.6 by default.

0.6
width float32 or float64

Minimal distance between found edges, none by default.

0.0
interp int

Interpolation mode to locate the edge position, linear by default.

<EdgeInterpolation.LINEAR: 1>
edges ArrayLike

1D output array to hold the positions of found edges, a new one is allocated if None is passed.

None
amplitudes ArrayLike

1D output array to hold the pulse amplitudes corresponding to found edges, a new one is allocated if None is passed.

None

Returns:

Type Description
(ArrayLike, ArrayLike, int)

1D arrays containing the edge positions and amplitudes, number of found edges.

extra.signal.cfd method descriptor ¤

cfd(signal, threshold, delay, width=0.0, fraction=1.0, walk=0.0, interp=<EdgeInterpolation.LINEAR: 1>, edges=None, amplitudes=None)

Constant fraction discriminator.

The pulse shape is assumed to always grow away from zero, i.e. the rising slope of positive pulses is positive and that of negative pulses is negative. Correspondigly, a positive threshold implies the pulse to peak at its largest value while a negative threshold implies the pulse to peak at its smallest value.

This discriminator can use sinc interpolation both to find the optimal walk crossing as well as to enable real delay values. Please see config_ftd_interpolation for more details.

Note that enabling both these features at the same time makes the discrimination much more expensive, as repeated nested interpolations are necessary.

Parameters:

Name Type Description Default
signal ArrayLike

1D input array with analog signal.

required
threshold float32 or float64

Trigger threshold, positive values imply a positive pulse slope while negative values correspondingly imply a negative pulse slope.

required
delay float32 or float64

Delay between the raw and inverted signal.

required
width int

Minimal distance between found edges, none by default.

0.0
fraction float32 or float64

Fraction of the inverted signal, 1.0 by default.

1.0
walk float32 or float64

Point of intersection in the inverted signal, 0.0 by default.

0.0
interp EdgeInterpolation

Interpolation mode to locate the edge position, linear by default.

<EdgeInterpolation.LINEAR: 1>
edges ArrayLike

1D output array to hold the positions of found edges, a new one is allocated if None is passed.

None
amplitudes ArrayLike

1D output array to hold the pulse amplitudes corresponding to found edges, a new one is allocated if None is passed.

None

Returns:

Type Description
(ArrayLike, ArrayLike, int)

1D arrays containing the edge positions and amplitudes, number of found edges.

extra.signal.EdgeInterpolation ¤

Bases: enum.IntFlag

Edge interpolation methods.

The fast timing discriminators in this module can use several different interpolation methods to estimate the real edge position in between the actual samples. These differ in terms of their interpolation quality and performance requirements.

The default setting is to apply EdgeInterpolation.LINEAR, which offers good results for not-too-fast rise times at close to no cost in performance.

For particularly fast signals however, i.e. with large curvature, linear interpolation tends to bias edge positions towards the sample positions at either end. This can be improved with EdgeInterpolation.SINC, but at a significant performance hit.

If the discriminated edge positions should always fall on the most actual sample positions, EdgeInterpolation.NEAREST chooses the closest such position. Note that this offers no relevant performance advantage over linear interpolation.

Some of the interpolation methods can be configured via config_ftd_interpolation.

Attributes:

  • NEAREST

    Chose the sample position whose value is closest to the value at the true edge position, no cost in performance and will always return an integer result.

  • LINEAR

    Perform a linear interpolation between the two bordering samples to find the position.

  • SINC

    Perform sinc interpolation on a region of the signal around the edge position to find the position, please see sinc_interpolate for more details.

extra.signal.config_ftd_interpolation method descriptor ¤

config_ftd_interpolation(sinc_window=None, sinc_search_iterations=None)

Configure fast timing discriminator interpolation.

Some of the interpolation methods used as part of fast timing discrimination in this module may be configured in terms of performance or precision:

  • sinc_window specifies the number of samples before and after the interpolation points actually used to evaluate \(x(t)\), i.e. the finite boundaries to approximate the infinite sum. By default, up to 200 samples in each direction are used.

  • sinc_search_iterations specifies the number of binary search steps taken to find the optimal edge position from interpolated values in between two samples. The maximal resolution in samples the interpolation can therefore achieve with \(N\) iterations is \(2^{-N}\).

When set, these parameters apply to all discriminator implementations and all their use of interpolation.

For more details on interpolation, please refer to EdgeInterpolation.

Parameters:

Name Type Description Default
sinc_window int

Sample window used around the interpolated point, unchanged if omitted.

None
sinc_search_iterations int

Number of iterations used in binary search for closest function argument, unchanged if omitted.

None

Returns:

Name Type Description
config dict

Mapping of current values with keys sinc_window, sinc_search_iterations.

Interpolation¤

extra.signal.sinc_interpolate method descriptor ¤

sinc_interpolate(y_sampled, x_interp, y_interp=None, window=100)

Perform sinc interpolation.

As a consequence of the Nyquist theorem, sinc interpolation allows to reconstruct a continuous-time function \(x(t)\) up to a certain bandwidth \(1/T\) from a sequence of real numbers \(x[n]\):

\[ x(t) = \sum \limits_n x[n] ~ {\rm sinc} \frac {t - n T}{T} \]

This can be used to find the optimal edge position between samples with the fast timing discriminators in this module. In particular for fast slopes consisting of only a few sample points, this will generally yield significantly better results than linear interpolation, which tends to shift points towards the middle. For the constant fraction discriminator specifically, this can also be used to enable the use of real delay values.

Parameters:

Name Type Description Default
y_sampled ArrayLike

Sampled input data.

required
x_interp ArrayLike

Real index positions to interpolate at.

required
y_interp ArrayLike

Output array for interpolated result, a new one is allocated.

None
window int

Number of samples before and after the interpolation points actually used to evaluate \(x(t)\), i.e. the finite boundaries to approximate the infinite sum. By default, up to 100 samples in each direction are used.

100

Returns:

Name Type Description
y_interp ndarray

Interpolated output data.