"""Per-instant dump on a window: pose, temperature, and per sensor the deviation of corr_x, corr_y, error_value from its level over a base window (median), in noises (median abs diff between consecutive measurements over base). Usage: dump.py START END BASE_START BASE_END [k] [sensors]""" import sys, statistics sys.path.insert(0, "tools/scripts") import data F = "data/CLARIDEN" start, end, b0, b1 = (data.parse_time(a) for a in sys.argv[1:5]) k = float(sys.argv[5]) if len(sys.argv) > 5 else 4 only = sys.argv[6].split(",") if len(sys.argv) > 6 else None M = data.load(F) cam = {p["t"].replace(second=0, microsecond=0): p for p in data.load_camera(F)} temp = data.load_temperature(F) lvl = {} for s, ms in M.items(): base = [m for m in ms if b0 <= m["t"] <= b1] for c in ("corr_x", "corr_y", "error_value"): v = [m[c] for m in base if m[c] is not None] if len(v) < 4: continue d = [abs(a - b) for a, b in zip(v, v[1:])] lvl[(s, c)] = (statistics.median(v), max(statistics.median(d), 1e-4)) times = sorted({m["t"] for ms in M.values() for m in ms if start <= m["t"] <= end}) for t in times: tm = t.replace(second=0, microsecond=0) p = cam.get(tm, {}) tt = [v for (u, v) in temp if abs((u - t).total_seconds()) <= 1800] out = [] for s, ms in sorted(M.items()): if only and s not in only: continue m = next((m for m in ms if m["t"] == t), None) if m is None: continue if data.rejected(m): out.append(f"{s}:REJ") continue parts = [] for c, n in (("corr_x", "x"), ("corr_y", "y"), ("error_value", "e")): if (s, c) in lvl and m[c] is not None: L, N = lvl[(s, c)] z = (m[c] - L) / N if abs(z) >= k or only: parts.append(f"{n}{z:+.0f}") if parts: out.append(s + ":" + ",".join(parts)) sc = p.get("scale") print(data.iso(t), f"T={tt[0]:.2f}" if tt else "T=-", f"sc={(sc-1)*1e5:+.1f}e-5" if sc else "sc=-", f"tl={p.get('tilt') or 0:+.4f} pn={p.get('pan') or 0:+.4f} rt={p.get('rotation') or 0:+.4f}", f"n={len(out)}", " ".join(out))