cubie.outputhandling.summarymetrics.peaks

Peak detection summary metric for CUDA-accelerated batch integration.

This module implements a summary metric that detects and records the timing of local maxima (peaks) in variable values during integration.

Classes

Peaks()

Summary metric to detect and record peak locations in a variable.

class cubie.outputhandling.summarymetrics.peaks.Peaks[source]

Bases: SummaryMetric

Summary metric to detect and record peak locations in a variable.

This metric identifies local maxima by tracking when a value is greater than both its predecessor and successor values. It records the time indices where peaks occur, up to a configurable maximum number.

Notes

The metric uses a parameterized buffer size that depends on the maximum number of peaks to detect. The buffer stores: previous value, previous-previous value, peak counter, and the time indices of detected peaks.

The peak detection algorithm requires at least 2 previous values and assumes no natural 0.0 values in the data (uses 0.0 as initialization marker).

CUDA_factory()[source]

Generate CUDA device functions for peak detection.

Creates optimized CUDA device functions with fixed signatures for detecting peaks during integration and saving peak time indices.

Returns:

Tuple containing (update_function, save_function) for CUDA execution.

Return type:

tuple[callable, callable]

Notes

The generated functions have the following signatures:

update(value, buffer, current_index, customisable_variable):

Detects peaks by comparing current value with previous values.

save(buffer, output_array, summarise_every, customisable_variable):

Saves detected peak time indices to output and resets buffer.

__init__()[source]

Initialize the Peaks summary metric.

Creates CUDA device functions for peak detection and result saving, and configures the metric with parameterized buffer and output sizes based on the maximum number of peaks to detect.

buffer_size: int | Callable
input_variable: dict[str, int] | None
name: str
output_size: int | Callable
save_device_func: Callable
update_device_func: Callable