# Prints, for some sensors of a station over [FROM, TO), each error_value with its MAD score and whether visibility.py counts it high (K_MAD and FACTOR). Args: SENSOR... import sys from datetime import datetime sys.path[:0] = ["/home/maxime/aimsight-detectors/scripts", "/home/maxime/aimsight-tools/scripts"] from data import load # noqa: E402 from episodes import level # noqa: E402 import visibility as v # noqa: E402 folder, a, b, *sensors = sys.argv[1:] a, b = (datetime.fromisoformat(x.replace("Z", "+00:00")) for x in (a, b)) ms = load(folder) for s in sensors: e = [m["error_value"] for m in ms[s] if m["error_value"] is not None] med, mad = level(e) print(s, f"median {med:.3g} MAD {mad:.3g} threshold {ms[s][0]['error_threshold']}") for m in ms[s]: if a <= m["t"] < b and m["error_value"] is not None: x = m["error_value"] high = x > med + v.K_MAD * mad and x > v.FACTOR * med print(" ", m["t"].strftime("%m-%d %H:%M"), f"{x:.3g}", f"{(x - med) / mad:5.1f} MAD", "HIGH" if high else "")