Skip to content

Python tool for aircraft Doppler audio geolocation using historical ADS-B flight data (Source-available)

Abstain when competing ridge paths reuse measured peaks (#279)

Cinna Davis5329d7e423f4
diff --git a/src/dopplergeist/confidence.py b/src/dopplergeist/confidence.py
index d6cb2bb..0583c11 100644
--- a/src/dopplergeist/confidence.py
+++ b/src/dopplergeist/confidence.py
@@ -60,6 +60,17 @@ def _possible_harmonic_overlap(events):
if span <= 0 or times[-1] - times[0] < 0.6 * span:
continue
x, y = (np.array([ridge[t] for t in times], dtype=float) for ridge in (a, b))
+ # Chunk paths can follow the same measured peak before branching.
+ # A reused sequence is not independent evidence, even when the
+ # later divergence fails the whole-ridge harmonic check below.
+ shared = x == y
+ starts = np.flatnonzero(np.convolve(shared, np.ones(5, dtype=int), mode="valid") == 5)
+ if len(starts):
+ start = int(starts[0])
+ return {"event_ids": [low["event_id"], high["event_id"]],
+ "ambiguity": "reused_ridge_observations", "harmonic_ratio": 1.0,
+ "aligned_samples": len(times), "shared_ridge_samples": int(shared.sum()),
+ "shared_run_start_s": times[start], "shared_run_end_s": times[start + 4]}
if np.median(x) > np.median(y):
low, high, x, y = high, low, y, x
with np.errstate(over="ignore", invalid="ignore", divide="ignore"):
@@ -247,7 +258,7 @@ def decide_location(events, candidates, coverage, *, matching_diagnostics=None,
diagnostics["independent_event_groups"] = None
diagnostics["possible_harmonic_overlap"] = possible_overlap
return result("insufficient_independent_events",
- "Overlapping matched ridges may be harmonics of one flyover; independent events are not established.")
+ "Overlapping matched ridges may describe one flyover; independent events are not established.")
if len(groups) < policy.min_independent_events and not (len(groups) == 1 and
policy.min_independent_events == 2 and known_clock):
return result("insufficient_independent_events", "Too few independent flyovers constrain location; harmonics count once.")
diff --git a/tests/test_real_harmonic_ambiguity.py b/tests/test_real_harmonic_ambiguity.py
index d79324c..ef932e2 100644
--- a/tests/test_real_harmonic_ambiguity.py
+++ b/tests/test_real_harmonic_ambiguity.py
@@ -36,3 +36,18 @@ def test_real_unflagged_group_pair_is_not_automatically_rejected():
assert len({event["harmonic_group_id"] for event in events}) >= 2
# Absence of a flag is not proof that these are independent aircraft.
assert _possible_harmonic_overlap(events) is None
+
+
+def test_real_shared_ridge_branch_does_not_establish_independence():
+ source = os.environ.get("DOPPLERGEIST_REAL_SHARED_RIDGE_SCAN")
+ if not source:
+ pytest.skip("set DOPPLERGEIST_REAL_SHARED_RIDGE_SCAN to the real ESID103 scan JSON")
+ events = [validate_event(event) for event in json.loads(Path(source).read_text())["events"]]
+ assert len(events) == 2 and events[0]["harmonic_group_id"] != events[1]["harmonic_group_id"]
+ flag = _possible_harmonic_overlap(events)
+ assert flag and set(flag["event_ids"]) == {event["event_id"] for event in events}
+ assert flag["ambiguity"] == "reused_ridge_observations"
+ assert flag["shared_ridge_samples"] == 8
+ assert flag["shared_run_start_s"] == 367.5
+ assert flag["shared_run_end_s"] == 369.5
+ assert _possible_harmonic_overlap(events[:1]) is None