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

38 lines
2.1 KiB
Python

"""Zoom : températures horaires et médiane des cibles (corr_x, corr_y), écart des deux références.
Lancer depuis la racine : .venv/bin/python labeling/auto/etiqueteur/MICHIGAN_2026-10-01/outils/zoom.py DEBUT FIN NOM
"""
import csv, glob, sys
from datetime import datetime
import matplotlib
matplotlib.use("Agg")
import matplotlib.pyplot as plt
import matplotlib.dates as mdates
D, OUT = "data/MICHIGAN", "labeling/auto/etiqueteur/MICHIGAN_2026-10-01"
A, B, NOM = datetime.fromisoformat(sys.argv[1]), datetime.fromisoformat(sys.argv[2]), sys.argv[3]
SENS = ["A0", "CPU", "GPU", "PLL", "thermal"]
fig, ax = plt.subplots(4, 1, figsize=(15, 11), sharex=True)
for s in SENS:
pts = []
for f in sorted(glob.glob(f"{D}/metrics/MICHIGAN_sensor_{s}_deg_c_*.csv")):
for r in csv.DictReader(open(f)):
t = datetime.fromisoformat(r["time_utc"][:19].replace(" ", "T"))
if A <= t <= B and r["metric"]:
pts.append((t, float(r["metric"])))
ax[0].plot([p[0] for p in pts], [p[1] for p in pts], ".-", ms=3, lw=0.8, label=s)
ax[0].legend(ncol=5, fontsize=8); ax[0].set_ylabel("°C (horaire)")
R = list(csv.DictReader(open(f"{OUT}/temp_corr.tsv"), delimiter="\t"))
R = [r for r in R if A <= datetime.fromisoformat(r["instant"][:-1]) <= B]
T = [datetime.fromisoformat(r["instant"][:-1]) for r in R]
ax[1].plot(T, [float(r["cx_med"]) for r in R], "o-", ms=3, label="corr_x médiane cibles")
ax[2].plot(T, [float(r["cy_med"]) for r in R], "o-", ms=3, color="C1", label="corr_y médiane cibles")
ax[3].plot(T, [float(r["sepx"]) for r in R], "o-", ms=3, label="x REFG43N - REF42")
ax[3].plot(T, [float(r["sepy"]) - float(R[0]["sepy"]) + float(R[0]["sepx"]) for r in R], "o-", ms=3,
label="y REFG43N - REF42 (décalé)")
for a in ax:
a.grid(alpha=.3); a.legend(fontsize=8)
a.xaxis.set_major_locator(mdates.HourLocator(byhour=[0, 12]))
a.xaxis.set_major_formatter(mdates.DateFormatter("%d.%m\n%H:%M"))
fig.suptitle(f"MICHIGAN {A:%d.%m %H:%M} - {B:%d.%m %H:%M} UTC")
fig.tight_layout(); p = f"{OUT}/zoom_{NOM}.png"; fig.savefig(p, dpi=85); print(p)