32 lines
1.6 KiB
Python
32 lines
1.6 KiB
Python
"""Run ranges.py --k 5 on each label of requalify_input.jsonl; report the max |deviation| in noises per target (refs excluded)."""
|
|||
|
|
import json, subprocess, sys, re
|
||
|
|
D = sys.argv[1]
|
||
|
|
out = {}
|
||
|
|
for line in open(f"{D}/work/requalify_input.jsonl"):
|
||
|
|
L = json.loads(line)
|
||
|
|
fam = L["family"]
|
||
|
|
if fam == "No data":
|
||
|
|
continue
|
||
|
|
modes = [("plain", [])]
|
||
|
|
if fam != "Thermal displacement":
|
||
|
|
modes.append(("rolling4", ["--rolling", "4"]))
|
||
|
|
for name, extra in modes:
|
||
|
|
cmd = ["python3", "tools/scripts/ranges.py", "data/JUNGFRAU", "--columns", "corr_x,corr_y", "--k", "5",
|
||
|
|
"--start", L["start"], "--end", L["end"]] + extra
|
||
|
|
txt = subprocess.run(cmd, capture_output=True, text=True).stdout
|
||
|
|
open(f"{D}/work/rq/{L['id']}_{name}.txt", "w").write(" ".join(cmd) + "\n" + txt)
|
||
|
|
best = {}
|
||
|
|
col = None
|
||
|
|
for l in txt.splitlines():
|
||
|
|
m = re.match(r"(corr_[xy]): ranges", l)
|
||
|
|
if m: col = m.group(1); continue
|
||
|
|
if l.startswith("=="): col = None; continue
|
||
|
|
if col:
|
||
|
|
p = l.split()
|
||
|
|
if len(p) >= 8 and re.match(r"\d{4}-", p[1]) and not p[0].startswith("REF"):
|
||
|
|
try: z = float(p[5])
|
||
|
|
except ValueError: continue
|
||
|
|
k = (p[0], col)
|
||
|
|
if abs(z) > abs(best.get(k, (0,))[0]): best[k] = (z, p[6], int(p[3]))
|
||
|
|
top = sorted(best.items(), key=lambda kv: -abs(kv[1][0]))[:4]
|
||
|
|
print(L["id"], L["start"], L["end"], fam[:10], name, "|", "; ".join(f"{s} {c[-1]} {z:+.1f} @{t[11:16]} n={n}" for (s, c), (z, t, n) in top) or "none")
|