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>
58 lines
3.8 KiB
Python
58 lines
3.8 KiB
Python
"""Vue d'ensemble au pas natif : rejets (cibles, références), écart médian des corr des cibles à leur médiane du lot,
|
|
quelques cibles du rail, température. Usage : vue.py DEBUT FIN NOM [capteurs,...]"""
|
|
import csv, glob, sys, collections, statistics as st, datetime as dt
|
|
import matplotlib; matplotlib.use('Agg'); import matplotlib.pyplot as plt
|
|
D = 'data/LENZSPITZE'; OUT = 'labeling/auto/etiqueteur/LENZSPITZE_2026-10-01/'
|
|
REFS = {'92H', '8002', '8004', '8011', '8012', '8013', '8014', '8017', '8019'}
|
|
deb, fin, nom = sys.argv[1], sys.argv[2], sys.argv[3]
|
|
choix = sys.argv[4].split(',') if len(sys.argv) > 4 else ['1020', '1021', '1014', '1013', '1019', '8010']
|
|
P = lambda s: dt.datetime.fromisoformat(s.replace('Z', '+00:00'))
|
|
d0, d1 = P(deb), P(fin)
|
|
rows = collections.defaultdict(dict)
|
|
for f in sorted(glob.glob(D + '/displacement/*.csv')):
|
|
for r in csv.DictReader(open(f)):
|
|
t = P(r['time_utc'])
|
|
if not (d0 <= t <= d1): continue
|
|
ok = float(r['error_value']) <= float(r['error_threshold'])
|
|
rows[t][r['sensor_name']] = (float(r['corr_x']) if ok and r['corr_x'] else None,
|
|
float(r['corr_y']) if ok and r['corr_y'] else None, float(r['error_value']), ok)
|
|
ts = sorted(rows)
|
|
cibles = sorted({s for t in ts for s in rows[t]} - REFS)
|
|
med = {}
|
|
for s in cibles:
|
|
xs = [rows[t][s][0] for t in ts if s in rows[t] and rows[t][s][0] is not None]
|
|
ys = [rows[t][s][1] for t in ts if s in rows[t] and rows[t][s][1] is not None]
|
|
med[s] = (st.median(xs) if xs else 0, st.median(ys) if ys else 0)
|
|
rc = [sum(1 for s in cibles if s in rows[t] and not rows[t][s][3]) for t in ts]
|
|
rr = [sum(1 for s in REFS if s in rows[t] and not rows[t][s][3]) for t in ts]
|
|
dx = []; dy = []
|
|
for t in ts:
|
|
a = [abs(rows[t][s][0] - med[s][0]) for s in cibles if s in rows[t] and rows[t][s][0] is not None]
|
|
b = [abs(rows[t][s][1] - med[s][1]) for s in cibles if s in rows[t] and rows[t][s][1] is not None]
|
|
dx.append(st.median(a) if a else float('nan')); dy.append(st.median(b) if b else float('nan'))
|
|
cam = {}
|
|
for f in glob.glob(D + '/camera/*.csv'):
|
|
for r in csv.DictReader(open(f)):
|
|
t = P(r['time_utc'])
|
|
if d0 <= t <= d1: cam[t] = (float(r['median_pan']), float(r['median_tilt']), float(r['median_rotation']))
|
|
temp = {}
|
|
for f in glob.glob(D + '/metrics/LENZSPITZE_temperature_deg_c_*.csv'):
|
|
for r in csv.DictReader(open(f)):
|
|
if r['metric']:
|
|
t = P(r['time_utc'])
|
|
if d0 <= t <= d1: temp[t] = float(r['metric'])
|
|
fig, ax = plt.subplots(5 + 0, 1, figsize=(18, 16), sharex=True)
|
|
ax[0].plot(ts, rc, label='cibles rejetées'); ax[0].plot(ts, rr, label='références rejetées'); ax[0].legend(); ax[0].set_ylabel('rejets')
|
|
ax[1].plot(ts, dx, label='corr_x'); ax[1].plot(ts, dy, label='corr_y'); ax[1].legend(); ax[1].set_ylabel('|écart| médian des cibles')
|
|
for s in choix:
|
|
ax[2].plot(ts, [rows[t][s][0] - med[s][0] if s in rows[t] and rows[t][s][0] is not None else float('nan') for t in ts], lw=.7, label=s)
|
|
ax[3].plot(ts, [rows[t][s][1] - med[s][1] if s in rows[t] and rows[t][s][1] is not None else float('nan') for t in ts], lw=.7, label=s)
|
|
ax[2].legend(ncol=6, fontsize=7); ax[2].set_ylabel('corr_x'); ax[3].set_ylabel('corr_y')
|
|
tc = sorted(cam); a4 = ax[4]; a4.plot(tc, [cam[t][0] for t in tc], label='pan'); a4.plot(tc, [cam[t][1] for t in tc], label='tilt'); a4.legend(loc='upper left')
|
|
a5 = a4.twinx(); tt = sorted(temp); a5.plot(tt, [temp[t] for t in tt], 'r', label='temperature_deg_c'); a5.legend(loc='upper right')
|
|
for a in ax: a.grid(alpha=.4)
|
|
import matplotlib.dates as md
|
|
ax[-1].xaxis.set_major_locator(md.HourLocator(byhour=range(0, 24, 6 if (d1 - d0).days > 3 else 2)))
|
|
ax[-1].xaxis.set_major_formatter(md.DateFormatter('%d/%m %Hh')); plt.setp(ax[-1].get_xticklabels(), rotation=60)
|
|
fig.tight_layout(); p = OUT + f'vue_{nom}.png'; fig.savefig(p, dpi=70); print(p)
|