Files
Support-Agent/labeling/auto/etiqueteur/NORDEND_2026-08-10/outils/capteur.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

34 lines
2.0 KiB
Python

"""Table au pas natif d'un capteur : error_value, corr_x, corr_y (écart à la médiane de la nuit 20-03 précédente, en bruits), R = rejetée.
Usage (depuis la racine) : python3 labeling/auto/etiqueteur/NORDEND_2026-08-10/outils/capteur.py CAPTEUR DEBUT FIN (DEBUT/FIN : AAAA-MM-JJTHH:MM)
"""
import csv, glob, statistics as st, sys
from datetime import datetime, timedelta, timezone
cap, deb, fin = sys.argv[1], *(datetime.fromisoformat(a).replace(tzinfo=timezone.utc) for a in sys.argv[2:4])
rows = {}
for p in sorted(glob.glob("data/NORDEND/displacement/NORDEND_advanced_202608*.csv")):
if not ("20260808" <= p[-12:-4] <= "20260816"):
continue
with open(p) as f:
for r in csv.DictReader(f):
if r["sensor_name"] == cap:
t = datetime.fromisoformat(r["time_utc"]).replace(second=0, microsecond=0)
t -= timedelta(minutes=t.minute % 15)
rej = float(r["error_value"]) > float(r["error_threshold"])
rows[t] = (float(r["error_value"]), None if rej or not r["corr_x"] else float(r["corr_x"]),
None if rej or not r["corr_y"] else float(r["corr_y"]), rej, float(r["x"]), float(r["y"]))
ts = sorted(rows)
bruit = {k: st.median(abs(rows[b][k] - rows[a][k]) for a, b in zip(ts, ts[1:]) if rows[a][k] is not None and rows[b][k] is not None) for k in (1, 2)}
t = deb
while t <= fin:
d0 = t.replace(hour=0, minute=0) - (timedelta(days=1) if t.hour < 20 else timedelta(0))
nuit = [rows[u] for u in ts if d0 + timedelta(hours=20) <= u < d0 + timedelta(hours=27)]
niv = {k: st.median(r[k] for r in nuit if r[k] is not None) for k in (1, 2)}
if t in rows:
r = rows[t]
f = lambda k: " ." if r[k] is None else f"{(r[k] - niv[k]) / bruit[k]:+7.1f}"
print(f"{t:%m-%d %H:%M} err {r[0]:.3f}{' R' if r[3] else ' '} cx {f(1)} cy {f(2)} x {r[4]:.2f} y {r[5]:.2f}")
else:
print(f"{t:%m-%d %H:%M} (pas de mesure)")
t += timedelta(minutes=15)