spcal.detection¶
Functions for detecting and classifying particles.
- spcal.detection.accumulate_detections(y: ndarray, limit_accumulation: float | ndarray, limit_detection: float | ndarray, points_required: int = 1, prominence_required: float = 0.2, integrate: bool = False) tuple[ndarray, ndarray]¶
Returns an array of accumulated detections.
Peak prominence is calculated for all points above the
limit_detection, with widths bound by thelimit_accumulation. Detections are peaks with at leastpoints_requiredpoints above thelimit_detection. Peaks with overlapping prominences with at leastprominence_requiredof the maxium height will be split.- Parameters:
y – array
limit_accumulation – minimum accumulation value(s)
limit_detection – minimum detection value(s)
points_required – no. points > limit_detection to be detected
prominence_required – minimum fraction of max prominence for overlapping peaks
integrate – integrate, otherwise sum
- Returns:
summed detection regions regions [starts, ends]
- spcal.detection.background_mask(regions: ndarray, size: int) ndarray¶
Create a mask to select background data using
regions.- Parameters:
regions – regions from
accumulate_detectionssize – size of underlying array, e.g. signals
- Returns:
mask of signal background
- spcal.detection.combine_regions(regions: list[ndarray], overlap: int) ndarray¶
Combine regions with an optional allowed overlap.
Regions in
regionsthat overlap by more thanoverlapare merged.- Parameters:
regions – list of regions from
accumulate_detectionsoverlap – maximum allowed overlap
- Returns:
merged regions
- spcal.detection.detection_maxima(y: ndarray, regions: ndarray) ndarray¶
Calculates the maxima of each region.
Does not work with overlapping regions.
- Parameters:
y – array
regions – regions from
accumulate_detections
- Returns:
idx of maxima