sessions of 2026-11-18 (the optimization campaign; three runs without summary, interrupted and rerun)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
maximeandClaude Opus 5.5 committed 2026-11-18 17:47:59 +01:00
1 parent 8a81c53cd9
commit 0cfbd1b7bc
363 files changed
+30822

No files matched your search

@@ -0,0 +1,156 @@
# Modification
**Verdict**: changed
**Changed**: scripts/displacement.py, scripts/no_data.py, scripts/categories.py, thresholds.md
## Diagnosis
JUNGFRAU, 2026-09-30 → 2026-11-02 (labels up to 2026-11-01T00:00Z), cadence 15 min, 12 targets, 3 references. The range score before, per instant:
| Family | labelled | found | flagged | wrongly |
|---|---|---|---|---|
| Displacement | 0 | 0 | 3100 | 3100 |
| No data | 29 | 6 | 6 | 0 |
| Obstruction | 1 | 1 | 308 | 307 |
| Perturbation | 2 | 1 | 265 | 264 |
| Target issue | 3005 | 3005 | 3100 | 95 |
| Thermal displacement | 2593 | 2296 | 2748 | 452 |
| Visibility | 762 | 480 | 503 | 23 |
- **Extra, Slow drift 09-27 → 11-01 on BJ_G, BL_C, PBJ_C, PM_D (no label; 3100 wrong instants)**: `displacement.drift` / `_whole`. Over the whole window the daily levels of corr_y of all the bridge targets rise with the autumn cooling (2.25 to 2.92 daily amplitudes for the four flagged), but they go back and forth with the weather on the way: the level falls back from its furthest point by 0.39 to 0.56 of the whole drift. The labels give only the daily Thermal displacement waves there. `_whole` checked only the size and the largest day-to-day step, not whether the level wanders back (fixed, S1).
- **Missed, 12 No data labels of a single measurement missing for all sensors (JUNGFRAU-9, 10, 11, 17, 19, 29, 32, 44, 49, 54, 62, 88)**: `no_data.MISSING` = 1 needed two missing steps. The same single-measurement labels exist at CLARIDEN, FLORIDA, LENZSPITZE, NIEDERHORN, NORDEND, SNCF01 and WILDSTRUBEL (fixed, S2).
- **Extra, Perturbation 10-08 07:15 → 10-10 12:30 on BJ_C, BL_C, PM_C (about 210 wrong instants)**: the jump starts one measurement after the end of a Heat shimmer episode (10-07 20:00 → 10-08 07:00, inside label JUNGFRAU-111 Visibility). Its level before is the median of the 4 measurements before it, read inside the episode. So the "jump" is the curve coming out of the nuisance. The overlap test in `categories.host` missed it by 15 min (fixed, S3).
- **Extra, Perturbation one-measurement jumps of all 12 targets** (10-01 12:00, 10-02 21:30, 10-06 22:30, 10-15 09:15, 10-21 23:45; 10-21 13:00 inside JUNGFRAU-114 Visibility; 10-06 06:00 is JUNGFRAU-22, the truck, also flagged Obstruction): `displacement` `K_TOGETHER`. Small common shifts of the base that are not labelled, except 10-21 13:00, where Visibility is the right family. Not fixed.
- **Extra, Perturbation 10-19 10:15 → 20:00 (BJ_D, BJ_G) and 10-16 10:30 → 11:15 (PM_D)**: jumps measured against a level read before a No data hole (JUNGFRAU-104, JUNGFRAU-52). Not fixed.
- **Wrong family, Target obscured PM_C 10-18 12:00 → 10-20 23:15 (about 270 instants)**: `target_issue`. PM_C is rejected for three days of rain (JUNGFRAU-103, 105, 106 Visibility). The boundary says rejections that come only with rain go to that condition's family, but target_issue cannot see the weather. Not fixed.
- **Wrong family, Brief obstruction of REF_G / REF_D at night** (10-15 01:45 → 06:15, 10-26 02:45 → 06:00, 10-27 01:15 → 06:45, 10-28 03:15 → 04:30): references lost during the night visibility drops (JUNGFRAU-101, 82, 86, 91 Visibility). The families document says: "a reference right at its threshold, with nothing in front of it, … Visibility". The Poor visibility event is also found there, so only the Obstruction instants are wrong. Not fixed.
- **Missed or partial, Visibility (found 63 %)**: the small one-measurement jumps on corr_x near 15:30 to 16:15 (JUNGFRAU-20, 37, 45, 50, 55, 72, 89) and the references seen less well at night without rejection (JUNGFRAU-7, 39, 57, 116, 118). These are faint and do not stand out of the detectors' thresholds. Not fixed.
- **Extra, Lasting shift BJ_C 10-25 16:45 and BJ_C, BJ_G 10-28 08:15** (2 instants): jumps on the edge of a visibility loss (JUNGFRAU-79, 91). Not fixed (2 instants).
- **Correct**: Target issue PM_G (JUNGFRAU-2); No data 10-15 22:45 → 10-16 10:30, 10-19 08:45 → 10:15, 10-26 14:15 → 15:00; Obstruction JUNGFRAU-22 (truck, 10-06 06:00); the Poor visibility episodes of JUNGFRAU-101, 103, 106, 109, 111, 79, 82, 86, 91 (bounds a little short); the daily Thermal displacement (camera thermal expansion and contraction, all sensors), 89 % found. The tails of the waves cut short are a question of bounds, not a defect.
## What changed
- **S1** (`98ba7c9`), `scripts/displacement.py` `_whole` and `thresholds.md`: new constant `RETREAT = 1 / 3`. A whole-window slow drift also needs its largest retreat to stay at or under `RETREAT` × the drift. The retreat is how far the daily level falls back from its furthest point so far, against the drift's direction. Added to the drift comment block and as a new line in `thresholds.md`. 3 code lines, 1 constant.
- **S2** (`be92f2d`), `scripts/no_data.py` and `thresholds.md`: `MISSING` 1 → 0.5. A gap above 1.5 steps, so one measurement missing for all sensors, is now a No data hole. Docstring and `thresholds.md` line updated.
- **S3** (`4063174`), `scripts/categories.py` `host` (and the `MERGE` line of `thresholds.md`): a jump back to normal now also joins a Visibility episode that ended less than `MERGE` (1 h) before its start. Before, the jump had to overlap the episode. No new constant; the module docstring is updated.
- **S4** (`0cca2a0`), `scripts/categories.py` `host`, pruning: removed the rule "a slow drift joins an overlapping Target issue episode". `host` now only places jumps back. The docstring line is removed.
## Why
- S1: a seasonal thermal trend moves the daily level of the corrected curves over a month, and it goes back and forth with the weather. A real slow drift (a camera tilting, a structure settling) goes back only a little. Checking the size and the day-to-day step alone flagged the seasonal wandering as a Displacement over the whole window.
- S2: a single measurement missing for all sensors is labelled No data on most stations. The detector needed two missing measurements in a row. Half a step of margin still keeps out timestamp jitter: gaps between 1 and 1.5 steps occur at NORDEND (6) and SNCF01 (1).
- S3: a jump is measured against the median of the measurements just before it. When those fall inside a visibility loss, the curve coming back out of the nuisance looks like a jump that "comes back" much later. That gives a long, false Perturbation, which the exact-overlap test did not hand to the Visibility event.
- S4: the slow-drift rule in `host` changed no figure of the benchmark, so it was removed (the simple-first rule).
## Checks
- events (JUNGFRAU): the Slow drift event 09-27 → 11-01 is gone (S1); 13 No data events are added at the single missing measurements (S2); the Perturbation 10-08 07:15 → 10-10 12:30 is gone, absorbed by the Heat shimmer 10-07 20:00 → 10-08 07:00 (S3); one jump moves from one Visibility event to another nearby. Full lines in "Before / after on the range". No `skipped` line in any output.
- sensors: the same events removed or added; the sensors of the other events are unchanged.
- range: Displacement correct 0/3100 → 0/2; No data found 6/29 → 29/29, correct 6/6 → 29/37; Perturbation found 1/2 → 0/2, correct 1/265 → 0/53; the other families unchanged.
- benchmark: 0 regressions at each step (S1 to S4 against the previous state) and over the whole against the benchmark before; see "Benchmark".
## Pruning
Each rule of the touched detectors was tried without it, on a copy, with the benchmark compared against the last committed state (S3):
- `categories.host`, "a slow drift joins an overlapping Target issue": no figure changes → **removed, S4 (`0cca2a0`)**.
- `displacement._whole`, the step condition (`step <= abs(d) / 2`): kept. Without it: CLARIDEN Displacement correct 42 → 35 % (713 instants), Total Displacement correct 57 → 48 %.
- `displacement._whole`, the size condition (`SIZE`): kept. Without it: Total Displacement correct 57 → 28 % (7638 instants).
- `displacement.drift`, the pieces (`_pieces`, `PIECE`): kept. Without them: CLARIDEN Displacement found 100 → 0 % (1421), MICHIGAN found 100 → 0 % (27), Total Displacement found 98 → 66 %.
- `displacement._days`, `HOURS` (any day counted): kept. Without it: Total Displacement correct 57 → 56 % (175 instants), WILDSTRUBEL correct 29 → 26 % (316 instants).
- `no_data`, `MISSING` (a hole is any gap above one step): no benchmark regression (WILDSTRUBEL No data correct 70 → 69 %, 1 instant), but **not removed**. Gaps between 1 and 1.5 steps from timestamp jitter exist at NORDEND (6) and SNCF01 (1), and would become No data events of a few minutes. The application also passes the window end, where a last measurement one minute early would make a hole "up to the end". The benchmark does not see either. See "For the user to decide".
- `displacement._whole`, `RETREAT`: this is the fix itself. Benchmark identical from 0.25 to 0.38; at 0.4 JUNGFRAU's drift comes back; at 0.2 and below, WILDSTRUBEL Displacement found 94 → 0 % (499 instants).
## Before / after on the range
Events check, changed lines (before `<`, after `>`):
```
< 2026-09-27T00:00Z → 2026-11-01T23:45Z Displacement kept | Slow drift | 4 sensors | absorbed: Slow drift 09-27T00:00, Slow drift 09-27T00:00, Slow drift 09-27T00:00
> 2026-10-02T11:15Z → 2026-10-02T13:45Z No data kept | No data | all sensors | absorbed: No data 10-02T12:00, No data 10-02T13:15
> 2026-10-05T06:00Z → 2026-10-05T06:30Z No data kept | No data | all sensors | absorbed: —
> 2026-10-05T10:30Z → 2026-10-05T11:00Z No data kept | No data | all sensors | absorbed: —
< 2026-10-08T07:15Z → 2026-10-10T12:30Z Perturbation greyed | Sudden jump, back to normal | 3 sensors | absorbed: Sudden jump, back to normal 10-08T07:15, ...
> 2026-10-09T11:45Z → 2026-10-09T12:15Z No data kept | No data | all sensors | absorbed: —
> 2026-10-10T10:30Z → 2026-10-10T11:00Z No data kept | No data | all sensors | absorbed: —
> 2026-10-14T09:15Z → 2026-10-14T09:45Z No data kept | No data | all sensors | absorbed: —
> 2026-10-15T09:30Z → 2026-10-15T10:00Z No data kept | No data | all sensors | absorbed: —
> 2026-10-16T13:30Z → 2026-10-16T14:00Z No data kept | No data | all sensors | absorbed: —
> 2026-10-19T20:30Z → 2026-10-19T21:30Z No data kept | No data | all sensors | absorbed: No data 10-19T21:00
> 2026-10-27T08:45Z → 2026-10-27T09:15Z No data kept | No data | all sensors | absorbed: —
> 2026-11-01T10:45Z → 2026-11-01T11:15Z No data kept | No data | all sensors | absorbed: —
> 2026-11-01T13:00Z → 2026-11-01T13:30Z No data kept | No data | all sensors | absorbed: —
```
The Heat shimmer 10-07 20:00 → 10-08 07:00 now also absorbs the jumps of 10-08 07:15. The jump of 10-21 00:45 moves from the Heat shimmer to the Poor visibility 10-20 16:30 → 10-21 00:30, and the jump of 10-25 17:15 from the Poor visibility of 10-26 to the Heat shimmer 10-24 22:00 → 10-25 17:00: same family, same instants.
Range score, before → after:
| Family | found | correct |
|---|---|---|
| Displacement | — → — | 0/3100 (0 %) → 0/2 (0 %) |
| No data | 6/29 (21 %) → 29/29 (100 %) | 6/6 (100 %) → 29/37 (78 %) |
| Obstruction | 1/1 (100 %) → same | 1/308 (0 %) → same |
| Perturbation | 1/2 (50 %) → 0/2 (0 %) | 1/265 (0 %) → 0/53 (0 %) |
| Target issue | 3005/3005 (100 %) → same | 3005/3100 (97 %) → same |
| Thermal displacement | 2296/2593 (89 %) → same | 2296/2748 (84 %) → same |
| Visibility | 480/762 (63 %) → same | 480/503 (95 %) → same |
The Perturbation found 1/2 before was by accident: label JUNGFRAU-112 (10-09 00:45 → 01:15) fell inside the false 10-08 → 10-10 jump. Of the 8 No data instants now flagged without a label, 4 are on 11-01, past the end of the labels (the labels stop at 11-01T00:00Z, the range runs to 11-02). The rest come from the merge of the three holes of 10-02 11:15 → 13:45 into one event (`MERGE`), which covers the measurements between JUNGFRAU-9, 10 and 11.
## Benchmark
```
CLARIDEN No data found 62 → 100 %
FLORIDA No data found 29 → 100 %
FLORIDA No data correct 100 → 91 % (2 instants lost)
JUNGFRAU No data found 21 → 100 %
JUNGFRAU No data correct 100 → 88 % (4 instants lost)
JUNGFRAU Perturbation found 50 → 0 % (1 instants lost)
JUNGFRAU Perturbation correct 1 → 0 % (-115 instants lost)
LENZSPITZE No data found 68 → 100 %
LENZSPITZE No data correct 52 → 56 %
MICHIGAN Displacement correct 16 → 17 %
NIEDERHORN No data found 8 → 100 %
NORDEND No data found 38 → 100 %
SNCF01 No data found 40 → 100 %
SNCF01 No data correct 63 → 73 %
Total Displacement correct 41 → 57 %
Total No data found 45 → 100 %
Total No data correct 77 → 83 %
Total Perturbation found 11 → 10 % (1 instants lost)
Total Perturbation correct 2 → 3 %
WILDSTRUBEL No data found 76 → 100 %
WILDSTRUBEL No data correct 74 → 70 % (5 instants lost)
WILDSTRUBEL Perturbation correct 14 → 17 %
0 regression(s); complexity: 602 code lines, 45 constants → 607 code lines, 46 constants
```
## For the user to decide
- S2 goes further than an earlier user's rule: `MISSING` was 2 (user's rule 2026-10-23), then 1 (ALASKA 2026-11-04, S1), and is now 0.5. One measurement missing for all sensors becomes a No data event. The labels of 8 stations retain these holes (JUNGFRAU-9, 10, 11, 17, 19, 29, 32, 44, 49, 54, 62, 88 here, and the same kind at CLARIDEN, FLORIDA, LENZSPITZE, NIEDERHORN, NORDEND, SNCF01, WILDSTRUBEL). The families document says "a missing point alone, filtered by the station, is not one", which I read as one sensor's point, not all sensors.
- Pruning: the removal of `MISSING` (any gap above one step is a hole) makes no benchmark regression, but I did not commit it, because the timestamp jitter would make short false No data events (NORDEND 6, SNCF01 1, and at the window end in the application).
- `RETREAT` = 1/3: the benchmark plateau is narrow, 0.25 (the labelled drift of WILDSTRUBEL PB2_2) to 0.38 (JUNGFRAU's wandering starts at 0.39). A third sits in the middle; a later station could fall on either side.
## Not fixed
- The one-measurement Perturbation jumps of all 12 targets (10-01 12:00, 10-02 21:30, 10-06 22:30, 10-15 09:15, 10-21 23:45; about 50 instants): small unlabelled base shifts. Raising `K_TOGETHER` would cut the labelled reference shifts of ALASKA (thresholds.md: at 8, half the gain).
- Perturbations after a No data hole (10-16 10:30, 10-19 10:15 → 20:00): the level before is read across the hole. A rule like S3 for holes would need its own benchmark trial; it did not fit in this session.
- Target obscured PM_C 10-18 → 10-20 during the rain (Visibility labels JUNGFRAU-103, 105, 106), and the Brief obstructions of REF_G / REF_D during the night visibility losses (JUNGFRAU-101, 82, 86, 91): another family than the labels. Turning an Obstruction inside a Poor visibility into Visibility would touch the many Obstruction labels of NORDEND and WILDSTRUBEL, where things pass in front of targets in bad weather too. Not tried.
- The faint Visibility labels (one-measurement corr_x jumps near 16:00, references seen less well at night without rejection): under every threshold of `visibility`.
- The two Lasting shift instants (10-25 16:45, 10-28 08:15): 2 instants.
## Limits
- The seasonal trend of JUNGFRAU (corr_y of the bridge targets rising with the autumn cooling) is Thermal displacement for the labels. The families boundary decides it by "the same position at equal temperature", which the detectors cannot test: `detect(measurements)` does not receive the housing temperature (`data.load_temperature` exists in the tools repository). S1 tells a wandering trend from a steady one, not a thermal one from a mechanical one. A steady seasonal trend would still be flagged. A real fix would pass the temperature to the drift detector and compare the levels at equal temperature (a contract change).
- PM_C rejected only while it rains, and references lost at night: rain and the absence of an object are seen on the images and the weather files, not in the measurements the detectors read.
- No label is said to be wrong by the context document (report: JUNGFRAU-2 kept as is).
## Tools
- `sessions/JUNGFRAU_2026-09-30T0000_2026-11-01T0000_20261118T1153Z/tools/labels.py`: lists the labels of a JSONL file touching a range (`labels.jsonl FROM TO [width]`). Worth keeping.
- `sessions/JUNGFRAU_2026-09-30T0000_2026-11-01T0000_20261118T1153Z/tools/drift.py`: per target and axis, the whole-window slow-drift figures of `displacement.py` (drift, daily amplitude, step, retreat / drift, residuals), `detectors_dir station_dir FROM TO [--flagged] [--levels]`. Worth keeping for any drift question.
- `sessions/JUNGFRAU_2026-09-30T0000_2026-11-01T0000_20261118T1153Z/tools/steps.py`: per station, the gaps between instants in steps of the cadence (jitter, single missing, holes), `data_dir STATION...`. It fails on a station without measurements (it stopped at SUSTENHORN). Worth keeping, with a guard for empty stations.
## Difficulties
- While exploring, the `RETREAT` variant was patched into a scratch copy with an inline heredoc Python, and later variants with `sed` one-liners, instead of a script in `tools/`. Only scratch copies in the working folder were touched, and the committed code was written by hand.
- `steps.py` crashed on SUSTENHORN (no measurements: `cadence` takes a median of nothing); the stations before it were enough.