# Prints, per hour, the median over sensors of the error_value agitation ratio (median |delta error_value| over its calm), the variant tried for the heat-shimmer gate. Args: import sys, statistics from datetime import datetime, timezone, timedelta sys.path[:0] = ["/home/maxime/aimsight-detectors/scripts", "/home/maxime/aimsight-tools/scripts"] from data import load import visibility as v day = lambda d: datetime.strptime(d, "%Y-%m-%d").replace(tzinfo=timezone.utc) a, b = day(sys.argv[2]), day(sys.argv[3]) ms = {s: k for s, x in load(sys.argv[1]).items() if (k := [m for m in x if a - timedelta(days=3) <= m["t"] < b])} hours = {} for s, x in ms.items(): e = [m for m in x if m["error_value"] is not None] r = v._ratios([(q["t"], abs(q["error_value"] - p["error_value"])) for p, q in zip(e, e[1:])]) for h, val in r.items(): hours.setdefault(h, []).append(val) for h, r in sorted(hours.items()): if h >= a: print(h.strftime("%m-%d %H"), f"errag={statistics.median(r):.2f}")