diff --git a/scripts/categories.py b/scripts/categories.py index 79bc7f5..09b7bdd 100644 --- a/scripts/categories.py +++ b/scripts/categories.py @@ -25,7 +25,6 @@ from pathlib import Path HERE = Path(__file__).resolve().parent sys.path[:0] = [str(HERE), str(HERE.parents[1] / "aimsight-tools" / "scripts")] from common import targets # noqa: E402 -from displacement import JUMP_BACK # noqa: E402 from data import iso, load # noqa: E402 DETECTORS = ("displacement", "no_data", "target_issue", "thermal_displacement", "visibility") @@ -39,6 +38,7 @@ CATEGORIES = { "No data": {"ignore": False, "process": "none"}, "Displacement": {"ignore": False, "process": "check"}, } +JUMP_BACK = "Sudden jump, back to normal" # the label of displacement.py MERGE = timedelta(hours=1) diff --git a/scripts/visibility.py b/scripts/visibility.py index bfb91ee..5c28c9e 100644 --- a/scripts/visibility.py +++ b/scripts/visibility.py @@ -1,5 +1,5 @@ """Visibility family: the camera sees the targets less well (error_value), or the air trembles (heat shimmer). The same -error_value also finds objects in front of a few targets: Obstruction family (Brief obstruction, Target obscured). +error_value also finds something passing in front of a few targets: Brief obstruction (Obstruction family). 1. High measurement: error_value above the median of its sensor + K_MAD MAD and above FACTOR times that median. 2. Brief obstruction (one instant): at least BRIEF_MIN sensors high, SALIENCE times more than at each neighbouring instant @@ -11,8 +11,6 @@ error_value also finds objects in front of a few targets: Obstruction family (Br 4. Diffuse nuisance: at least RUN_MIN instants in a row where the median over the sensors of the error_value, in MAD above each one's median, reaches K_DIFFUSE: Poor visibility "reduced", unless within heat shimmer or another Poor visibility. -5. Target obscured: a target rejected above K_TARGET MAD at least TARGET_MIN times, less than TARGET_GAP apart, mostly - outside the episodes above (leaves, snow, glare on one target). Heat shimmer: end of file. """ import statistics @@ -29,12 +27,8 @@ BRIEF_MIN = 3 # trains of E-005: 5 to 17 sensors SALIENCE = 3 # a train stands out (E-005: 5 to 17 against 0 to 2); the cobweb of E-002 varies from 2 to 9 HALF = 0.5 # "nothing is seen": NORDEND 09.10 23:00 (68 % rejected) against the rain of E-005 (24 to 33 %) K_DIFFUSE = 2.5 # wf-improve Visibility, mod. 1, S2 (JUNGFRAU, FLORIDA, NORDEND: the whole scene less clear) -K_TARGET = 5 # leaves of E-005: 6 to 25 MAD, rejected -TARGET_MIN = 3 -TARGET_GAP = timedelta(hours=6) # leaves of E-005: 7 rejections in 12 h, up to 5 h apart BRIEF = "Something passed in front of {} for a single measurement. Ignore this point on the curves." -OBSCURED = "{} was hidden several times while the targets around it stayed clear. Ignore its curve in this period." def _levels(measurements, instants): @@ -61,7 +55,7 @@ def detect(measurements): refs = {s for s, v in measurements.items() if is_reference(v)} instants = sorted({m["t"] for v in measurements.values() for m in v}) z = {} # t -> {sensor: error_value in MAD above the sensor's median} - high, strong, rejected, repeated = {}, {}, {}, {} # t -> {sensors}; repeated: target -> [t] + high, strong, rejected = {}, {}, {} # t -> {sensors} for s, v in measurements.items(): e = [m["error_value"] for m in v if m["error_value"] is not None] if len(e) < 10: @@ -78,8 +72,6 @@ def detect(measurements): rejected.setdefault(t, set()).add(s) if x > FACTOR * med: strong.setdefault(t, set()).add(s) - if s not in refs and x > med + K_TARGET * mad: - repeated.setdefault(s, []).append(t) n = lambda t: len(high.get(t, ())) # noqa: E731 out, briefs = [], set() @@ -119,12 +111,6 @@ def detect(measurements): e = _poor(r[0], r[-1], {s for t in r for s, x in z[t].items() if x >= K_DIFFUSE}, "reduced", refs) if len(r) >= RUN_MIN and not any(h["start"] <= e["start"] and e["end"] <= h["end"] for h in hosts): out.append(e) - - seen = lambda t: t in briefs or any(a <= t <= b for a, b, _ in zones) # noqa: E731 - for s, ts in repeated.items(): # 5. Target obscured - for r in runs(ts, TARGET_GAP): - if len(r) >= TARGET_MIN and 2 * sum(map(seen, r)) < len(r): - out.append(episode(r[0], r[-1], "Obstruction", "Target obscured", OBSCURED.format(s), [s], True)) return out + shimmer