cait.filter
- cait.filter.box_car_smoothing(event, length=50)[source]
Calculates a moving average on an event array and returns the smoothed event
- Parameters
event – 1D array, the event to calculate the MA
length – the length of the moving average
- Returns
1D array the smoothed array
- cait.filter.extend_filter(filt, extend_to, sampling_frequency)[source]
Extend a filter to a given length.
- Parameters
nps (1D np.array) – The filter.
extend_to (int) – The desired length of the filter.
sampling_frequency (int) – The sampling frequency.
- Returns
List of the frequencies of the extended filter and the extended filter.
- Return type
list
- cait.filter.extend_nps(nps, extend_to, sampling_frequency)[source]
Extend a noise power spectrum to a given length.
- Parameters
nps (1D np.array) – The noise power spectrum.
extend_to (int) – The desired length of the noise record window.
sampling_frequency (int) – The sampling frequency.
- Returns
List of the frequencies of the extended NPS and the extended NPS.
- Return type
list
- cait.filter.filter_event(event, transfer_function, window=False)[source]
this function filters a single event
- Parameters
event – 1D array of the one event that should be filtered, size N
transfer_function – the filter in fourier space, size N/2 +1 complex numpy array
window – bool, if activated the array is multiplied with a window function befor filtering
- Returns
1D array length N, the filtered event
- cait.filter.get_amplitudes(events_array, stdevent, nps, hard_restrict=False, down=1, window=False, peakpos=None, return_peakpos=False, flexibility=20, baseline_model='constant', pretrigger_samples=500, transfer_function=None)[source]
This function determines the amplitudes of several events with optimal sig-noise-ratio.
- Parameters
events_array – 2D array (nmbr_events, rec_length), the events to determine ph
stdevent – 1D array, the standardevent
nps – 1D array, length N/2 + 1, the noise power spectrum
hard_restrict – bool, The maximum search is restricted to 20-30% of the record window.
down – int, a factor by which the events and filter is downsampled before application
window – bool, if activated the array is multiplied with a window function befor filtering
peakpos – array of length nmbr_events, use these peak positions to do the fit
return_peakpos – bool, if true a second array is returned, namely the peak positions within the arrays
flexibility – int, in case a peak position is provided, the maximum search can still deviate by this amount of samples
baseline_model – str, which baseline model to use, either “constant”, “linear” or “exponential”
pretrigger_samples – int, the number of samples from the start of the record window to evaluate the baseline
transition_function – 2D complex float numpy array, use this transfer function instead of calculating it again from the stdevent and nps
- Returns
1D array size (nmbr_events), the phs after of filtering; if return_peakpos is true, this is instead a 2-tuple of the of_ph and the maximum positions
- cait.filter.linregfit(XX, yy)[source]
” Fit a large set of points to a linear regression.
- Parameters
XX (list of 1D numpy arrays) – List of the x values of all regressions.
yy (list of 1D numpy arrays) – List of the y values of all regressions.
- Returns
The offsets of the regressions, the scales of the regressions.
- Return type
list of 2 1D arrays
- cait.filter.normalization_constant(stdevent, nps)[source]
this function is needed as utility for the function optimal_transition_function and calculates the normalization constant s.t. the Variance of an event is preserved Remark: We do not use this function, as we want to preserve the height of a peak and not the RMS.
- Parameters
stdevent – 1D array of the standardevent with length N
nps – 1D array of the noise power spectrum with length N/2 + 1
- Returns
integer, the normalization constant
- cait.filter.optimal_transfer_function(stdevent, nps, window=True)[source]
This function calculates the transition function for an optimal filter.
- Parameters
stdevent – 1D array, pulse shape standard event with length N
nps – 1D array, the NPS of a baseline, with length N/2 + 1
window – bool, include a window function to the standard event
- Returns
1D complex numpy array of length N/2 + 1, the optimal transfer function
- cait.filter.rem_off(ev: list, baseline_model: str, pretrigger_samples: int = 500)[source]
Remove the offset of a set of events in-place, with different baseline models.
- Parameters
ev (2D numpy array) – The events.
baseline_model (str) – Which baseline model to use, either “constant”, “linear” or “exponential”.
pretrigger_samples (int) – The number of pre-trigger samples to use for the calculation of the offset.