Files
Support-Agent/labeling/auto/etiqueteur/MICHIGAN_2026-10-20/outils/table.py
T
maximeandClaude Opus 5.5 6fbd7510b7 Etiqueteur: October labels for 8 stations; its folder moves to labeling/auto/etiqueteur/, analyses and scripts versioned (D-126)
Labels for CLARIDEN, FLORIDA, JUNGFRAU (gaps 06-20.10, 26.10-01.11), LENZSPITZE,
NIEDERHORN, NORDEND, SNCF01, WILDSTRUBEL. Figures and tool outputs stay out of git.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-03 16:33:41 +01:00

33 lines
1.6 KiB
Python

"""Table par instant : médiane des cibles de corr_x, corr_y, error_value ; REFPOU22 error ; température A0 et thermal."""
import csv, glob, statistics as st, sys
from collections import defaultdict
D = "data/MICHIGAN"
deb, fin = sys.argv[1], sys.argv[2] # 'AAAA-MM-JJ HH'
rows = defaultdict(dict)
for f in sorted(glob.glob(f"{D}/displacement/*.csv")):
for r in csv.DictReader(open(f)):
t = r["time_utc"][:16]
rows[t][r["sensor_name"]] = r
temp = {}
for name in ("sensor_A0_deg_c", "sensor_thermal_deg_c"):
for f in glob.glob(f"{D}/metrics/MICHIGAN_{name}_*.csv"):
for r in csv.DictReader(open(f)):
temp[(name, r["time_utc"][:13])] = r["metric"]
print("instant cx_med cy_med ev_med ev_max(cible) POU22_ev rej A0 therm")
for t in sorted(rows):
if not (deb <= t <= fin):
continue
s = rows[t]
cib = [r for n, r in s.items() if r["pattern_type"] == "target"]
ok = [r for r in cib if r["corr_x"]]
cx = st.median(float(r["corr_x"]) for r in ok) if ok else float("nan")
cy = st.median(float(r["corr_y"]) for r in ok) if ok else float("nan")
ev = st.median(float(r["error_value"]) for r in cib)
mx = max(cib, key=lambda r: float(r["error_value"]))
p = s.get("REFPOU22")
pe = float(p["error_value"]) if p else float("nan")
rej = "R" if p and pe > float(p["error_threshold"]) else "-"
h = t[:13]
print(f"{t} {cx:6.3f} {cy:6.3f} {ev:.3f} {float(mx['error_value']):.3f} {mx['sensor_name']:10s} {pe:.3f} {rej} {temp.get(('sensor_A0_deg_c', h), ''):5s} {temp.get(('sensor_thermal_deg_c', h), '')}")