# Modification **Verdict**: changed **Changed**: scripts/ranges.py **data.py**: unchanged ## What the analyst used - Tools: `inventory.py`, `ranges.py --rolling 8`, `days.py` (night levels, byhour), `overview.py --rigid` (29/09), `summary.py` (error_value, 1 h), `plot.py`, `thumbnails.py`, `metrics.py`. - Its own scripts, for a re-check of 94 existing labels against a "5 own noises" rule: - `exceed.py`: every target measurement more than K noises from its rolling level (the same computation as `ranges.py --rolling 8 --instants 1`), plus **the labels covering each instant** (to find the uncovered ones) and **per label, the largest deviation strictly inside** with the number of instants beyond K. It was the backbone of the 42 removals and 12 additions. - `labeldev.py`: the same per label, against the edge level as well (previous session). - `thermal.py`, `days_dev.py`: per day, the deviation of `corr` from the night level at "clean" instants (no reference lost except one named sensor, outside brief labels), with the longest run beyond K. - `clipplot.py`: `corr` in mm, 1st-99th percentile clipped, long labels shaded. `build_labels.py`: writes the file. - What it missed: no tool relates the `corr` deviations to a labels file. `quality.py --labels/--outside` does it only with the image quality metrics, which this station does not have. Its one documentation remark about the tools: measurement timestamps carry seconds, so comparing them with minute label bounds needs flooring. ## Diagnosis - Label check by `corr` deviation (the main task of a re-check, and of any search for forgotten labels on a station without quality metrics): no tool does it. Cause: `ranges.py` computes the deviations per instant but knows nothing of labels; `quality.py` knows labels but only reads quality metrics. The analyst rewrote the `ranges.py` computation in `exceed.py` and `labeldev.py` just to add the labels. - Seconds in the timestamps against minute label bounds: a script that compares them directly counts a measurement at a bound as inside. Same cause: no tool did the comparison, so each script had to deal with it. - Day-by-day thermal deviation at clean instants (`thermal.py`, `days_dev.py`): partly covered by `days.py --bounds` and `--smoothing`. Excluding instants with a lost reference is general, but it needs a new mode for `days.py`, and the "except R3" choice was specific to this station. ## What I decided - `ranges.py`: changed (S1). New option `--labels F`. It does what `exceed.py` did, with the computation `ranges.py` already has, so it works on any station. - `exceed.py`, `labeldev.py` (analyst): not added as scripts. `ranges.py --labels` replaces `exceed.py` (rolling level). `labeldev.py`'s edge level is close to `--rolling` with a small N and was a secondary column. - `thermal.py`, `days_dev.py` (analyst): left where they are. `days.py --bounds --smoothing` covers the per-day deviation from the night level. The "clean instants" filter (no reference lost) would be a new `days.py` mode, and this one range is not enough to design it: see "Not fixed". - `clipplot.py`: left. `plot.py` plus `corr_x_mm`/`corr_y_mm` covers it. The percentile clipping did not block the analyst. - `GUIDE.md`: left untouched, as the request requires (already modified by someone else). The guide text for the option is under "For the user to decide". - Removals: none. ## What changed - S1, commit `f5ff319` in tools, `scripts/ranges.py`: new option `--labels F` (one JSON per line with `start`, `end`, `family`, and `id` if present, numbered in file order). Docstring section 4 and usage line added. - With `--instants N`, each instant line ends with `| labels: ` or `| labels: none`. - After that, a "Per label" table: number, id, start, end, family, and the number of measurement instants strictly inside (start < instant < end, instant floored to the minute). Then the largest deviation inside, from the level (rolling if `--rolling`): sensor.column, signed in noises, instant. Last, the number of instants inside where a sensor is more than `--k` noises off. A label with no measurement inside says so. - Without `--labels`, the output is byte-identical to before. ## Why - A label re-check, or a search for forgotten labels on a station without quality metrics, asks two questions. What does each label hold beyond k noises? Which instants beyond k does no label cover? `ranges.py` already computed the deviations but could not answer either, so the analyst re-implemented it. The option answers both from the existing computation (`| grep 'labels: none'` lists the uncovered instants). - A measurement is compared with the bounds on its minute, strictly inside. A point at a bound (the point before or after) is not counted inside, even if its timestamp carries seconds. ## Checks - `python3 tools/scripts/ranges.py data/WILDSTRUBEL --columns corr_x,corr_y --rolling 8 --instants 1 --sensors PB1_2,PB2_2,PB4,PB_5,PA2_2,PA3_2,PA_9 --labels labeling/auto/analyses/WILDSTRUBEL_2026-09-24T0230_2026-10-06T1945/work/existing.jsonl --start 2026-09-24T02:30Z --end 2026-10-06T19:45Z` → `work/tools/ranges-labels-existing.txt`, 0.5 s. - It reproduces the analyst's `work/exceed.txt`. Same two uncovered instants (24/09 02:30 PB2_2 cx+12; 03/10 05:00 PB1_2 cy+44). Same per-label maxima and counts, e.g. WILDSTRUBEL-94 PB4.cx +16.6, -96 PB1_2.cx +27.6, -87 +2.3, -115 +5.4, -120 to -127 identical. -111 (No data): no measurement inside. - The same with `--min-measurements 6`, no `--instants`, on the final `labels.jsonl` (no `id`) → `work/tools/ranges-labels-new.txt`. The per-label table prints `-` for the id, exit 0. - No PNG (`ranges.py` makes none). - `python3 tools/scripts/quality.py --self-test`: ok. - Without `--labels`, the old and new `ranges.py` give byte-identical output on `--rolling 8` (the report's command) and on `--columns corr_x,corr_y --rolling 8 --instants 2` (with a fixed `PYTHONHASHSEED`, see "Not fixed"). Report commands rerun: 1 (`ranges.py --rolling 8` on the range → `work/ranges_roll8.txt`), no failure. ## For the user to decide - `GUIDE.md` must document the new option in the same change (tools `CLAUDE.md`), but the request forbids touching `GUIDE.md`, so the option is committed without its guide text. Proposed text to add to the guide (by whoever commits `GUIDE.md`): - usage line of `ranges.py`: add `[--labels F]` before `[--sensors A,B]`; - a bullet under `ranges`: "`--labels F` (one JSON per line, `start`, `end`, `family`, `id` if any): each line of `--instants` ends with the numbers of the labels that cover the instant (`labels: none` otherwise: `| grep 'labels: none'` lists the deviations no label holds); then, per label, the measurements strictly inside (start < instant < end, to the minute: a measurement at a bound is the point before or after), the largest deviation inside (sensor, column, noises, instant) and the number of instants beyond `--k`. To check a labels file against the curves: `--columns corr_x,corr_y --rolling 8 --instants 1 --sensors --labels F`." - Inside means strictly inside, on the minute, following the analyst's reading of the bounds (a label goes from the point before to the point after). `quality.py --labels` counts the bounds as inside. I kept the two tools apart rather than change `quality.py`. ## Not fixed - Day-by-day deviation from the night level at "clean" instants, with the longest run beyond k (`thermal.py`). It could become a `days.py --bounds` filter: drop the instants where a retained reference is lost. That is a new mode, and this range alone does not settle which references to ignore (here, one always rejected by day). Wait for a second analysis that needs it. - `ranges.py --instants`: the order of the "rejected" list changes from one run to the next (it is built from a set, and string hashing varies between runs). It existed before this change, and the values are unaffected. A one-line fix (iterate `names` then references in order) if wanted. ## Limits none ## Tools none ## Difficulties - The request forbids committing or reverting `GUIDE.md`, while the tools `CLAUDE.md` requires a new option to enter the guide in the same change. I committed the script alone and gave the guide text above. - The output folder already held another session's files (`modification.md`, `validation.md`, `tools/`). I only added `tools.md` and `work/`.