Files
Support-Agent/labeling/auto/etiqueteur/NORDEND_2026-08-16/outils/jour_capteur.py
T

33 lines
1.7 KiB
Python
Raw Normal View History

"""Par jour (UTC) et par capteur : médiane d'error_value de nuit (20-03) et de jour (08-17), part de mesures rejetées, heures des rejets (comptées par heure),
médianes de corr_x, corr_y des mesures acceptées. NORDEND, 10/08-09/09.
Usage : python3 labeling/auto/etiqueteur/NORDEND_2026-08-16/outils/jour_capteur.py PR04[,PR07]
"""
import csv, glob, statistics as st, sys
from collections import defaultdict
from datetime import datetime
caps = sys.argv[1].split(",")
d = {c: defaultdict(list) for c in caps}
for p in sorted(glob.glob("data/NORDEND/displacement/NORDEND_advanced_*.csv")):
if "20260810" <= p[-12:-4] <= "20260909":
for r in csv.DictReader(open(p)):
if r["sensor_name"] in d:
t = datetime.fromisoformat(r["time_utc"])
e = float(r["error_value"])
d[r["sensor_name"]][t.date()].append((t.hour, e, e > float(r["error_threshold"]),
float(r["corr_x"]) if r["corr_x"] else None, float(r["corr_y"]) if r["corr_y"] else None))
for c in caps:
print(f"== {c}")
for j in sorted(d[c]):
L = d[c][j]
nuit = [e for h, e, *_ in L if h >= 20 or h < 3]
jour = [e for h, e, *_ in L if 8 <= h < 17]
rej = [h for h, e, r, *_ in L if r]
hs = defaultdict(int)
for h in rej:
hs[h] += 1
cx = [x for *_, x, y in L if x is not None]
cy = [y for *_, x, y in L if y is not None]
m = lambda v: f"{st.median(v):.3f}" if v else " - "
print(f"{j:%d/%m} n={len(L):3d} ev nuit {m(nuit)} jour {m(jour)} rej {len(rej):3d} ({100 * len(rej) / len(L):3.0f}%) "
f"cx {m(cx)} cy {m(cy)} h: {' '.join(f'{h}:{n}' for h, n in sorted(hs.items()))}")