def exclude_tails(records, to_pe, min_area=int(2e5), peak_duration=int(1e4), tail_duration=int(1e7), gap_threshold=300): """Return records that do not lie fully in tail after a big peak""" # Find peaks using the records as "hits". This is rough, but good enough. cut = find_peaks(records, to_pe, gap_threshold=gap_threshold, min_area=min_area, result_dtype=peak_dtype(records['channel'].max() + 1), max_duration=peak_duration) # Transform these 'peaks' to ranges to cut. # We want to cut tails after peaks, not the peaks themselves. cut['time'] += peak_duration # Don't cut the actual peak cut['length'] = tail_duration / cut['dt'] return records[fully_contained_in(records, cut) == -1]
import numpy as np import numba from strax import utils from strax.dtypes import peak_dtype, DIGITAL_SUM_WAVEFORM_CHANNEL __all__ = 'find_peaks sum_waveform'.split() @utils.growing_result(dtype=peak_dtype(), chunk_size=int(1e4)) @numba.jit(nopython=True, nogil=True, cache=True) def find_peaks(hits, to_pe, gap_threshold=300, left_extension=20, right_extension=150, min_hits=3, min_area=0, max_duration=int(1e9), _result_buffer=None, result_dtype=None): """Return peaks made from grouping hits together Assumes all hits have the same dt :param hits: Hit (or any interval) to group :param left_extension: Extend peaks by this many ns left :param right_extension: Extend peaks by this many ns right :param gap_threshold: No hits for this much ns means new peak :param min_hits: Peaks with less than min_hits are not returned :param min_area: Peaks with less than min_area are not returned :param max_duration: Peaks are forcefully ended after this many ns """