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>
37 lines
2.1 KiB
Python
37 lines
2.1 KiB
Python
"""Épisodes d'agitation des corr des cibles : à chaque instant, médiane entre cibles de max(|dcorr_x|,|dcorr_y|) d'une mesure
|
|
à la suivante ; lissée par médiane glissante sur W mesures ; plages au-dessus de SEUIL (fusion des plages à moins de FUS mesures).
|
|
Imprime aussi, par plage, error_value médiane des cibles, le max lissé, et le nombre de cibles qui « basculent » (saut > 0.2)."""
|
|
import csv, glob, sys, collections, statistics as st
|
|
SEUIL = float(sys.argv[1]) if len(sys.argv) > 1 else 0.007
|
|
W, FUS = 7, 6
|
|
REFS = {'92H', '8002', '8004', '8011', '8012', '8013', '8014', '8017', '8019'}
|
|
rows = collections.defaultdict(dict)
|
|
for f in sorted(glob.glob('data/LENZSPITZE/displacement/*.csv')):
|
|
for r in csv.DictReader(open(f)):
|
|
t = r['time_utc'][:16]
|
|
if t >= '2026-11-01' or r['sensor_name'] in REFS: continue
|
|
ok = float(r['error_value']) <= float(r['error_threshold']) and r['corr_x']
|
|
rows[t][r['sensor_name']] = (float(r['corr_x']), float(r['corr_y'])) if ok else None, float(r['error_value'])
|
|
ts = sorted(rows)
|
|
ag = [float('nan')]; ev = [st.median(v[1] for v in rows[ts[0]].values())]; flip = [set()]
|
|
for a, b in zip(ts, ts[1:]):
|
|
d = []; fl = set()
|
|
for s, (c, e) in rows[b].items():
|
|
p = rows[a].get(s)
|
|
if c and p and p[0]:
|
|
m = max(abs(c[0] - p[0][0]), abs(c[1] - p[0][1])); d.append(m)
|
|
if m > 0.2: fl.add(s)
|
|
ag.append(st.median(d) if d else float('nan')); ev.append(st.median(v[1] for v in rows[b].values())); flip.append(fl)
|
|
lis = [st.median([x for x in ag[max(0, i - W // 2): i + W // 2 + 1] if x == x] or [0]) for i in range(len(ts))]
|
|
on = [x > SEUIL for x in lis]
|
|
pl = []; i = 0
|
|
while i < len(ts):
|
|
if on[i]:
|
|
j = i
|
|
while j + 1 < len(ts) and (on[j + 1] or any(on[j + 1: j + 1 + FUS])): j += 1
|
|
pl.append((i, j)); i = j + 1
|
|
else: i += 1
|
|
for i, j in pl:
|
|
fl = collections.Counter(s for k in range(i, j + 1) for s in flip[k])
|
|
print(f"{ts[max(i-1,0)]} -> {ts[min(j+1,len(ts)-1)]} n={j-i+1:3d} agit_max={max(lis[i:j+1]):.4f} ev_med={st.median(ev[i:j+1]):.3f} bascules={dict(fl.most_common(6))}")
|