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

32 lines
1.4 KiB
Python

"""Écarts brefs de la médiane des cibles au-dessus de la dérive lente, face aux écarts brefs des températures.
Lit temp_corr.tsv (écrit par temp_corr.py). Fond lent : médiane glissante de +-36 h.
Lancer depuis la racine : python3 labeling/auto/etiqueteur/MICHIGAN_2026-10-01/outils/ecarts.py [k]
"""
import csv, sys, statistics as st
from datetime import datetime, timedelta
OUT = "labeling/auto/etiqueteur/MICHIGAN_2026-10-01"
K = float(sys.argv[1]) if len(sys.argv) > 1 else 3
R = list(csv.DictReader(open(f"{OUT}/temp_corr.tsv"), delimiter="\t"))
T = [datetime.fromisoformat(r["instant"][:-1]) for r in R]
COLS = ["cx_med", "cy_med", "sepx", "sepy", "A0", "CPU", "GPU", "PLL", "thermal"]
def resid(col):
v = [float(r[col]) for r in R]
out = []
for i, t in enumerate(T):
w = [v[j] for j, u in enumerate(T) if abs(u - t) <= timedelta(hours=36)
and (u >= datetime(2026, 10, 9, 12)) == (t >= datetime(2026, 10, 9, 12))]
out.append(v[i] - st.median(w))
return out
res = {c: resid(c) for c in COLS}
mad = {c: st.median(abs(x) for x in res[c]) for c in COLS}
print("MAD des résidus :", {c: round(mad[c], 3) for c in COLS})
print("instant " + " ".join(f"{c:>8}" for c in COLS) + " (en MAD)")
for i, t in enumerate(T):
if abs(res["cx_med"][i]) > K * mad["cx_med"] or abs(res["cy_med"][i]) > K * mad["cy_med"]:
print(f"{t:%Y-%m-%dT%H:%MZ} " + " ".join(f"{res[c][i] / mad[c]:8.1f}" for c in COLS))