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

41 lines
2.2 KiB
Python

"""Par heure : agitation des corr (médiane entre cibles de |diff| corr_x, corr_y), nb de rejets, error_value médiane,
et températures (metrics). Une ligne par heure, du 16/10 au 01/11."""
import csv, glob, collections, statistics as st
D = 'data/LENZSPITZE'
REFS = {'92H', '8002', '8004', '8011', '8012', '8013', '8014', '8017', '8019'}
rows = collections.defaultdict(dict) # t -> s -> (cx, cy, ev, thr)
for f in sorted(glob.glob(D + '/displacement/*.csv')):
for r in csv.DictReader(open(f)):
t = r['time_utc'][:16]
if t >= '2026-11-01': continue
cx = float(r['corr_x']) if r['corr_x'] else None
cy = float(r['corr_y']) if r['corr_y'] else None
rows[t][r['sensor_name']] = (cx, cy, float(r['error_value']), float(r['error_threshold']))
ts = sorted(rows)
# |diff| per sensor between consecutive instants, grouped by hour
agx = collections.defaultdict(list); agy = collections.defaultdict(list)
rej = collections.Counter(); rejref = collections.Counter(); ev = collections.defaultdict(list); n = collections.Counter()
for a, b in zip(ts, ts[1:]):
h = b[:13]
n[h] += 1
for s, (cx, cy, e, thr) in rows[b].items():
if e > thr:
(rejref if s in REFS else rej)[h] += 1
if s in REFS: continue
ev[h].append(e)
pa = rows[a].get(s)
if pa and cx is not None and pa[0] is not None:
agx[h].append(abs(cx - pa[0])); agy[h].append(abs(cy - pa[1]))
temps = {}
for nom in ('temperature_deg_c', 'sensor_CPU_deg_c'):
for f in glob.glob(D + f'/metrics/LENZSPITZE_{nom}_*.csv'):
for r in csv.DictReader(open(f)):
if r['metric']:
temps.setdefault(r['time_utc'][:13].replace(' ', 'T'), {})[nom] = float(r['metric'])
print('heure n agit_x agit_y ev_med rej_cib rej_ref T_temp T_cpu')
for h in sorted(set(agx) | set(n)):
hh = h.replace(' ', 'T')
T = temps.get(hh, {})
mx = st.median(agx[h]) if agx[h] else float('nan'); my = st.median(agy[h]) if agy[h] else float('nan')
print(f"{hh} {n[h]:3d} {mx:7.4f} {my:7.4f} {st.median(ev[h]) if ev[h] else float('nan'):7.3f} {rej[h]:6d} {rejref[h]:6d} {T.get('temperature_deg_c', float('nan')):6.1f} {T.get('sensor_CPU_deg_c', float('nan')):6.1f}")