API

Modules

    Types and constants

    Functions and macros

    Documentation

    RadiationDetectorDSP.AbstractRadSigFilterType
    abstract type AbstractRadSigFilter{FT<:FilteringType} <: Function

    Abstract type for signal filters.

    Filters are callable as (flt::AbstractRadSigFilter)(input) and come with specialized broadcasting.

    Subtypes of AbstractRadSigFilter must implement

    fltinstance(flt::AbstractRadSigFilter, si::SamplingInfo)::[`AbstractRadSigFilterInstance`](@ref)

    Invertible filters should also implement

    • InverseFunctions.inverse(flt::SomeFilter)

    Note that while a filter may have an inverse, it may, depending on the filter paramters, be very unstable in the presence of additional noise. Filters with a high-pass characteristic pass high-frequency noise, so their inverses pass such noise as well without amplifying it (substantially). Filters with a low-pass characteristic, on the other hand, attentuate high-frequency noise, so their inverses amplify such noise and are typically not useful to deconvolve signals in practical applications.

    source
    RadiationDetectorDSP.AbstractRadSigFilterInstanceType
    abstract type AbstractRadSigFilterInstance{FT<:FilteringType}

    Abstract type for signal filter instances. Filter instances are specilized to a specific length and numerical type of input and output.

    Filter instances are callable as (fi::SomeFilterInstance)(input) and come with specialized broadcasting.

    Subtypes of AbstractRadSigFilterInstance must implement

    • RadiationDetectorDSP.rdfilt!(output, fi::SomeFilterInstance, input)

    • RadiationDetectorDSP.flt_output_smpltype(fi::SomeFilterInstance)

    • RadiationDetectorDSP.flt_input_smpltype(fi::SomeFilterInstance)

    • RadiationDetectorDSP.flt_output_length(fi::SomeFilterInstance)

    • RadiationDetectorDSP.flt_input_length(fi::SomeFilterInstance)

    • RadiationDetectorDSP.flt_output_time_axis(fi::SomeFilterInstance, time::AbstractVector{<:RealQuantity})

    Invertible filter instances should implement

    • InverseFunctions.inverse(fi::SomeFilterInstance)

    Default methods are implemented for

    • RadiationDetectorDSP.rdfilt(fi::AbstractRadSigFilterInstance, x::AbstractSamples)
    • RadiationDetectorDSP.rdfilt(fi::AbstractRadSigFilterInstance, wf::RDWaveform)
    • RadiationDetectorDSP.bc_rdfilt(fi::AbstractRadSigFilterInstance, inputs)

    The default methods that operate on RadiationDetectorSignals.RDWaveforms require RadiationDetectorDSP.flt_output_time_axis.

    source
    RadiationDetectorDSP.BiquadFilterType
    struct BiquadFilter{T<:RealQuantity} <: AbstractRadIIRFilter

    A biquad filter.

    Constructors:

    • BiquadFilter(fields...)

    Fields:

    • b_012::Tuple{T, T, T} where T<:Union{Real, Unitful.AbstractQuantity{<:Real}}: Coefficients b0 to b2

    • a_12::Tuple{T, T} where T<:Union{Real, Unitful.AbstractQuantity{<:Real}}: Coefficients a1 to a2, a_0 equals one implicitly

    source
    RadiationDetectorDSP.CPUNormAdaptorType
    RadiationDetectorDSP.CPUNormAdaptor

    To be used with Adapt.adapt.

    Adapt.adapt(RadiationDetectorDSP.CPUNormAdaptor, x) adapts x to reside on the CPU and tries to ensure that arrays are stored in column-major order.

    source
    RadiationDetectorDSP.CRFilterType
    struct CRFilter <: AbstractRadIIRFilter

    A first-order CR highpass filter.

    The inverse filter is InvCRFilter, this is typically stable even in the presence of additional noise. This is because a CR filter passes high-frequency noise and so it's inverse passes such noise as well without amplifying it.

    Constructors:

    • CRFilter(fields...)

    Fields:

    • cr::Union{Real, Unitful.AbstractQuantity{<:Real}}: CR time constant
    source
    RadiationDetectorDSP.CUSPChargeFilterType
    struct CUSPChargeFilter <: AbstractRadFIRFilter

    CUSP filter.

    For the definition the filter and a discussion of the filter properties, see

    Constructors:

    • CUSPChargeFilter(; fields...)

    Fields:

    • sigma::Union{Real, Unitful.AbstractQuantity{<:Real}}: equivalent of shaping time (τₛ) Default: 450

    • toplen::Union{Real, Unitful.AbstractQuantity{<:Real}}: length of flat top (FT) Default: 10

    • tau::Union{Real, Unitful.AbstractQuantity{<:Real}}: decay constant of the exponential Default: 20

    • length::Union{Real, Unitful.AbstractQuantity{<:Real}}: total length of the filter (L) Default: 100

    • beta::AbstractFloat: scaling factor Default: 100.0

    source
    RadiationDetectorDSP.ConvolutionFilterType
    struct ConvolutionFilter{T<:RealQuantity} <: AbstractRadFIRFilter

    A FIR filter defined by it's filter taps, applied via convolution with the input signal.

    Constructors:

    • ConvolutionFilter(fields...)

    Fields:

    • method::RadiationDetectorDSP.ConvolutionMethod: Convolution method

    • coeffs::AbstractVector{T} where T<:Union{Real, Unitful.AbstractQuantity{<:Real}}: Filter taps

    • offset::Int64: Time axis offset

    source
    RadiationDetectorDSP.FirstOrderIIRType
    struct FirstOrderIIR{T<:RealQuantity} <: AbstractRadIIRFilter

    A biquad filter.

    Constructors:

    • FirstOrderIIR(fields...)

    Fields:

    • b_01::Tuple{T, T} where T<:Union{Real, Unitful.AbstractQuantity{<:Real}}: Coefficients b0 to b1

    • a_1::Tuple{T} where T<:Union{Real, Unitful.AbstractQuantity{<:Real}}: Coefficient a1, a0 equals one implicitly

    source
    RadiationDetectorDSP.Gauss1DFilterType
    struct Gauss1DFilter <: AbstractRadFIRFilter

    One dimensional gaussian filter defined as: f(x) = beta * exp(-0.5*(x/sigma)^2) / length

    where x is in the interval [-alphasigma, alphasigma]

    Constructors:

    • Gauss1DFilter(; fields...)

    Fields:

    • sigma::Union{Real, Unitful.AbstractQuantity{<:Real}}: standard deviation Default: 1.0

    • length::Union{Real, Unitful.AbstractQuantity{<:Real}}: total length of the filter Default: 100.0

    • alpha::AbstractFloat: the amount of standard deviations to cover in the gaussian window Default: 3.0

    • beta::AbstractFloat: scaling factor Default: 1.0

    source
    RadiationDetectorDSP.IntegratorCRFilterType
    struct IntegratorCRFilter <: AbstractRadIIRFilter

    A modified CR-filter. The filter has an inverse.

    Constructors:

    • IntegratorCRFilter(fields...)

    Fields:

    • gain::Union{Real, Unitful.AbstractQuantity{<:Real}}: Filter gain

    • cr::Union{Real, Unitful.AbstractQuantity{<:Real}}: CR time constant

    source
    RadiationDetectorDSP.IntegratorModCRFilterType
    struct IntegratorModCRFilter <: AbstractRadIIRFilter

    A modified CR-filter. The filter has an inverse.

    Constructors:

    • IntegratorModCRFilter(fields...)

    Fields:

    • gain::Union{Real, Unitful.AbstractQuantity{<:Real}}: Filter gain

    • cr::Union{Real, Unitful.AbstractQuantity{<:Real}}: CR time constant

    source
    RadiationDetectorDSP.IntersectType
    struct Intersect <: Function

    Finds the intersects of a Y with a threshold

    Constructors:

    • Intersect(; fields...)

    Fields:

    • mintot::Union{Real, Unitful.AbstractQuantity{<:Real}}: minimum time-over-threshold
    source
    RadiationDetectorDSP.InvSecondOrderCRFilterType
    struct InvSecondOrderCRFilter <: AbstractRadIIRFilter

    Inverse of SecondOrderCRFilter. Apply a double pole-zero cancellation using the provided time constants to the waveform.

    Constructors:

    • InvSecondOrderCRFilter(fields...)

    Fields:

    • cr::Union{Real, Unitful.AbstractQuantity{<:Real}}: time constant of the first exponential to be deconvolved

    • cr2::Union{Real, Unitful.AbstractQuantity{<:Real}}: time constant of the second exponential to be deconvolved

    • f::Real: the fraction faktor which the second exponential contributes

    source
    RadiationDetectorDSP.ModCRFilterType
    struct ModCRFilter <: AbstractRadIIRFilter

    A first-order CR highpass filter, modified for full-amplitude step-signal response.

    The resonse of the standard digital CRFilter will not recover the full amplitude of a digital step stignal since a step from one sample to the still has a finite rise time. This version of a CR filter compensates for this loss in amplitude, so it effectively treats a step as having

    The inverse filter is InvModCRFilter, this is typically stable even in the presence of additional noise (see CRFilter).

    Constructors:

    • ModCRFilter(fields...)

    Fields:

    • cr::Union{Real, Unitful.AbstractQuantity{<:Real}}: CR time constant
    source
    RadiationDetectorDSP.PolynomialDNIType
    struct PolynomialDNI <: DNIMethod

    Polynomial denoising and interpolation method.

    Operates in a similar way as a Savitzky-Golay filter, but interpolates as well.

    Constructors:

    • PolynomialDNI(; fields...)

    Fields:

    • degree::Int64: polynomial degree Default: (2, "length")

    • length::Union{Real, Unitful.AbstractQuantity{<:Real}}

    source
    RadiationDetectorDSP.RCFilterType
    struct RCFilter <: AbstractRadII>RFilter

    A first-order RC lowpass filter.

    The inverse filter is InvCRFilter, but note that this is unstable in the presence of additional noise. As an RC filter attenuates high-frequency noise, its inverse amplifies such noise and will typically not be useful to deconvolve signals in practical applications.

    Constructors:

    • RCFilter(fields...)

    Fields:

    • rc::Union{Real, Unitful.AbstractQuantity{<:Real}}: RC time constant
    source
    RadiationDetectorDSP.SamplingInfoType
    struct SamplingInfo{T<:RealQuantity,A<:AbstractVector{<:RealQuantity}}

    Holds sampling information.

    The numerical type of an individual sample is T, the (time) axis is given by the axis field.

    Constructors:

    • SamplingInfo{T,A}(axis)
    • SamplingInfo{T}(axis)

    Fields:

    • axis::AbstractVector{<:Union{Real, Unitful.AbstractQuantity{<:Real}}}
    source
    RadiationDetectorDSP.SavitzkyGolayFilterType
    struct SavitzkyGolayFilter <: AbstractRadFIRFilter

    A Savitzky-Golay filter.

    Constructors:

    • SavitzkyGolayFilter(; fields...)

    Fields:

    • length::Union{Real, Unitful.AbstractQuantity{<:Real}}: filter length

    • degree::Int64: Polynomial defgree

    • derivative::Int64: n-th derivative (0 for no derivative)

    source
    RadiationDetectorDSP.SecondOrderCRFilterType
    struct SecondOrderCRFilter <: AbstractRadIIRFilter

    A scond order CR highpass filter. The filter has an inverse InvSecondOrderCRFilter.

    Constructors:

    • SecondOrderCRFilter(fields...)

    Fields:

    • cr::Union{Real, Unitful.AbstractQuantity{<:Real}}: time constant of the first exponential to be deconvolved

    • cr2::Union{Real, Unitful.AbstractQuantity{<:Real}}: time constant of the second exponential to be deconvolved

    • f::Real: the fraction faktor which the second exponential contributes

    source
    RadiationDetectorDSP.SignalEstimatorType
    struct SignalEstimator <: Function

    Estimates a signal at a given position x.

    Usage:

    (f::SamplesOrWaveform)(input::RDWaveform, x::RealQuantity)

    Constructors:

    • SignalEstimator(; fields...)

    Fields:

    • dni::DNIMethod: denoising and interpolation method
    source
    RadiationDetectorDSP.SimpleCSAFilterType
    struct SimpleCSAFilter <: AbstractRadIIRFilter

    Simulates the current-signal response of a charge-sensitive preamplifier with resistive reset, the output is a charge signal.

    It is equivalent to the composition

    CRFilter(cr = tau_decay) ∘
    Integrator(gain = gain) ∘
    RCFilter(rc = tau_rise)

    and maps to a single BiquadFilter.

    This filter has an inverse, but the inverse is very unstable in the presence of additional noise if tau_rise is not zero (since the inverse of an RC-filter is unstable under noise). Even if tau_rise is zero the inverse will still amplify noise (since it differentiates), so it should be used very carefully when deconvolving signals in practical applications.

    Constructors:

    • SimpleCSAFilter(fields...)

    Fields:

    • tau_rise::Union{Real, Unitful.AbstractQuantity{<:Real}}: Rise time constant

    • tau_decay::Union{Real, Unitful.AbstractQuantity{<:Real}}: Decay time constant

    • gain::Union{Real, Unitful.AbstractQuantity{<:Real}}: Gain

    source
    RadiationDetectorDSP.TrapezoidalChargeFilterType
    struct TrapezoidalChargeFilter <: AbstractRadNonlinearFilter

    Filter that responds to a step signal with a trapezoidal pulse.

    The filter is equivalent to two moving averages separated by a gap.

    Constructors:

    • TrapezoidalChargeFilter(; fields...)

    Fields:

    • avgtime::Union{Real, Unitful.AbstractQuantity{<:Real}}: pre-rise averaging time

    • gaptime::Union{Real, Unitful.AbstractQuantity{<:Real}}: gap time

    • avgtime2::Union{Real, Unitful.AbstractQuantity{<:Real}}: post-rise averaging time

    A sharp step on the input will result in a trapezoid with rise time and fall time avgtime and a flat top of length gaptime.

    source
    RadiationDetectorDSP.TruncateFilterType
    struct TruncateFilter <: AbstractRadSigFilter{LinearFiltering}

    Filter that truncates the input signal.

    Constructors:

    • TruncateFilter(; fields...)

    Fields:

    • interval::IntervalSets.ClosedInterval{<:Union{Real, Unitful.AbstractQuantity{<:Real}}}: interval to keep
    source
    RadiationDetectorDSP.ZACChargeFilterType
    struct ZACChargeFilter <: AbstractRadFIRFilter

    Zero area cusp (ZAC) filter.

    For the definition the filter and a discussion of the filter properties, see "Improvement of the energy resolution via an optimized digital signal processing in GERDA Phase I", Eur. Phys. J. C 75, 255 (2015).

    Constructors:

    • ZACChargeFilter(; fields...)

    Fields:

    • sigma::Union{Real, Unitful.AbstractQuantity{<:Real}}: equivalent of shaping time (τₛ) Default: 450

    • toplen::Union{Real, Unitful.AbstractQuantity{<:Real}}: length of flat top (FT) Default: 10

    • tau::Union{Real, Unitful.AbstractQuantity{<:Real}}: decay constant of the exponential Default: 20

    • length::Union{Real, Unitful.AbstractQuantity{<:Real}}: total length of the filter (L) Default: 100

    • beta::AbstractFloat: scaling factor Default: 100.0

    source
    RadiationDetectorDSP.adapt_memlayoutFunction
    RadiationDetectorDSP::adapt_memlayout(
        fi::AbstractRadSigFilterInstance,
        backend::KernelAbstractions.Backend,
        A::AbstractArray{<:Number}
    )

    Adapts the memory layout of A in a suitable fashion for fi on computing device backend.

    Returns a row-major version of A on all backends by default, filter instance types may specialize this behavior.

    source
    RadiationDetectorDSP.bc_rdfiltFunction
    bc_rdfilt(flt::AbstractRadSigFilter, input)
    bc_rdfilt(fi::AbstractRadSigFilterInstance, input)

    Broadcast filter instance fi over signals input, return the filtered signals.

    source
    RadiationDetectorDSP.bc_rdfilt!Function
    bc_rdfilt!(outputs, fi::AbstractRadSigFilterInstance, inputs)

    Broadcast filter flt or filter instance fi over signals inputs, storing the results in outputs.

    inputs and outputs must be of type AbstractVector{<:AbstractSamples}.

    Returns outputs.

    source
    RadiationDetectorDSP.charge_trapflt!Method
    charge_trapflt!(samples::AbstractVector{<:RealOrSIMD{<:AbstractFloat}}, navg::Integer, ngap::Integer)

    Apply a trapezoidal FIR filter to a charge signal in samples.

    source
    RadiationDetectorDSP.cusp_charge_filter_coeffsMethod
    cusp_charge_filter_coeffs(N::Int, sigma::U, FT::Int, tau::V, beta::W
    ) where {U, V, W <: AbstractFloat}

    return a vector representing the cusp filter applicaible on a charge signal, where N is the total length of the filter, FT the length of the flat top, sigma the filter shaping time,tau the decay constant and a the scaling factor.

    source
    RadiationDetectorDSP.dfilt!Function
    rdfilt!(output, fi::AbstractRadSigFilterInstance, input)

    Apply filter flt or filter instance fi to signal input and store the filtered signal in output. Return output.

    source
    RadiationDetectorDSP.elsmplinfoFunction
    smplinfo(smpls::AbstractSamples)::SamplingInfo
    smplinfo(wf::RDWaveform{T,U})::RDWaveform

    Get sampling information an array of vectors of samples, resp. an array of waveform. All elements must have equal samling information.

    source
    RadiationDetectorDSP.fltinstanceFunction
    fltinstance(flt::AbstractRadSigFilter, si::SamplingInfo)::AbstractRadSigFilterInstance

    Create a filter instance of the filter flt, specialized for the given input, resp. input characteristics.

    source
    RadiationDetectorDSP.gaussian_coeffsMethod
    gaussian_coeffs(N::Int, sigma::V, alpha::U, beta::U) where {V, U}

    compute a gaussian kernel, where N is the total length of the kernel, alpha the amount of standard deviations to cover, sigma the standard deviation and beta the total scaling factor.

    source
    RadiationDetectorDSP.rdfiltFunction
    rdfilt(fi::AbstractRadSigFilterInstance, input)

    Apply filter instance fi to signal input, return the filtered signal.

    Returns output.

    source
    RadiationDetectorDSP.smplinfoFunction
    smplinfo(smpls::AbstractSamples)::SamplingInfo
    smplinfo(wf::RDWaveform{T,U})::RDWaveform

    Get sampling information from a vector of samples, resp. a waveform.

    source
    RadiationDetectorDSP.zac_charge_filter_coeffsMethod
    zac_charge_filter_coeffs(
        N::Int, sigma::V, FT::Int, tau::T, beta::U
        ) where {V, T, U <: AbstractFloat}

    return a vector representing the zac filter applicaible on a charge signal, where N is the total length of the filter, FT the length of the flat top, sigma the filter shaping time, tau the decay constant and beta an additional scaling factor. (see Eur. Phys. J. C (2015) 75:255).

    source