Python tool for aircraft Doppler audio geolocation using historical ADS-B flight data (Source-available)
Python acoustic-geolocationads-baircraft-trackingairplaneaudio-forensicsdoppler-effectdoppler-shiftgeolocationosintsignal-processing
Cover screening within real shared-clock scoring
Cinna Davis4e2e330afb90
diff --git a/tests/test_real_acoustic_screen.py b/tests/test_real_acoustic_screen.pyindex 4ea1ced..47d202b 100644--- a/tests/test_real_acoustic_screen.py+++ b/tests/test_real_acoustic_screen.py@@ -59,3 +59,60 @@ def test_real_ridge_rejections_have_supported_failing_witnesses():assert -fit["score"] > 3*sigmawitnessed += 1assert tested > 100 and witnessed > 0 and unsupported > 0+++def test_real_candidate_scores_match_full_fits_with_screening(monkeypatch):+ import math+ import random+ from types import SimpleNamespace++ import dopplergeist.acoustic_screen as screen+ import dopplergeist.matching as matching+ from dopplergeist.search import score_candidate++ source = os.environ.get("DOPPLERGEIST_REAL_CPA_FIXTURE")+ if not source:+ pytest.skip("set DOPPLERGEIST_REAL_CPA_FIXTURE to the real reference diagnostic")+ fixture = json.loads(Path(source).read_text())+ events, measurements = prepare_events(fixture["events"])+ candidates, _ = matching.association_candidates(pd.DataFrame(fixture["cpa_rows"]), events,+ max_candidates=20000)+ chosen = sorted(random.Random(20261103).sample(range(len(candidates)), 20))+ tracks = {track.id: track for track in FlightIndex(fixture["real_index"]).query(+ fixture["query_bounds"], fixture["query_time_s"])}+ point = SimpleNamespace(**fixture["point"], x=0., y=0.)++ @matching._cache_ridge_fits+ def run():+ return [score_candidate(candidates[i], point, tracks, events, measurements, mode="robust_ridge")+ for i in chosen]++ original = screen.ridge_trial_rejections+ with monkeypatch.context() as patch:+ patch.setattr(screen, "ridge_trial_rejections",+ lambda measurement, event, factors, emissions: np.zeros(len(factors), dtype=bool))+ baseline = run()+ witnessed = 0++ def checked(measurement, event, factors, emissions):+ nonlocal witnessed+ rejected = original(measurement, event, factors, emissions)+ sigma = _frequency_scale(event)+ fraction = event.get("quality", {}).get("source_drift_fraction", .02)+ for i in np.flatnonzero(rejected):+ fit = _fit_ridge_uncached(None, None, measurement, 0., event["f0_range_hz"], 343.,+ sigma, fraction, acoustic_result=(factors[i], emissions[i]))+ assert fit["support_fraction"] == 1. and math.isfinite(fit["score"])+ assert -fit["score"] > 3*sigma+ witnessed += 1+ return rejected++ with monkeypatch.context() as patch:+ patch.setattr(screen, "ridge_trial_rejections", checked)+ screened = run()+ assert witnessed > 0+ for before, after in zip(baseline, screened):+ before, after = dict(before), dict(after)+ before.pop("scoring_assessment", None)+ after.pop("scoring_assessment", None)+ assert json.dumps(before, sort_keys=True, allow_nan=True) == json.dumps(after, sort_keys=True, allow_nan=True)