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>
60 lines
3.7 KiB
Python
60 lines
3.7 KiB
Python
"""Vague thermique jour par jour : à chaque mesure, médiane sur les cibles du pont de corr_x, corr_y
|
|
(écart à la médiane du lot), pan et tilt de la caméra, x brut médian, température A0 (horaire).
|
|
Puis, par jour, l'instant du max et du min de corr_y médian et de corr_x médian, entre bornes.
|
|
Usage : .venv/bin/python <ce fichier> data/JUNGFRAU 2026-09-30 2026-10-05 <sortie>
|
|
"""
|
|
import csv, glob, statistics as st, sys
|
|
from collections import defaultdict
|
|
from datetime import date, timedelta, datetime
|
|
|
|
dossier, d0, d1, sortie = sys.argv[1], date.fromisoformat(sys.argv[2]), date.fromisoformat(sys.argv[3]), sys.argv[4]
|
|
CIBLES = ["BJ_C", "BJ_D", "BJ_G", "PBJ_C", "PM_C", "PM_D", "BL_C", "BL_D", "BL_G", "PBL_C", "PBL_D"]
|
|
jours = [(d0 + timedelta(days=i)) for i in range((d1 - d0).days + 1)]
|
|
mes = defaultdict(dict) # t -> capteur -> (cx, cy, x)
|
|
cam = {}
|
|
temp = {}
|
|
for j in jours:
|
|
for r in csv.DictReader(open(f"{dossier}/displacement/JUNGFRAU_advanced_{j:%Y%m%d}.csv")):
|
|
t = r["time_utc"][:16]
|
|
if r["sensor_name"] in CIBLES and r["corr_x"] not in ("", "nan"):
|
|
mes[t][r["sensor_name"]] = (float(r["corr_x"]), float(r["corr_y"]), float(r["x"]))
|
|
for r in csv.DictReader(open(f"{dossier}/camera/JUNGFRAU_camera_{j:%Y%m%d}.csv")):
|
|
cam[r["time_utc"][:16]] = (float(r["median_pan"]), float(r["median_tilt"]))
|
|
for f in glob.glob(f"{dossier}/metrics/*_sensor_A0_deg_c_{j:%Y_%m_%d}_00_00*.csv"):
|
|
for r in csv.DictReader(open(f)):
|
|
temp[r["time_utc"][:13]] = float(r["metric"])
|
|
niv = {c: (st.median(m[c][0] for m in mes.values() if c in m), st.median(m[c][1] for m in mes.values() if c in m),
|
|
st.median(m[c][2] for m in mes.values() if c in m)) for c in CIBLES}
|
|
rows = []
|
|
for t in sorted(mes):
|
|
m = mes[t]
|
|
cx = st.median(m[c][0] - niv[c][0] for c in m)
|
|
cy = st.median(m[c][1] - niv[c][1] for c in m)
|
|
xb = st.median(m[c][2] - niv[c][2] for c in m)
|
|
p, ti = cam.get(t[:13] + ":" + t[14:16], (float("nan"), float("nan")))
|
|
rows.append((t, cx, cy, xb, p, ti, temp.get(t[:13])))
|
|
with open(f"{sortie}/vague.tsv", "w") as f:
|
|
f.write("instant\tcorr_x_med\tcorr_y_med\tx_brut_med\tpan\ttilt\tA0\n")
|
|
for r in rows:
|
|
f.write("\t".join(str(v) if not isinstance(v, float) else f"{v:.4f}" for v in r) + "\n")
|
|
# extrêmes par jour : max de corr_y de 00:00 à 12:00, min de 09:00 à 23:45 ; max de corr_x de 08:00 à 20:00
|
|
for j in jours:
|
|
s = f"{j:%Y-%m-%d}"
|
|
def ext(a, b, k, fn):
|
|
sel = [r for r in rows if r[0][:10] == s and a <= r[0][11:16] <= b]
|
|
return fn(sel, key=lambda r: r[k]) if sel else None
|
|
ymax = ext("00:00", "12:00", 2, max); ymin = ext("09:00", "23:45", 2, min); xmax = ext("08:00", "20:00", 1, max)
|
|
pmax = ext("05:00", "20:00", 4, max)
|
|
print(s, f"corr_y max {ymax[0][11:]} {ymax[2]:+.3f} | corr_y min {ymin[0][11:]} {ymin[2]:+.3f} | corr_x max {xmax[0][11:]} {xmax[1]:+.3f} | pan max {pmax[0][11:]} {pmax[4]:.4f}")
|
|
import matplotlib; matplotlib.use("Agg"); import matplotlib.pyplot as plt
|
|
ts = [datetime.fromisoformat(r[0].replace(" ", "T")) for r in rows]
|
|
fig, ax = plt.subplots(5, 1, figsize=(15, 13), sharex=True)
|
|
for a, k, lab in zip(ax, [1, 2, 3, 4, 6], ["corr_x médian des cibles (écart)", "corr_y médian des cibles (écart)", "x brut médian des cibles (écart, px)", "pan caméra (deg)", "température A0 (°C, horaire)"]):
|
|
a.plot(ts, [r[k] if r[k] is not None else float("nan") for r in rows], ".-", ms=2, lw=0.8); a.set_ylabel(lab, fontsize=8); a.grid(alpha=0.4)
|
|
for a in ax:
|
|
for j in jours + [d1 + timedelta(days=1)]:
|
|
a.axvline(datetime(j.year, j.month, j.day), color="k", lw=0.6)
|
|
fig.suptitle("JUNGFRAU : vague thermique des cibles, caméra et température (UTC)")
|
|
fig.tight_layout(); fig.savefig(f"{sortie}/vague.png", dpi=90)
|
|
print(f"{sortie}/vague.png")
|