auto: labels requalified under the 5-noise rules (only what stands out from the noise): 32 analyses refined, the 6 paused periods verified, the long labels requalified with the fixes the period analysts found; 1153 -> 961 labels
- 32 analyses: each label kept, rewritten or removed by its analyst (section Requalification of the report; mm magnitudes where the targets have them) - SNCF01 x3, WILDSTRUBEL 2026-09-01 -> 2026-10-06 x3: verified from their existing labels under the new rules - long labels (no analysis): auto/analyses/long-labels/<STATION>/; NORDEND-169 and -195 run to 07/11, so NORDEND-283 and -284 (their continuation) are removed - reading-rules.md, stations.md: the citations of removed or rewritten labels point to their successor, or to [expert] Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
c779de7720
commit
ddb17c2189
321 files changed
+18464
-3426
No files matched your search
@@ -0,0 +1,165 @@
|
||||
"""Build labels.jsonl from work/existing.jsonl: kept as they are (review kept), corrected (review dropped), removed, added.
|
||||
|
||||
Usage: python3 build_labels.py (from the repository root)
|
||||
"""
|
||||
import json, os
|
||||
|
||||
D = "labeling/auto/analyses/WILDSTRUBEL_2026-09-24T0230_2026-10-06T1945"
|
||||
old = [json.loads(l) for l in open(os.path.join(D, "work/existing.jsonl"))]
|
||||
W = "WILDSTRUBEL-"
|
||||
|
||||
REMOVED = {
|
||||
# daily heat shimmer: the daytime agitation stays under 5 own noises outside the moments labelled apart
|
||||
82: "shimmer", 90: "shimmer", 97: "shimmer", 101: "shimmer", 105: "shimmer", 114: "shimmer", 122: "shimmer",
|
||||
134: "shimmer", 139: "shimmer", 146: "shimmer", 156: "shimmer", 164: "shimmer", 170: "shimmer",
|
||||
# daily camera cycle that the corrected curves do not keep beyond 5 noises (single agitated points only)
|
||||
91: "thermal", 98: "thermal", 102: "thermal", 145: "thermal", 155: "thermal", 163: "thermal",
|
||||
# PB1_2 alone by day: the same dip as the camera wave, merged into the thermal labels 83 and 113
|
||||
84: "merged", 112: "merged",
|
||||
# passages and one-measurement losses whose effect on the other curves stays under 5 noises
|
||||
87: "sub", 88: "sub", 92: "sub", 93: "sub", 95: "sub", 99: "sub", 100: "sub", 104: "sub", 108: "sub",
|
||||
109: "sub", 110: "sub", 115: "sub", 117: "sub", 124: "sub", 126: "sub", 128: "sub", 129: "sub",
|
||||
149: "sub", 158: "sub", 159: "sub", 167: "replaced by the R1 label of 05/10 10:15",
|
||||
}
|
||||
|
||||
CORR = {}
|
||||
CORR[83] = dict(description=(
|
||||
"At sunrise, the camera nods down: its tilt rises, with its scale and its rotation, and all the raw positions, "
|
||||
"references included, move together in the image; the tilt peaks in early morning, goes below its night level in "
|
||||
"late morning, then comes back to it in early afternoon, while the housing temperature rises; the scale and the pan "
|
||||
"come back more slowly, until mid-afternoon. The compensation follows most of it, but not at the bottom of the "
|
||||
"image: the two targets closest to the camera, PB1_2 and PB2_2, keep part of the wave. The corr_y of PB2_2 (whose "
|
||||
"spot is partly covered, separate label) rises clearly from early morning to late morning, that of PB1_2 a little; "
|
||||
"the corr_x of PB1_2 dips at sunrise and in the morning, then comes back. Their raw positions move slightly away "
|
||||
"from the overall movement of the targets: a remainder of the camera movement that the compensation does not take "
|
||||
"at the nearest targets. The other targets keep nothing beyond the noise. Deduced cause: the mount or the lens of "
|
||||
"the camera heats up in the sun; according to the expert, the road hardly moves with temperature and the system "
|
||||
"compensates this movement well. Normal, nothing to do; the small morning wave of PB1_2 and PB2_2 is not a "
|
||||
"movement."))
|
||||
CORR[113] = dict(description=(
|
||||
"At the restart at sunrise, after the night outage, the camera nods down: its tilt rises, with its scale and its "
|
||||
"rotation, and all the raw positions, references included, move together in the image; the tilt is highest in early "
|
||||
"morning, goes below its night level in late morning and comes back to it in early afternoon, while the housing "
|
||||
"temperature rises. The compensation follows most of it, but the target closest to the camera, PB1_2, at the bottom "
|
||||
"of the image, keeps part of the wave: its corr_x goes down clearly just after sunrise, the most in early morning, "
|
||||
"and comes back in mid-morning; PB2_2, the next closest, goes down a little on corr_x in the middle of the morning. "
|
||||
"At the same hours their raw positions move away from the overall movement of the targets, the others do not: a "
|
||||
"remainder of the camera movement that the compensation does not take at the nearest targets. The sunlit kerb shows "
|
||||
"as a bright band next to PB1_2 on the 07:15 thumbnail, but it is still lit on the 10:00 one, when the curve is "
|
||||
"back: it does not explain the dip; the error_value of PB1_2 rises by day like those of PB2_2 and PB4, not more. "
|
||||
"Deduced cause: the mount or the lens of the camera heats up in the sun; according to the expert, the road hardly "
|
||||
"moves with temperature. Normal, nothing to do; the morning dip of PB1_2 is not a movement."))
|
||||
CORR[140] = dict(start="2026-10-02T05:15Z", description=(
|
||||
"At the restart at sunrise, after the night outage, the references PA1_2 and PA_8 are rejected together, then PA_8 "
|
||||
"alone at the next measurement: the basis changes and the corr_y of PA2_2, PB1_2, PB2_2 and PB_5 jump, PA2_2 "
|
||||
"strongly, then PA2_2 and PB2_2 on corr_x. PA_8 is then set aside at times in early morning, and continuously from "
|
||||
"08:00 to 12:45: PA_9 rises on corr_x, PB1_2 too, PA2_2 a little, in steps that follow the entries and exits of "
|
||||
"PA_8; at 12:45, all the references are lost together, PA3_2 and PB4 rejected, with no obstacle visible on the "
|
||||
"image. Everything comes back when PA_8 is taken again at 13:00. Cause: PA_8 poorly seen in daylight, like the day "
|
||||
"before, and at sunrise PA1_2 with it. The steps are not a movement: curves of PA_9, PB1_2, PA2_2, PB2_2 and PB_5 "
|
||||
"not to be trusted over the range."))
|
||||
CORR[151] = dict(description=(
|
||||
"A vehicle passes on the road, headlights and bodywork translucent on the 11:00 thumbnails: PA3_2 and PA_9 are "
|
||||
"rejected for the time of one measurement, with the reference R2, while PA_8 is set aside (separate label): the "
|
||||
"basis changes and PB2_2 and PB1_2 jump on corr_x, PA2_2 on corr_y. Everything comes back at the next measurement. "
|
||||
"The structure is not moving: point to ignore."))
|
||||
CORR[152] = dict(description=(
|
||||
"For the time of one measurement, PB1_2 and PB2_2 are rejected together: on their 12:00 thumbnails, a light "
|
||||
"silhouette passes translucent on the pavement, probably a passer-by. At the same measurement the reference PA1_2 is "
|
||||
"rejected too, while PA_8 is set aside (separate label): the basis changes and PA3_2 and PA2_2 jump a little on "
|
||||
"corr_y. Everything comes back at the next measurement. The structure is not moving: point to ignore."))
|
||||
CORR[168] = dict(end="2026-10-06T05:45Z", description=(
|
||||
"No measurement for any sensor during the night, until the first measurement of the morning. The station shuts down "
|
||||
"for lack of energy: just before the outage, the battery is at its lowest and the voltage below its usual night "
|
||||
"level, and the metrics stop with the measurements; it comes back at the end of the night with the compute board "
|
||||
"still cold (metrics), the first images a little before the first measurement. The curves are missing; nothing moves "
|
||||
"on the structure, but the station does not have enough energy to last the night: to be checked (battery, panel)."))
|
||||
|
||||
SUN = ("Cause seen: the low sun lights the background behind PA_8, as on the other mornings. The structure is not "
|
||||
"moving: {}.")
|
||||
NEW = [
|
||||
("2026-09-24T04:45Z", "2026-09-24T05:15Z", "Visibility",
|
||||
"At sunrise, the reference PA_8 is rejected for the time of one measurement, with its neighbour PA_9: on the 05:00 "
|
||||
"thumbnail, its spot is drowned in bright streaks, the low sun on the background behind it. Without PA_8 the basis "
|
||||
"changes: PA2_2, its neighbour, jumps on corr_x, the other targets barely. Everything comes back at the next "
|
||||
"measurement. " + SUN.format("point to ignore")),
|
||||
("2026-09-25T04:15Z", "2026-09-25T05:00Z", "Visibility",
|
||||
"At sunrise, the reference PA_8 and its neighbour PA_9 are rejected for two measurements: on the 04:30 thumbnail, "
|
||||
"the spot of PA_8 is drowned in the bright streaks of the low sun on the background. Without PA_8 the basis "
|
||||
"changes: PA2_2 jumps on corr_x, PB1_2 and PB_5 a little, then PB2_2 on corr_x and PA3_2 on corr_y. Everything "
|
||||
"comes back when PA_8 is taken again. " + SUN.format("points to ignore")),
|
||||
("2026-09-27T04:15Z", "2026-09-27T05:30Z", "Visibility",
|
||||
"At sunrise, the reference PA_8 is rejected for four measurements, PA_9 for three: on the 04:45 and 05:00 "
|
||||
"thumbnails, the spot of PA_8 is drowned in bright streaks of the low sun on the background, which fade by 05:30. "
|
||||
"Without PA_8 the basis changes: PA2_2 jumps on corr_x and corr_y, PA3_2 and PB_5 on corr_x. Everything comes back "
|
||||
"when PA_8 is taken again. " + SUN.format("points to ignore")),
|
||||
("2026-09-28T04:15Z", "2026-09-28T05:15Z", "Visibility",
|
||||
"At sunrise, the reference PA_8 is rejected for two measurements and PA_9 until 05:15: the basis changes and PA2_2, "
|
||||
"PA3_2, PB1_2 and PB2_2 shift a little on corr_x, PA2_2 on corr_y; at 04:30, PB4, left under its threshold, jumps "
|
||||
"clearly on corr_x and corr_y for that measurement alone; at 05:00, with PA_8 back just under its threshold, PA2_2 "
|
||||
"jumps the other way on corr_y. Everything comes back at 05:15. Cause deduced from the signature of the other "
|
||||
"mornings: PA_8 drowned in the low sun on its background at the same hour (thumbnails of 24/09, 25/09 and 27/09). "
|
||||
"The structure is not moving: points to ignore."),
|
||||
("2026-10-01T13:45Z", "2026-10-01T14:15Z", "Visibility",
|
||||
"The reference PA_8 is set aside again for the time of one measurement, after its long loss of the late morning "
|
||||
"(separate label): its spot is faint on the 14:00 thumbnail. The basis changes: PA2_2 and PB1_2 jump on corr_x, "
|
||||
"PA_9 and PA3_2 a little. Everything comes back at the next measurement. Cause: PA_8 poorly seen in daylight, as "
|
||||
"the same morning. The structure is not moving: point to ignore."),
|
||||
("2026-10-04T11:45Z", "2026-10-04T12:15Z", "Visibility",
|
||||
"The reference PA_8 is rejected for the time of one measurement: its spot is faint on the light background of the "
|
||||
"12:00 thumbnail. The basis changes: PA2_2 and PB1_2 jump on corr_x, PB_5 and PB2_2 a little. Everything comes back "
|
||||
"at the next measurement. Cause: PA_8 poorly seen in daylight, as on the previous days. The structure is not "
|
||||
"moving: point to ignore."),
|
||||
("2026-10-05T10:15Z", "2026-10-05T11:15Z", "Visibility",
|
||||
"The reference R1 is rejected for two measurements: its spot is fainter, under a dark band that thickens just above "
|
||||
"it (10:30 and 10:45 thumbnails, compared with 10:15); no vehicle is seen in front of it. Without R1 the basis "
|
||||
"changes: PB4 jumps on corr_x at 10:30, the other targets barely. At 11:00, R1 is back and a vehicle passes in "
|
||||
"front of PB4 and PA3_2, seen translucent with its lights on their thumbnails: they are rejected with PA_9 for that "
|
||||
"measurement, without effect on the other curves. Everything comes back at 11:15. Cause: R1 less well seen, of a "
|
||||
"nature not established (a shadow on its background is possible). The structure is not moving: points to ignore."),
|
||||
("2026-10-05T13:15Z", "2026-10-05T13:45Z", "Visibility",
|
||||
"The reference R1 is rejected alone for the time of one measurement: on the 13:30 thumbnail, its spot is much "
|
||||
"brighter and larger than at the other measurements, like that of R2: a capture brighter than usual, with no "
|
||||
"obstacle. Without R1 the basis changes: PB4 and PB_5 jump a little on corr_x. Everything comes back at the next "
|
||||
"measurement. The structure is not moving: point to ignore."),
|
||||
("2026-10-06T05:45Z", "2026-10-06T06:00Z", "Visibility",
|
||||
"At the first measurement after the night outage, at sunrise, the reference R2 is rejected with PB4: on the 05:45 "
|
||||
"thumbnail, bright streaks of the low sun surround R2. Without R2 the basis changes and PB_5 jumps on corr_x; it "
|
||||
"is back at the next measurement, R2 and PB4 still rejected there, as every morning at this hour. Cause seen: the "
|
||||
"low sun on the background of R2. The structure is not moving: point to ignore."),
|
||||
("2026-10-06T06:00Z", "2026-10-06T06:30Z", "No data",
|
||||
"The 06:15 measurement is missing for all the sensors, two measurements after the restart from the night outage "
|
||||
"(labelled separately). The station is running: an image exists at 06:17 and the metrics continue, the voltage "
|
||||
"normal for the hour. Cause not established. The curves miss one measurement; nothing to do."),
|
||||
("2026-10-06T08:00Z", "2026-10-06T08:30Z", "Visibility",
|
||||
"The reference PA_8 is rejected for the time of one measurement: its spot is very faint on the 08:15 thumbnail, "
|
||||
"sharp again at 08:30. Without PA_8, and with R3 taken at that measurement although usually rejected by day, the "
|
||||
"basis changes: PB1_2 jumps strongly on corr_x, PA2_2 and PA_9 clearly, PA_9 and PB1_2 a little on corr_y. "
|
||||
"Everything comes back at the next measurement. Cause: PA_8 poorly seen in daylight. The structure is not moving: "
|
||||
"point to ignore."),
|
||||
("2026-10-06T08:45Z", "2026-10-06T09:45Z", "Visibility",
|
||||
"The reference R1 is rejected for the time of one measurement: its spot is faint on the 09:00 thumbnail, without "
|
||||
"an obstacle. The basis changes: PB1_2 jumps strongly on corr_x, PB2_2 on corr_y and corr_x, PA3_2, PA2_2 and PB_5 "
|
||||
"on corr_x, PB1_2 and PA2_2 on corr_y. Everything comes back at 09:15, except PA3_2 and PA2_2, a little high on "
|
||||
"corr_x for one or two more measurements, back at 09:45. It falls just after the step of PB1_2 (separate label), "
|
||||
"which it does not change. Cause: R1 less well seen in daylight. The structure is not moving: points to ignore."),
|
||||
]
|
||||
|
||||
out = []
|
||||
for L in old:
|
||||
n = int(L["id"].replace(W, ""))
|
||||
if n in REMOVED:
|
||||
continue
|
||||
L = dict(L)
|
||||
L.pop("id")
|
||||
if n in CORR:
|
||||
L.update(CORR[n])
|
||||
L.pop("review", None)
|
||||
out.append(L)
|
||||
for s, e, f, d in NEW:
|
||||
out.append({"start": s, "end": e, "family": f, "description": d})
|
||||
out.sort(key=lambda L: (L["start"], L["end"]))
|
||||
with open(os.path.join(D, "labels.jsonl"), "w") as fh:
|
||||
for L in out:
|
||||
fh.write(json.dumps(L, ensure_ascii=False) + "\n")
|
||||
print(len(old), "old;", len(REMOVED), "removed;", len(CORR), "corrected;", len(NEW), "added;", len(out), "written")
|
||||
@@ -0,0 +1,42 @@
|
||||
"""corr_x, corr_y of chosen targets, one panel per target and column, y clipped to the 1st-99th percentile.
|
||||
|
||||
Usage: .venv/bin/python clipplot.py OUT.png START END SENSORS [--mm] [--labels F]
|
||||
--labels: grey band per label (family colour), only those longer than 2 h.
|
||||
"""
|
||||
import sys, json, statistics
|
||||
sys.path.insert(0, "tools/scripts")
|
||||
import data
|
||||
import matplotlib
|
||||
matplotlib.use("Agg")
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
out, a, b, sens = sys.argv[1], data.parse_time(sys.argv[2]), data.parse_time(sys.argv[3]), sys.argv[4].split(",")
|
||||
mm = "--mm" in sys.argv
|
||||
by = data.load("data/WILDSTRUBEL")
|
||||
cols = ("corr_x_mm", "corr_y_mm") if mm else ("corr_x", "corr_y")
|
||||
fig, axs = plt.subplots(len(sens), 2, figsize=(18, 2.2 * len(sens)), sharex=True, squeeze=False)
|
||||
labels = []
|
||||
if "--labels" in sys.argv:
|
||||
labels = [json.loads(l) for l in open(sys.argv[sys.argv.index("--labels") + 1])]
|
||||
colors = {"Visibility": "tab:blue", "Obstruction": "tab:orange", "Thermal displacement": "tab:red",
|
||||
"Displacement": "tab:green", "Target issue": "tab:purple", "No data": "grey"}
|
||||
for i, s in enumerate(sens):
|
||||
for j, c in enumerate(cols):
|
||||
ax = axs[i][j]
|
||||
ms = [m for m in by[s] if a <= m["t"] <= b and m[c] is not None]
|
||||
if not ms:
|
||||
continue
|
||||
v = sorted(m[c] for m in ms)
|
||||
lo, hi = v[int(0.01 * len(v))], v[int(0.99 * len(v)) - 1]
|
||||
pad = 0.15 * (hi - lo)
|
||||
ax.plot([m["t"] for m in ms], [m[c] for m in ms], ".-", ms=2, lw=0.5)
|
||||
ax.set_ylim(lo - pad, hi + pad)
|
||||
ax.set_ylabel(f"{s} {c}", fontsize=8)
|
||||
ax.grid(alpha=0.3)
|
||||
for L in labels:
|
||||
la, lb = data.parse_time(L["start"]), data.parse_time(L["end"])
|
||||
if (lb - la).total_seconds() > 7200 and lb > a and la < b:
|
||||
ax.axvspan(max(la, a), min(lb, b), color=colors.get(L["family"], "k"), alpha=0.12)
|
||||
fig.tight_layout()
|
||||
fig.savefig(out, dpi=80)
|
||||
print(out)
|
||||
@@ -0,0 +1,84 @@
|
||||
"""Per day and per target: what the daytime curves keep, outside the brief moments.
|
||||
|
||||
For each day D (04:00-16:00 UTC), each target, each column:
|
||||
- night level: median of accepted measurements from D-1 17:00 to D 04:00 (evening + night before),
|
||||
- 'clean' instants: those where the compensation keeps all its references except R3 (5 or 6 retained), that no
|
||||
label of --exclude covers (brief labels: passages, reference losses), accepted;
|
||||
- wave: max |median-of-5 smoothed (clean) - night level| in noises, and its instant;
|
||||
- agit: max |v - median of 4 clean neighbours each side| in noises (the fast part), and the count of clean points > 5;
|
||||
- night agit, same on the night measurements, for comparison.
|
||||
Usage: python3 days_dev.py EXCLUDE.jsonl [--maxdur 90]
|
||||
"""
|
||||
import json, sys, statistics
|
||||
from datetime import timedelta
|
||||
sys.path.insert(0, "tools/scripts")
|
||||
import data
|
||||
|
||||
S, E = data.parse_time("2026-09-23T17:00Z"), data.parse_time("2026-10-06T19:45Z")
|
||||
by = data.load("data/WILDSTRUBEL")
|
||||
refs = [s for s, ms in by.items() if data.is_reference(ms)]
|
||||
tg = [s for s, ms in by.items() if not data.is_reference(ms)]
|
||||
maxdur = int(sys.argv[sys.argv.index("--maxdur") + 1]) if "--maxdur" in sys.argv else 90
|
||||
excl = []
|
||||
for l in open(sys.argv[1]):
|
||||
L = json.loads(l)
|
||||
a, b = data.parse_time(L["start"]), data.parse_time(L["end"])
|
||||
if (b - a) <= timedelta(minutes=maxdur) or L.get("_force"):
|
||||
excl.append((a, b))
|
||||
# instants with refs other than R3 out
|
||||
bad = set()
|
||||
reft = {}
|
||||
for r in refs:
|
||||
for m in by[r]:
|
||||
if S <= m["t"] <= E and r != "R3" and (data.rejected(m) or m.get("inlier") in (0, None)):
|
||||
bad.add(m["t"])
|
||||
def covered(t):
|
||||
return any(a < t < b for a, b in excl)
|
||||
noise = {}
|
||||
W0, W1 = data.parse_time("2026-09-24T02:30Z"), E
|
||||
for s in tg:
|
||||
for c in ("corr_x", "corr_y"):
|
||||
v = [m[c] for m in by[s] if W0 <= m["t"] <= W1 and m[c] is not None]
|
||||
noise[s, c] = statistics.median(abs(b - a) for a, b in zip(v, v[1:]))
|
||||
|
||||
def agit(ser, nz):
|
||||
out = []
|
||||
for i, (t, v) in enumerate(ser):
|
||||
nb = [x for _, x in ser[max(0, i - 4):i] + ser[i + 1:i + 5]]
|
||||
if len(nb) >= 4:
|
||||
out.append((abs(v - statistics.median(nb)) / nz, t))
|
||||
return out
|
||||
|
||||
day = data.parse_time("2026-09-24T00:00Z")
|
||||
while day < data.parse_time("2026-10-07T00:00Z"):
|
||||
print(f"=== {day:%m-%d}")
|
||||
for s in tg:
|
||||
for c in ("corr_x", "corr_y"):
|
||||
nz = noise[s, c]
|
||||
ms = [m for m in by[s] if m[c] is not None]
|
||||
night = [m[c] for m in ms if day - timedelta(hours=7) <= m["t"] < day + timedelta(hours=4)]
|
||||
dser = [(m["t"], m[c]) for m in ms if day + timedelta(hours=4) <= m["t"] < day + timedelta(hours=16)
|
||||
and m["t"] not in bad and not covered(m["t"])]
|
||||
nser = [(m["t"], m[c]) for m in ms if day - timedelta(hours=7) <= m["t"] < day + timedelta(hours=4)
|
||||
and m["t"] not in bad and not covered(m["t"])]
|
||||
if len(night) < 3 or len(dser) < 5:
|
||||
lvl = None
|
||||
else:
|
||||
lvl = statistics.median(night)
|
||||
wave = ""
|
||||
if lvl is not None:
|
||||
sm = []
|
||||
for i in range(len(dser)):
|
||||
w = [v for _, v in dser[max(0, i - 2):i + 3]]
|
||||
sm.append((statistics.median(w) - lvl, dser[i][0]))
|
||||
mx = max(sm, key=lambda x: abs(x[0]))
|
||||
over = [t for d, t in sm if abs(d) / nz > 5]
|
||||
wave = f"wave {mx[0]/nz:+6.1f} @{mx[1]:%H:%M}" + (f" >5: {over[0]:%H:%M}-{over[-1]:%H:%M} ({len(over)})" if over else "")
|
||||
ag = agit(dser, nz)
|
||||
na = agit(nser, nz)
|
||||
agd = max(ag, default=(0, None))
|
||||
n5 = sum(1 for a, _ in ag if a > 5)
|
||||
agn = max(na, default=(0, None))
|
||||
print(f" {s:6s}{c[-1]} {wave:42s} agit day max {agd[0]:5.1f}"
|
||||
f"{'@'+format(agd[1],'%H:%M') if agd[1] else '':7s} n>5 {n5:2d}/{len(ag):2d} night max {agn[0]:4.1f} ({len(na)})")
|
||||
day += timedelta(days=1)
|
||||
@@ -0,0 +1,66 @@
|
||||
"""Every target measurement more than K own noises from its local level, grouped by instant, against the labels.
|
||||
|
||||
Noise: median |diff| of consecutive accepted measurements over the range (as ranges.py).
|
||||
Local level: median of the N accepted neighbours on each side, itself excluded (as ranges.py --rolling N).
|
||||
Output 1: per instant with at least one target > K: the targets and their signed deviation (noises), the
|
||||
references out (rejected r / inlier 0), and the labels covering it (start < t < end).
|
||||
Output 2: per label: the max deviation strictly inside, with its target and instant; '-' if none > K.
|
||||
Usage: python3 exceed.py LABELS.jsonl [--k 5] [--n 8] [--uncovered]
|
||||
"""
|
||||
import json, sys, statistics
|
||||
sys.path.insert(0, "tools/scripts")
|
||||
import data
|
||||
|
||||
K = float(sys.argv[sys.argv.index("--k") + 1]) if "--k" in sys.argv else 5
|
||||
N = int(sys.argv[sys.argv.index("--n") + 1]) if "--n" in sys.argv else 8
|
||||
S, E = data.parse_time("2026-09-24T02:30Z"), data.parse_time("2026-10-06T19:45Z")
|
||||
by = data.load("data/WILDSTRUBEL")
|
||||
for _ms in by.values(): # measurement instants to the minute, as the label bounds
|
||||
for _m in _ms:
|
||||
_m["t"] = _m["t"].replace(second=0, microsecond=0)
|
||||
refs = sorted(s for s, ms in by.items() if data.is_reference(ms))
|
||||
tg = sorted(s for s, ms in by.items() if not data.is_reference(ms))
|
||||
labels = [json.loads(l) for l in open(sys.argv[1])]
|
||||
for L in labels:
|
||||
L["a"], L["b"] = data.parse_time(L["start"]), data.parse_time(L["end"])
|
||||
|
||||
dev = {} # t -> list of (target, col, signed noises)
|
||||
for s in tg:
|
||||
for c in ("corr_x", "corr_y"):
|
||||
acc = [m for m in by[s] if m[c] is not None and S <= m["t"] <= E]
|
||||
v = [m[c] for m in acc]
|
||||
nz = statistics.median(abs(b - a) for a, b in zip(v, v[1:]))
|
||||
for i, m in enumerate(acc):
|
||||
nb = v[max(0, i - N):i] + v[i + 1:i + 1 + N]
|
||||
d = (v[i] - statistics.median(nb)) / nz
|
||||
dev.setdefault(m["t"], []).append((s, c[-1], d))
|
||||
|
||||
refout = {}
|
||||
for r in refs:
|
||||
for m in by[r]:
|
||||
if S <= m["t"] <= E and (data.rejected(m) or m.get("inlier") == 0):
|
||||
refout.setdefault(m["t"], []).append(r + ("r" if data.rejected(m) else "0"))
|
||||
|
||||
def cover(t):
|
||||
return [L.get("id", "new").replace("WILDSTRUBEL-", "") for L in labels if L["a"] < t < L["b"]]
|
||||
|
||||
if "--per-label" not in sys.argv:
|
||||
for t in sorted(dev):
|
||||
over = [(s, c, d) for s, c, d in dev[t] if abs(d) > K]
|
||||
if not over:
|
||||
continue
|
||||
cv = cover(t)
|
||||
if "--uncovered" in sys.argv and [x for x in cv if x not in sys.argv[sys.argv.index("--uncovered") + 1].split(",")]:
|
||||
continue
|
||||
over.sort(key=lambda x: -abs(x[2]))
|
||||
print(f"{t:%m-%d %H:%M} " + " ".join(f"{s}.{c}{d:+.1f}" for s, c, d in over)
|
||||
+ f" | refs out: {','.join(x for x in refout.get(t, []) if x != 'R3r') or '-'} | labels: {','.join(cv) or 'NONE'}")
|
||||
print("\n== per label: max |dev| strictly inside (rolling), n instants > K ==")
|
||||
for L in labels:
|
||||
ins = [(abs(d), s, c, d, t) for t in dev if L["a"] < t < L["b"] for s, c, d in dev[t]]
|
||||
if not ins:
|
||||
print(f"{L.get('id','new'):16s} {L['start'][5:16]} {L['end'][5:16]} {L['family'][:10]:10s} no measurement inside")
|
||||
continue
|
||||
mx = max(ins)
|
||||
n = len({t for a, s, c, d, t in ins if a > K})
|
||||
print(f"{L.get('id','new'):16s} {L['start'][5:16]} {L['end'][5:16]} {L['family'][:10]:10s} max {mx[1]}.{mx[2]} {mx[3]:+.1f} @{mx[4]:%m-%d %H:%M} instants>K {n}")
|
||||
@@ -0,0 +1,64 @@
|
||||
"""Per label: the deviation of each target's corr_x, corr_y inside the label, in its own noises.
|
||||
|
||||
Noise: median |diff| of consecutive accepted measurements over the whole range (as ranges.py).
|
||||
ref_edge: median of the accepted measurements just outside the label (up to N before start and N after end, both bounds
|
||||
excluded? no: bounds included, they are the 'point before' and 'point after').
|
||||
dev_edge: max |v - ref_edge| over measurements strictly inside (start, end).
|
||||
dev_roll: max |v - median of the 8 accepted neighbours on each side, itself excluded| strictly inside.
|
||||
Usage: python3 labeldev.py LABELS.jsonl [--n 4]
|
||||
"""
|
||||
import json, sys, statistics, os
|
||||
sys.path.insert(0, "tools/scripts")
|
||||
import data
|
||||
|
||||
START, END = data.parse_time("2026-09-24T02:30Z"), data.parse_time("2026-10-06T19:45Z")
|
||||
by = data.load("data/WILDSTRUBEL")
|
||||
targets = [s for s, ms in by.items() if not data.is_reference(ms)]
|
||||
win = {s: [m for m in by[s] if START <= m["t"] <= END] for s in targets}
|
||||
noise = {}
|
||||
for s in targets:
|
||||
for c in ("corr_x", "corr_y"):
|
||||
v = [m[c] for m in win[s] if m[c] is not None]
|
||||
noise[s, c] = statistics.median(abs(b - a) for a, b in zip(v, v[1:]))
|
||||
|
||||
def run(path, n=4, verbose=True):
|
||||
out = []
|
||||
for line in open(path):
|
||||
L = json.loads(line)
|
||||
a, b = data.parse_time(L["start"]), data.parse_time(L["end"])
|
||||
best = []
|
||||
for s in targets:
|
||||
ms = win[s]
|
||||
for c in ("corr_x", "corr_y"):
|
||||
acc = [m for m in ms if m[c] is not None]
|
||||
before = [m[c] for m in acc if m["t"] <= a][-n:]
|
||||
after = [m[c] for m in acc if m["t"] >= b][:n]
|
||||
inside = [m for m in acc if a < m["t"] < b]
|
||||
if not inside:
|
||||
continue
|
||||
ref = statistics.median(before + after) if before + after else None
|
||||
de = max(((abs(m[c] - ref), m["t"]) for m in inside), default=(0, None)) if ref is not None else (0, None)
|
||||
# rolling
|
||||
idx = {id(m): i for i, m in enumerate(acc)}
|
||||
dr = (0, None)
|
||||
for m in inside:
|
||||
i = idx[id(m)]
|
||||
nb = [x[c] for x in acc[max(0, i - 8):i] + acc[i + 1:i + 9]]
|
||||
d = abs(m[c] - statistics.median(nb))
|
||||
if d > dr[0]:
|
||||
dr = (d, m["t"])
|
||||
nz = noise[s, c]
|
||||
best.append((de[0] / nz, dr[0] / nz, s, c, de[1], dr[1]))
|
||||
best.sort(reverse=True)
|
||||
top = best[:3]
|
||||
out.append((L, top))
|
||||
if verbose:
|
||||
tag = L.get("id", "")
|
||||
print(f"{tag:16s} {L['start'][5:16]} {L['end'][5:16]} {L['family'][:12]:12s} " + " ".join(
|
||||
f"{s}.{c[-1]} e{de:.1f} r{dr:.1f}" for de, dr, s, c, *_ in top))
|
||||
return out
|
||||
|
||||
if __name__ == "__main__":
|
||||
n = int(sys.argv[sys.argv.index("--n") + 1]) if "--n" in sys.argv else 4
|
||||
print("noise:", {f"{s}.{c[-1]}": round(v, 4) for (s, c), v in noise.items()})
|
||||
run(sys.argv[1], n)
|
||||
@@ -0,0 +1,79 @@
|
||||
"""Per day: what each target's corr keeps of the morning camera wave, at clean instants, against a rest level.
|
||||
|
||||
Rest level: median of the accepted clean measurements of the night before (D-1 17:00 -> D 04:00) when it has >= 8,
|
||||
else of the evening of D (15:45 -> 21:00), else of its afternoon (12:45 -> 15:45, then compared up to it). Clean instant: all references retained except R3 (and the usual
|
||||
rejections of R3 only), not strictly inside a brief label (<= 90 min) of LABELS. Raw deviation in own noises
|
||||
(median |diff| over the range). Per target and column: max |raw dev| with instant, the longest run of
|
||||
consecutive clean points beyond K on the same side (start-end, n), and the error_value of the target by day vs
|
||||
by night (medians), to compare the targets.
|
||||
Usage: python3 thermal.py LABELS.jsonl [--k 5] [--day 2026-09-29]
|
||||
"""
|
||||
import json, sys, statistics
|
||||
from datetime import timedelta
|
||||
sys.path.insert(0, "tools/scripts")
|
||||
import data
|
||||
|
||||
K = float(sys.argv[sys.argv.index("--k") + 1]) if "--k" in sys.argv else 5
|
||||
S, E = data.parse_time("2026-09-24T02:30Z"), data.parse_time("2026-10-06T19:45Z")
|
||||
by = data.load("data/WILDSTRUBEL")
|
||||
for _ms in by.values(): # measurement instants to the minute, as the label bounds
|
||||
for _m in _ms:
|
||||
_m["t"] = _m["t"].replace(second=0, microsecond=0)
|
||||
refs = [s for s, ms in by.items() if data.is_reference(ms)]
|
||||
tg = sorted(s for s, ms in by.items() if not data.is_reference(ms))
|
||||
excl = []
|
||||
for l in open(sys.argv[1]):
|
||||
L = json.loads(l)
|
||||
a, b = data.parse_time(L["start"]), data.parse_time(L["end"])
|
||||
if b - a <= timedelta(minutes=90):
|
||||
excl.append((a, b))
|
||||
bad = set()
|
||||
for r in refs:
|
||||
if r == "R3":
|
||||
continue
|
||||
for m in by[r]:
|
||||
if data.rejected(m) or m.get("inlier") == 0:
|
||||
bad.add(m["t"])
|
||||
clean = lambda t: t not in bad and not any(a < t < b for a, b in excl)
|
||||
noise = {}
|
||||
for s in tg:
|
||||
for c in ("corr_x", "corr_y"):
|
||||
v = [m[c] for m in by[s] if S <= m["t"] <= E and m[c] is not None]
|
||||
noise[s, c] = statistics.median(abs(b - a) for a, b in zip(v, v[1:]))
|
||||
days = [data.parse_time(sys.argv[sys.argv.index("--day") + 1] + "T00:00Z")] if "--day" in sys.argv else \
|
||||
[data.parse_time("2026-09-24T00:00Z") + timedelta(days=i) for i in range(13)]
|
||||
for day in days:
|
||||
print(f"=== {day:%m-%d}")
|
||||
for s in tg:
|
||||
ms = by[s]
|
||||
ev_d = [m["error_value"] for m in ms if day + timedelta(hours=6) <= m["t"] < day + timedelta(hours=14) and m["error_value"] is not None]
|
||||
ev_n = [m["error_value"] for m in ms if day - timedelta(hours=4) <= m["t"] < day + timedelta(hours=3) and m["error_value"] is not None]
|
||||
for c in ("corr_x", "corr_y"):
|
||||
nz = noise[s, c]
|
||||
acc = [m for m in ms if m[c] is not None and clean(m["t"])]
|
||||
night = [m[c] for m in acc if day - timedelta(hours=7) <= m["t"] < day + timedelta(hours=4)]
|
||||
src = "night"
|
||||
if len(night) < 8:
|
||||
night = [m[c] for m in acc if day + timedelta(hours=15, minutes=45) <= m["t"] <= day + timedelta(hours=21)]
|
||||
src = "eve"
|
||||
if len(night) < 4:
|
||||
night = [m[c] for m in acc if day + timedelta(hours=12, minutes=45) <= m["t"] <= day + timedelta(hours=15, minutes=45)]
|
||||
src = "aft"
|
||||
if len(night) < 4:
|
||||
print(f" {s:6s}{c[-1]} no rest level"); continue
|
||||
lvl = statistics.median(night)
|
||||
ser = [(m["t"], (m[c] - lvl) / nz) for m in acc if day + timedelta(hours=4) <= m["t"] < day + timedelta(hours=15, minutes=45)]
|
||||
if not ser:
|
||||
continue
|
||||
mx = max(ser, key=lambda x: abs(x[1]))
|
||||
best, cur = (0, None, None), []
|
||||
for t, d in ser:
|
||||
if abs(d) > K and (not cur or (d > 0) == (cur[-1][1] > 0)):
|
||||
cur.append((t, d))
|
||||
else:
|
||||
cur = [(t, d)] if abs(d) > K else []
|
||||
if len(cur) > best[0]:
|
||||
best = (len(cur), cur[0][0], cur[-1][0])
|
||||
run = f"run {best[0]:2d} {best[1]:%H:%M}-{best[2]:%H:%M}" if best[0] else "run 0"
|
||||
evs = f"ev day {statistics.median(ev_d):.2f} night {statistics.median(ev_n):.2f}" if ev_d and ev_n else ""
|
||||
print(f" {s:6s}{c[-1]} [{src:5s}] max {mx[1]:+6.1f} @{mx[0]:%H:%M} {run:22s} n={len(ser):2d} {evs if c == 'corr_x' else ''}")
|
||||
Reference in new issue
Block a user