Files
Support-Agent/labeling/auto/etiqueteur/JUNGFRAU_2026-10-06/outils/sauts.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

54 lines
2.0 KiB
Python

"""Pas où plusieurs cibles sautent ensemble sur corr_x/corr_y (|delta| > K bruits).
usage : python3 sauts.py DEBUT FIN [K] [NMIN]"""
import csv, glob, sys, statistics as st
from datetime import datetime, timedelta
D = "data/JUNGFRAU"
deb = datetime.fromisoformat(sys.argv[1].replace("Z", "+00:00"))
fin = datetime.fromisoformat(sys.argv[2].replace("Z", "+00:00"))
K = float(sys.argv[3]) if len(sys.argv) > 3 else 5
NMIN = int(sys.argv[4]) if len(sys.argv) > 4 else 3
def t15(s):
t = datetime.fromisoformat(s)
return t.replace(second=0, microsecond=0, minute=t.minute // 15 * 15)
rows = {}
d = deb.date() - timedelta(days=1)
while d <= fin.date():
for f in glob.glob(f"{D}/displacement/JUNGFRAU_advanced_{d:%Y%m%d}.csv"):
for r in csv.DictReader(open(f)):
t = t15(r["time_utc"])
if deb <= t <= fin:
rows[(t, r["sensor_name"])] = r
d += timedelta(days=1)
temps = sorted({t for t, _ in rows})
cibles = sorted({c for _, c in rows if not c.startswith("REF")})
refs = sorted({c for _, c in rows if c.startswith("REF")})
def v(t, c, k):
r = rows.get((t, c))
return float(r[k]) if r and r[k] != "" else None
bruit = {}
for c in cibles:
for k in ("corr_x", "corr_y"):
dd = [abs(v(b, c, k) - v(a, c, k)) for a, b in zip(temps, temps[1:])
if v(a, c, k) is not None and v(b, c, k) is not None]
bruit[(c, k)] = st.median(dd) if dd else 1
for a, b in zip(temps, temps[1:]):
out = []
for k in ("corr_x", "corr_y"):
s = []
for c in cibles:
if v(a, c, k) is None or v(b, c, k) is None:
continue
z = (v(b, c, k) - v(a, c, k)) / bruit[(c, k)]
if abs(z) > K:
s.append(f"{c}{z:+.0f}")
if len(s) >= NMIN:
out.append(f"{k}[{len(s)}] " + " ".join(s))
if out:
ev = " ".join(f"{r}={v(b, r, 'error_value'):.2f}/{rows[(b, r)]['inlier'] or '-'}" for r in refs if (b, r) in rows)
print(b.strftime("%d/%m %H:%M"), "|", " | ".join(out), "|", ev)