flap.denoising

Denoising tools for FLAP

@author: Donat M. Takacs (takacs.donat@ek.hun-ren.hu) Centre for Energy Research

flap.denoising.remove_sharp_peaks_func(signal, time, max_width_samples, diff_limit, dt=1.0, return_peak_center_times=False, return_peak_width_samples=False, return_peak_amplitudes=False, remove_peaks=True, interpolation='linear')

Remove sharp peaks with only a few samples of duration from the data, e.g. due to neutron/gamma noise affecting APDCAM.

Peaks are detected by looking for sharp rising and falling edges in the signal, within a window of maximum max_width_samples samples. Detected peaks can be removed from the signal by interpolation.

Parameters:
signalnp.ndarray

The signal to process.

timenp.ndarray

The time coordinate of the signal.

max_width_samplesint

The maximum width of the peak in samples.

diff_limitfloat

The derivative limit for the detection of sharp rising/falling edges of peaks. Calculated in units of signal units / time units.

dtfloat, optional, default=1.0

The time difference between consecutive samples. Must be in the same time unit as used for diff_limit and time.

return_peak_center_timesbool, optional, default=False

Return the time coordinates of the center of the detected peaks.

return_peak_width_samplesbool, optional, default=False

Return the widths of the detected peaks in samples.

return_peak_amplitudesbool, optional, default=False

Return the amplitudes of the detected peaks.

remove_peaksbool, optional, default=True

Remove the detected peaks from the signal by interpolation.

interpolationstr, optional, default=’linear’

The interpolation method to use for removing peaks. Only ‘linear’ is implemented.

Returns:
processed_signalnp.ndarray

The processed signal.

num_detected_samplesint

The number of detected samples.

loc_detected_samplesnp.ndarray

The location of detected samples as a boolean index array.

peak_center_timesnp.ndarray, optional

The time coordinates of the center of the detected peaks.

peak_width_samplesnp.ndarray, optional

The widths of the detected peaks in samples.

peak_amplitudesnp.ndarray, optional

The amplitudes of the detected peaks.

Notes

A sharp peak is defined as a sequence of consecutive samples that are between two samples of maximum distance max_width_samples, where:

  • at the first sample, the derivative exceeds +diff_limit (raising edge of over_positive_difflimit)

  • at the last sample, the derivative raises above -diff_limit (falling edge of under_negative_difflimit)

The implementation uses numpy-implementated convolution for faster calculations. This has been found to be ca. 50% faster than a pure Python for-loop implementation.