# Prints, around given instants, each target's corr_x/corr_y jump from the median of the 4 previous measurements, in noises (median step) of the series. # Usage: python3 jumps.py [ ...] import statistics import sys from pathlib import Path sys.path.insert(0, str(Path.home() / "aimsight-tools" / "scripts")) from data import is_reference, load, parse_time # noqa: E402 ms = load(sys.argv[1]) for when in sys.argv[2:]: t0 = parse_time(when) print(when) for s, rows in sorted(ms.items()): if is_reference(rows): continue line = [] for col in ("corr_x", "corr_y"): kept = [m for m in rows if m[col] is not None] v = [m[col] for m in kept] n = statistics.median(abs(b - a) for a, b in zip(v, v[1:])) i = next((k for k, m in enumerate(kept) if abs((m["t"] - t0).total_seconds()) < 420), None) if i is None or i < 4: line.append(f"{col}: -") continue base = statistics.median(v[i - 4:i]) line.append(f"{col}: {(v[i] - base) / n:+6.1f}n") print(f" {s:10} " + " ".join(line))