Files
Support-Agent/labeling/auto/etiqueteur/NORDEND_2026-10-01/outils/avant_apres.py
T

27 lines
1.4 KiB
Python
Raw Normal View History

"""Médiane de nuit (00-05 h) de corr_x, corr_y et error_value par capteur, avant et après un instant, en bruits.
Lancer depuis la racine : python3 .../avant_apres.py A0 A1 B0 B1"""
import csv, glob, sys, statistics as st
from collections import defaultdict
D = "data/NORDEND"
a0, a1, b0, b1 = sys.argv[1:5]
v = defaultdict(lambda: defaultdict(list))
for f in sorted(glob.glob(f"{D}/displacement/NORDEND_advanced_20261*.csv")):
for r in csv.DictReader(open(f)):
t = r["time_utc"][:16].replace(" ", "T")
if not r["corr_x"] or int(t[11:13]) >= 5:
continue
k = "A" if a0 <= t <= a1 else "B" if b0 <= t <= b1 else None
if k:
s = r["sensor_name"]
v[s]["cx" + k].append(float(r["corr_x"])); v[s]["cy" + k].append(float(r["corr_y"]))
v[s]["e" + k].append(float(r["error_value"]))
print("capteur dcorr_x dcorr_y (bruit nuit x, y) error avant → après")
for s in sorted(v):
d = v[s]
if not d["cxA"] or not d["cxB"]:
print(s, "-"); continue
bx = st.median(abs(d["cxA"][i + 1] - d["cxA"][i]) for i in range(len(d["cxA"]) - 1))
by = st.median(abs(d["cyA"][i + 1] - d["cyA"][i]) for i in range(len(d["cyA"]) - 1))
dx = st.median(d["cxB"]) - st.median(d["cxA"]); dy = st.median(d["cyB"]) - st.median(d["cyA"])
print(f"{s:7s} {dx:+.4f} ({dx / bx:+5.1f}) {dy:+.4f} ({dy / by:+5.1f}) {st.median(d['eA']):.3f} → {st.median(d['eB']):.3f}")