flank_run#
- pypillometry.signal.flank_run(vel, unusable, edge, direction, low, high, min_len=1, tolerance=0, sign=None, max_len=None, bridge=0, max_gap=0)[source]#
The run of fast change that touches a gap: a flank of a blink (the closing before the gap, the reopening after it) or of another transient.
Starting at the sample next to the gap (edge), the run grows away from the gap while the velocity is beyond low (hysteresis): its length comes from the data, not from a fixed window. The first tolerance samples next to the gap may be below low (the last samples before a dropout are often odd). The run stops at unusable samples.
- Parameters:
vel (np.ndarray) – velocity of the signal (per sample); before a gap the backward-, after a gap the forward-looking one
unusable (np.ndarray of bool) – samples without data (missing or masked)
edge (int) – the first sample next to the gap (the last one before it, or the first one after it)
direction (int) – -1: the flank before the gap (the run grows to earlier samples); +1: the flank after it
low (float or np.ndarray) – rates (positive; one for all samples, or one per sample): the run consists of the samples beyond low; it is a flank if at least min_len of them are beyond high. The sign of the change comes from direction: before a gap, the signal falls (velocity below
-low); after it, the signal rises (abovelow).high (float or np.ndarray) – rates (positive; one for all samples, or one per sample): the run consists of the samples beyond low; it is a flank if at least min_len of them are beyond high. The sign of the change comes from direction: before a gap, the signal falls (velocity below
-low); after it, the signal rises (abovelow).min_len (int) – number of samples beyond high that make it a flank
tolerance (int) – samples next to the gap that may be below low
sign (int, optional) – the sign of the change (-1: falling, +1: rising) if it is not the one given by direction (e.g., to extend a fall to later samples)
max_len (int, optional) – the run stops after this many samples (a safety bound)
bridge (int) – the run goes on across up to this many samples below low if it continues after them (noise in slow parts of a transient)
max_gap (int) – the run goes on across up to this many unusable samples in a row (e.g., a short dropout during the reopening) if it continues right after them; they do not count as below low or beyond high
- Return type:
- Returns:
the run (both inclusive,
first <= last) and whether it is a flank; None if there is no usable sample next to the gap (no information)