"""Amplitude in px, at given instants, of the deviation of corr_x / corr_y from the median of the +-3 neighbouring measurements: per instant, the targets and references above 0.02 px, sorted. Usage: amp.py T1 T2 ...""" import sys, statistics as st sys.path.insert(0, __file__.rsplit('/', 1)[0]); sys.path.insert(0, 'tools/scripts') from scan import load import data by, refs, cam = load() for a in sys.argv[1:]: t = data.parse_time(a); out = [] for s, ms in by.items(): for col in ('corr_x', 'corr_y'): pts = [(m['t'], m[col]) for m in ms if m[col] is not None] for i, (tt, v) in enumerate(pts): if tt == t: nb = [p[1] for p in pts[max(0, i-3):i] + pts[i+1:i+4]] d = v - st.median(nb) if abs(d) >= 0.02: out.append((abs(d), f"{s}{'r' if s in refs else ''}{col[-1]}{d:+.3f}")) out.sort(reverse=True) print(a, len(out), ' '.join(x for _, x in out[:16]))