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

50 lines
2.4 KiB
Python

"""Médiane des cibles de corr_x, corr_y face à la température (A0, thermal, horaire), écart brut REFG43N-REF42, error_value médiane."""
import csv, glob, statistics as st
from collections import defaultdict
from datetime import datetime
import matplotlib
matplotlib.use("Agg")
import matplotlib.pyplot as plt
D = "data/MICHIGAN"
OUT = "labeling/auto/etiqueteur/MICHIGAN_2026-10-20/temperature_corr.png"
T0, T1 = "2026-10-17", "2026-11-03"
rows = defaultdict(dict)
for f in sorted(glob.glob(f"{D}/displacement/*.csv")):
for r in csv.DictReader(open(f)):
if T0 <= r["time_utc"] <= T1:
rows[r["time_utc"][:16]][r["sensor_name"]] = r
P = lambda t: datetime.strptime(t, "%Y-%m-%d %H:%M")
ts, cx, cy, dref_x, dref_y, ev = [], [], [], [], [], []
for t in sorted(rows):
s = rows[t]
ok = [r for r in s.values() if r["pattern_type"] == "target" and r["corr_x"]]
ts.append(P(t))
cx.append(st.median(float(r["corr_x"]) for r in ok))
cy.append(st.median(float(r["corr_y"]) for r in ok))
dref_x.append(float(s["REFG43N"]["x"]) - float(s["REF42"]["x"]))
dref_y.append(float(s["REFG43N"]["y"]) - float(s["REF42"]["y"]))
ev.append(st.median(float(r["error_value"]) for r in s.values() if r["pattern_type"] == "target"))
temp = {}
for name in ("sensor_A0_deg_c", "sensor_thermal_deg_c", "sensor_CPU_deg_c"):
pts = []
for f in glob.glob(f"{D}/metrics/MICHIGAN_{name}_*.csv"):
for r in csv.DictReader(open(f)):
if T0 <= r["time_utc"] <= T1 and r["metric"]:
pts.append((P(r["time_utc"][:16]), float(r["metric"])))
temp[name] = sorted(pts)
fig, ax = plt.subplots(5, 1, figsize=(15, 13), sharex=True)
ax[0].plot(ts, cx, ".-"); ax[0].set_ylabel("corr_x médiane cibles")
ax[1].plot(ts, cy, ".-"); ax[1].set_ylabel("corr_y médiane cibles")
for n, p in temp.items():
ax[2].plot([a for a, _ in p], [b for _, b in p], label=n)
ax[2].legend(); ax[2].set_ylabel("°C")
ax[3].plot(ts, [v - st.median(dref_x) for v in dref_x], ".-", label="x")
ax[3].plot(ts, [v - st.median(dref_y) for v in dref_y], ".-", label="y")
ax[3].legend(); ax[3].set_ylabel("REFG43N - REF42 brut [px]")
ax[4].plot(ts, ev, ".-"); ax[4].set_ylabel("error_value médiane cibles")
for a in ax:
a.grid(alpha=.3)
a.axvspan(P("2026-10-20 00:00"), P("2026-11-01 00:00"), color="y", alpha=.05)
fig.tight_layout(); fig.savefig(OUT, dpi=80); print(OUT)