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

42 lines
2.1 KiB
Python

"""Par jour : (1) fenetre du cycle thermique : pan de la camera et corr_x de P7, P6, P5 (mediane des ecarts
au niveau de la nuit precedente 00-04 h), premier et dernier instant ou l'ecart depasse un seuil ;
(2) fenetre de l'agitation de jour : |difference d'une mesure a la suivante| de corr_x, corr_y sur
CV.2, CV.4, F4.2, BG.3, CV.6, mediane glissante sur 5 pas, au-dessus de 2 fois le niveau des nuits."""
import csv, glob, statistics as st
from collections import defaultdict
pan = {}
for f in glob.glob("data/SNCF01/camera/*.csv"):
for r in csv.DictReader(open(f)):
pan[r["time_utc"][:16].replace(" ", "T")] = (float(r["median_pan"]), float(r["median_tilt"]), float(r["median_scale"]))
corr = defaultdict(dict)
for f in glob.glob("data/SNCF01/displacement/*.csv"):
for r in csv.DictReader(open(f)):
if r["corr_x"] and float(r["error_value"]) <= float(r["error_threshold"]):
corr[r["time_utc"][:16].replace(" ", "T")][r["sensor_name"]] = (float(r["corr_x"]), float(r["corr_y"]))
times = sorted(t for t in corr if "2026-10-04" <= t < "2026-11-01")
TH = ("P7", "P6", "P5")
AG = ("CV.2", "CV.4", "F4.2", "BG.3", "CV.6")
def agit(i):
t0, t1 = times[i - 1], times[i]
v = []
for s in AG:
if s in corr[t0] and s in corr[t1]:
v.append(max(abs(corr[t1][s][0] - corr[t0][s][0]), abs(corr[t1][s][1] - corr[t0][s][1])))
return st.median(v) if v else None
ag = {times[i]: agit(i) for i in range(1, len(times))}
nuit = [a for t, a in ag.items() if a is not None and (t[11:13] < "04" or t[11:13] >= "21")]
ref_ag = st.median(nuit)
print("agitation de nuit (mediane)", round(ref_ag, 4))
for d in ("2026-10-09", "2026-10-16", "2026-10-19", "2026-10-21", "2026-10-22", "2026-10-25", "2026-10-26", "2026-10-28"):
tt = [t for t in times if t[:10] == d]
sm = []
for i, t in enumerate(tt):
w = [ag[x] for x in tt[max(0, i - 2): i + 3] if ag.get(x) is not None]
sm.append((t, st.median(w) if w else 0))
ha = [t for t, v in sm if v > 2 * ref_ag]
print(d, ha[0][11:] if ha else "-", ha[-1][11:] if ha else "-", len(ha), "max", round(max(v for _, v in sm) / ref_ag, 1))