Files
aimsight-detectors/scripts/obstruction.py
T
maximeandClaude Opus 5.5 5e9a7aa9d1 The single reader: data.py of the tools repository (sibling ~/aimsight-tools), located once in categories.py
scripts/data.py removed; the detectors' standalone CLIs go (categories.py runs them).
Benchmark identical to the baseline.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 15:25:01 +01:00

27 lines
1.6 KiB
Python

"""Detector of the Obstruction family (the families document): an object hides one or a few targets, for an instant or
for long. It reuses two computations shared with other families:
- the error_value of visibility.py: Brief obstruction (something passing, one instant) and Target obscured (a target
rejected again and again while the others stay seen, or a nuisance that only touches a few targets, no reference);
- the day-by-day rejections of target_issue.py: a target rejected for less than a week, Target obscured.
A sensor already in an overlapping Target issue episode (Degraded target, Target stuck) is not returned as Obstruction:
its curve is already to be ignored, the family is Target issue (boundary "Target issue or an episode of another family"
of the families document; wf-improve session Obstruction, mod. 1: S1, problem targets of FLORIDA, NORDEND, SNCF01,
NIEDERHORN, JUNGFRAU, CLARIDEN cut into Target obscured; S3, their isolated rejections as Brief obstruction).
"""
import target_issue
import visibility
def detect(measurements):
ti = target_issue.episodes(measurements)
issues = [e for e in ti if e["kind"] == "Target issue"]
out = []
for e in visibility.episodes(measurements) + ti:
if e["kind"] != "Obstruction":
continue
taken = {s for h in issues if h["start"] <= e["end"] and h["end"] >= e["start"] for s in h["sensors"]}
if (e := {**e, "sensors": [s for s in e["sensors"] if s not in taken]})["sensors"]: # minus the sensors
out.append(e) # already in Target issue
return sorted(out, key=lambda e: e["start"])