Files
Support-Agent/labeling/auto/etiqueteur/WILDSTRUBEL_2026-09-07/outils/pose_jour.py
T
maximeandClaude Opus 5.5 35b5ed4d74 Auto labels reviewed per station and cross-reviewed; all labeling knowledge in labeling/ (D-130)
- Every station's auto labels reviewed by an analyst (/review-auto-labels), then a
  cross-review per family across all stations (new skill /cross-review-labels),
  a finishing pass, and descriptions rewritten in words (no numeric values).
- The three never-labeled ranges (WILDSTRUBEL 07/09-01/10, NORDEND 16/08-01/10)
  labeled and reviewed: 991 auto labels on 11 stations, labeling/controle.py at 0 errors.
- Labeling knowledge gathered in labeling/: regles-d-etiquetage.md (new), familles.md
  (settled boundaries), connaissances/ (notes moved from docs/, links updated),
  the label map rebuilt from reviewed labels, events and cases; events tied to their
  stations (PS_DES_COUDRES is JUNGFRAU). The labeler and reviewers read only labeling/.
- labels-map reads auto labels and events; decision D-130; living plan points 73-75.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-05 08:21:57 +01:00

73 lines
2.8 KiB
Python

"""Par jour : la vague de la pose de la caméra (tilt par défaut) face au niveau de nuit (18 h → 2 h UTC) qui précède
(ou qui suit, si la précédente manque ou est à plus d'un jour). Suite de mesures au-delà de K bruits autour de l'extrême,
une coupure de plus de G mesures sous le seuil la termine ; imprime le premier et le dernier instant de la suite,
la mesure juste avant et juste après, l'extrême et son heure.
Usage : python3 pose_jour.py DEBUT FIN [--col median_tilt] [--k 5] [--g 3] (DEBUT, FIN : AAAA-MM-JJ)
"""
import csv, os, sys, statistics as st
from datetime import date, datetime, timedelta
a = sys.argv[1:]
d0, d1 = date.fromisoformat(a[0]), date.fromisoformat(a[1])
col = a[a.index("--col") + 1] if "--col" in a else "median_tilt"
K = float(a[a.index("--k") + 1]) if "--k" in a else 5
G = int(a[a.index("--g") + 1]) if "--g" in a else 3
v = []
d = d0 - timedelta(days=1)
while d <= d1 + timedelta(days=1):
f = f"data/WILDSTRUBEL/camera/WILDSTRUBEL_camera_{d:%Y%m%d}.csv"
if os.path.exists(f):
for r in csv.DictReader(open(f)):
v.append((datetime.fromisoformat(r["time_utc"][:16]), float(r[col])))
d += timedelta(days=1)
v.sort()
bruit = st.median(abs(x[1] - y[1]) for x, y in zip(v, v[1:]))
print(f"{col} bruit {bruit:.5f}")
def nuit(n0):
return [x for t, x in v if n0 <= t < n0 + timedelta(hours=8)]
d = d0
while d <= d1:
n0 = datetime.combine(d - timedelta(days=1), datetime.min.time()) + timedelta(hours=18)
ref, quelle = nuit(n0), "précédente"
if len(ref) < 8:
ref, quelle = nuit(n0 + timedelta(days=1)), "suivante"
jour = [(t, x) for t, x in v if n0 + timedelta(hours=8) <= t < n0 + timedelta(hours=24)]
if len(ref) < 8 or len(jour) < 8:
print(f"{d:%d/%m} pas assez de mesures")
d += timedelta(days=1)
continue
niv = st.median(ref)
z = [(x - niv) / bruit for _, x in jour]
i = max(range(len(z)), key=lambda k: abs(z[k]))
lo = hi = i
k, sous = i, 0
while k > 0:
k -= 1
if abs(z[k]) > K:
lo, sous = k, 0
else:
sous += 1
if sous > G:
break
k, sous = i, 0
while k < len(z) - 1:
k += 1
if abs(z[k]) > K:
hi, sous = k, 0
else:
sous += 1
if sous > G:
break
av = jour[lo - 1][0] if lo > 0 else None
ap = jour[hi + 1][0] if hi + 1 < len(jour) else None
mx = max(range(len(z)), key=lambda k: z[k])
mn = min(range(len(z)), key=lambda k: z[k])
print(f"{d:%d/%m} nuit {quelle} {niv:.4f} | suite {jour[lo][0]:%H:%M} → {jour[hi][0]:%H:%M} "
f"(avant {av:%H:%M} / après {ap:%H:%M}) | max {z[mx]:+.0f} à {jour[mx][0]:%H:%M}, min {z[mn]:+.0f} à {jour[mn][0]:%H:%M}"
if av and ap else f"{d:%d/%m} suite {jour[lo][0]} → {jour[hi][0]}")
d += timedelta(days=1)