lair.transects.robust_z#
- lair.transects.robust_z(enh, min_points=20)[source]#
Per-transit robust z-score of the enhancement.
The score is
(enh - median) / (1.4826 * MAD), with the median and MAD taken along each transit’s route points.A point is then judged against the rest of its own transit, so a night with the whole route elevated does not read as detections everywhere.
- Parameters:
enh (np.ndarray) – Enhancement matrix
enh[transit, point], as fromenhancement().min_points (int, optional) – Fewest finite points a transit needs for a score. Default 20.
- Returns:
np.ndarray – The scores, the same shape as
enh. Transits with fewer thanmin_pointsfinite points, or zero MAD, are NaN.- Return type:
See also
enhancementThe enhancement matrix.
detection_frequencyCounts the transits above a threshold at each point.
Examples
The first transit has one point far above its own median, which scores about 33; the second is the same everywhere (zero MAD), so it has no score:
>>> import numpy as np >>> from lair.transects import robust_z >>> enh = np.array([[0.0, 0.1, 0.0, 5.0, 0.1], [1.0, 1.0, 1.0, 1.0, 1.0]]) >>> robust_z(enh, min_points=3).round(2) array([[-0.67, 0. , -0.67, 33.05, 0. ], [ nan, nan, nan, nan, nan]])