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

28 lines
1.5 KiB
Python
Raw Normal View History

"""Instants touchés sur une fenêtre : capteurs rejetés (hors PR04) et capteurs hors niveau (plages_gl1.txt : > 6 bruits du niveau glissant ±3 h, hors PR04).
Usage : python3 labeling/auto/etiqueteur/NORDEND_2026-08-16/outils/touche.py 2026-08-17T02:00 2026-08-17T11:00"""
import csv, glob, re, sys
from collections import defaultdict
from datetime import datetime, timedelta
D = "labeling/auto/etiqueteur/NORDEND_2026-08-16/"
a, b = (datetime.fromisoformat(x) for x in sys.argv[1:3])
rej, off, pres = defaultdict(list), defaultdict(list), set()
for p in sorted(glob.glob("data/NORDEND/displacement/NORDEND_advanced_*.csv")):
if (a - timedelta(days=1)).strftime("%Y%m%d") <= p[-12:-4] <= b.strftime("%Y%m%d"):
for r in csv.DictReader(open(p)):
t = datetime.fromisoformat(r["time_utc"][:16])
pres.add(t)
if float(r["error_value"]) > float(r["error_threshold"]) and r["sensor_name"] != "PR04":
rej[t].append(r["sensor_name"])
for l in open(D + "plages_gl1.txt"):
m = re.match(r"(\d{4}-\d\d-\d\dT\d\d:\d\d)Z\s+\d+\s+(.*?)\|", l)
if m:
s = [x for x in m.group(2).split() if not x.startswith("PR04")]
if s:
off[datetime.fromisoformat(m.group(1))] = s
t = a
while t <= b:
if t not in pres:
print(f"{t:%d/%m %H:%M} (pas de mesure)")
elif rej[t] or off[t]:
print(f"{t:%d/%m %H:%M} rej {','.join(sorted(rej[t])) or '-':40s} hors {' '.join(off[t])}")
t += timedelta(minutes=15)