26 lines
1.4 KiB
Python
26 lines
1.4 KiB
Python
"""Native-step extreme of the short CLARIDEN Displacement labels: per target, the largest deviation of corr_x_mm /
|
|
corr_y_mm within the label from the median of the 6 h before, in mm and in the target's own noise (median step)."""
|
|
import sys, json, statistics as st
|
|
from datetime import timedelta
|
|
sys.path.insert(0, "tools/scripts")
|
|
import data
|
|
D = data.load("data/CLARIDEN")
|
|
ids = sys.argv[1].split(",")
|
|
for l in open("labeling/auto/CLARIDEN.jsonl"):
|
|
L = json.loads(l)
|
|
if L["id"] not in ids: continue
|
|
a, b = data.parse_time(L["start"]), data.parse_time(L["end"]); rows = []
|
|
for s, ms in D.items():
|
|
if data.is_reference(ms) or s in ("P-300-B", "PR-283"): continue
|
|
for c in ("corr_x_mm", "corr_y_mm"):
|
|
v = [m[c] for m in ms if m[c] is not None and a - timedelta(days=2) <= m["t"] <= b + timedelta(days=2)]
|
|
if len(v) < 50: continue
|
|
n = st.median(abs(x - y) for x, y in zip(v, v[1:])) or 1e-9
|
|
pre = [m[c] for m in ms if m[c] is not None and a - timedelta(hours=6) <= m["t"] < a]
|
|
ins = [m[c] for m in ms if m[c] is not None and a < m["t"] < b]
|
|
if len(pre) < 6 or not ins: continue
|
|
lv = st.median(pre); d = max(ins, key=lambda x: abs(x - lv)) - lv
|
|
rows.append((abs(d) / n, s, c[5], d))
|
|
rows.sort(reverse=True)
|
|
print(L["id"], L["start"], "->", L["end"], "; ".join(f"{s} {c} {d:+.2f} mm ({k:.1f} n)" for k, s, c, d in rows[:3]))
|