Algorithms | latest | counts
Counts
Counts (also known as ring down counts) are the number of positive threshold crossings of a burst signal.
Parameters
Name | Description | Unit | Limits |
---|---|---|---|
threshold | Threshold amplitude | Same unit as signal | (0, |
References
Code
INFO
The following snippet is written in a generic and unoptimized manner. The code aims to be comprehensible to programmers familiar with various programming languages and may not represent the most efficient or idiomatic Python practices. Please refer to implementations for optimized implementations in different programming languages.
py
import numpy as np
def counts(signal: np.ndarray, threshold: float) -> int:
if len(signal) == 0:
return 0
result = 0
was_above_threshold = signal[0] >= threshold
for value in signal[1:]:
is_above_threshold = value >= threshold
if not was_above_threshold and is_above_threshold:
result += 1
was_above_threshold = is_above_threshold
return result