kinextract.compute_losvd_n_peaks
- kinextract.compute_losvd_n_peaks(b: ndarray, min_prominence: float = 0.1) int[source]
Count topographically-prominent peaks in a LOSVD.
Counts local maxima of the LOSVD whose prominence — height above the deepest valley (“key col”) connecting the peak to any taller neighbouring peak, normalised by the global peak height — exceeds min_prominence. This correctly ignores wings and shoulders: features with only a shallow valley separating them from the main peak have low prominence and are not counted, while only genuine secondary peaks separated by a deep valley (e.g. a bimodal LOSVD produced by noise overfitting in the inner bins) exceed the threshold. Used by
_auto_select_xlam()as a unimodality constraint: candidate xlam values that produce a multi-peaked (non-unimodal) LOSVD are rejected even if their chi2 is competitive.- Parameters:
b (ndarray) – LOSVD histogram to assess (negative values are clipped to zero).
min_prominence (float, optional) – Minimum prominence, as a fraction of the global peak height, required for a local maximum to be counted as a distinct peak.
- Returns:
Number of peaks meeting the prominence threshold; always at least 1 (a LOSVD with no qualifying local maxima, or fewer than 3 samples, or a non-positive peak, is counted as having a single peak).
- Return type: