# Print, around an instant, what visibility.py point 2 sees: high sensors (n), sensors rejected at FACTOR x their median, rejected sensors. # Usage: python3 brief_debug.py import statistics import sys sys.path.insert(0, sys.argv[1] + "/scripts") import data # noqa: E402 import visibility as V # noqa: E402 ms = data.load(sys.argv[2]) a, b = data.parse_time(sys.argv[3]), data.parse_time(sys.argv[4]) refs = {s for s, v in ms.items() if v[0]["pattern_type"] == "global_ref"} rows = {} for s, v in ms.items(): e = [m["error_value"] for m in v if m["error_value"] is not None] if len(e) < 10: continue med = statistics.median(e) mad = statistics.median(abs(x - med) for x in e) or 1e-9 for m in v: x = m["error_value"] if x is None or not a <= m["t"] <= b: continue rej = m["error_threshold"] and x > m["error_threshold"] r = rows.setdefault(m["t"], {"high": [], "strong": [], "rej": []}) if x > med + V.K_MAD * mad and (x > V.FACTOR * med or rej and x > V.REJECT_FACTOR * med): r["high"].append(s) if rej: r["rej"].append(s) if x > V.FACTOR * med: r["strong"].append(s + ("(R)" if s in refs else "")) for t in sorted(rows): r = rows[t] print(f"{t:%H:%M} high={sorted(r['high'])} strong={sorted(r['strong'])} rejected={len(r['rej'])}")