Files
Support-Agent/labeling/auto/etiqueteur/LENZSPITZE_2026-10-01/outils/vague.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

28 lines
1.7 KiB
Python

"""Vague thermique d'une cible : par jour, écart de corr (médiane glissante d'1 h) à la médiane de la nuit (00-04 h UTC) ;
début = premier instant après 04 h où |écart| > SEUIL, extrême et son instant, fin = premier instant après l'extrême où
|écart| < SEUIL (avant 04 h le lendemain). Usage : vague.py CAPTEUR COLONNE SEUIL"""
import csv, glob, sys, collections, statistics as st, datetime as dt
cap, col, S = sys.argv[1], sys.argv[2], float(sys.argv[3])
P = lambda s: dt.datetime.fromisoformat(s)
pts = []
for f in sorted(glob.glob('data/LENZSPITZE/displacement/*.csv')):
for r in csv.DictReader(open(f)):
if r['sensor_name'] == cap and r[col] and float(r['error_value']) <= float(r['error_threshold']):
pts.append((P(r['time_utc']), float(r[col])))
pts.sort()
lis = []
for i, (t, v) in enumerate(pts):
w = [x for u, x in pts[max(0, i - 12): i + 13] if abs((u - t).total_seconds()) <= 1800]
lis.append((t, st.median(w)))
jours = sorted({t.date() for t, _ in lis})
for j in jours:
nuit = [v for t, v in lis if t.date() == j and t.hour < 4]
if len(nuit) < 10: print(j, 'pas de nuit'); continue
n = st.median(nuit)
jour = [(t, v - n) for t, v in lis if (t.date() == j and t.hour >= 4) or (t.date() == j + dt.timedelta(days=1) and t.hour < 4)]
hors = [(t, d) for t, d in jour if abs(d) > S]
if not hors: print(j, 'rien'); continue
t0 = hors[0][0]; te, de = max(jour, key=lambda x: abs(x[1]) if x[0] >= t0 else 0)
fin = next((t for t, d in jour if t > te and abs(d) < S), None)
print(f"{j} début {t0:%H:%M} extrême {de:+.3f} à {te:%d %H:%M} fin {fin:%d %H:%M}" if fin else f"{j} début {t0:%H:%M} extrême {de:+.3f} à {te:%d %H:%M} pas de retour")