Files
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

57 lines
2.2 KiB
Python

"""Par instant, cibles/réfs dont corr_x ou corr_y s'écarte de son niveau local (médiane de la fenêtre)
de plus de K bruits (bruit = médiane |écart entre deux mesures|) ; + nb de rejetées et error_value hautes.
Usage : python3 out/.../outils/pas.py DEBUT FIN [K]
"""
import csv, glob, sys
from datetime import datetime
from statistics import median
ST = "data/CLARIDEN"
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
rows = []
for f in sorted(glob.glob(f"{ST}/displacement/CLARIDEN_advanced_2026*.csv")):
d = f[-12:-4]
if not (deb.strftime("%Y%m%d") <= d <= fin.strftime("%Y%m%d")):
continue
for r in csv.DictReader(open(f)):
t = datetime.fromisoformat(r["time_utc"].replace(" ", "T"))
if deb <= t <= fin:
rows.append((t.strftime("%m-%d %H:%M"), r))
ser = {}
for t, r in rows:
s = r["sensor_name"]
rej = float(r["error_value"]) > float(r["error_threshold"])
for c in ("corr_x", "corr_y", "error_value"):
v = r[c]
if c != "error_value" and (rej or not v):
continue
ser.setdefault((s, c), {})[t] = float(v)
stat = {}
for k, d in ser.items():
ts = sorted(d); vs = [d[t] for t in ts]
if len(vs) < 5:
continue
stat[k] = (median(vs), median(abs(a - b) for a, b in zip(vs, vs[1:])) or 1e-9)
inst = sorted({t for t, _ in rows})
rej = {}
for t, r in rows:
if float(r["error_value"]) > float(r["error_threshold"]):
rej.setdefault(t, []).append(r["sensor_name"])
for t in inst:
out = []
for c in ("corr_x", "corr_y"):
for (s, cc), (m, b) in stat.items():
if cc == c and t in ser[(s, c)]:
z = (ser[(s, c)][t] - m) / b
if abs(z) > K:
out.append(f"{s}:{c[-1]}{z:+.0f}")
ev = []
for (s, cc), (m, b) in stat.items():
if cc == "error_value" and t in ser[(s, cc)]:
z = (ser[(s, cc)][t] - m) / b
if z > 10:
ev.append(s)
print(t, f"n={len(out)}", " ".join(sorted(out)), "| ev+", len(ev), "| rej", ",".join(r for r in rej.get(t, []) if r != "P-300-B"))