Files
Support-Agent/labeling/auto/etiqueteur/MICHIGAN_2026-10-01/outils/heures.py
T

23 lines
1.2 KiB
Python
Raw Normal View History

"""Températures horaires sur une fenêtre, avec la médiane des cibles aux instants de mesure.
Lancer depuis la racine : python3 labeling/auto/etiqueteur/MICHIGAN_2026-10-01/outils/heures.py DEBUT FIN
"""
import csv, glob, sys
from datetime import datetime
D, OUT = "data/MICHIGAN", "labeling/auto/etiqueteur/MICHIGAN_2026-10-01"
A, B = datetime.fromisoformat(sys.argv[1]), datetime.fromisoformat(sys.argv[2])
SENS = ["A0", "CPU", "GPU", "PLL", "thermal"]
tab = {}
for s in SENS:
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:
tab.setdefault(t, {})[s] = r["metric"]
cor = {datetime.fromisoformat(r["instant"][:-1]): r
for r in csv.DictReader(open(f"{OUT}/temp_corr.tsv"), delimiter="\t")}
print("heure " + " ".join(f"{s:>7}" for s in SENS) + " cx_med cy_med sepx sepy")
for t in sorted(set(tab) | {k for k in cor if A <= k <= B}):
c = cor.get(t)
print(f"{t:%d.%m %H:%M} " + " ".join(f"{tab.get(t, {}).get(s, '-'):>7}" for s in SENS)
+ (f" {c['cx_med']:>6} {c['cy_med']:>6} {c['sepx']:>6} {c['sepy']:>6}" if c else ""))