Python tool for aircraft Doppler audio geolocation using historical ADS-B flight data (Source-available)
Python acoustic-geolocationads-baircraft-trackingairplaneaudio-forensicsdoppler-effectdoppler-shiftgeolocationosintsignal-processing
Update
Cinna Davisb17476245af6
diff --git a/src/dopplergeist/pipeline.py b/src/dopplergeist/pipeline.pyindex cea2b71..954ac84 100644--- a/src/dopplergeist/pipeline.py+++ b/src/dopplergeist/pipeline.py@@ -97,6 +97,20 @@ def _score_chunk(chunk):state["measurements"],state["parameters"],state["origin"])+def _enforce_location_policy(rows, output_dir):+ from .region_policy import RegionPolicyUnavailable, ResultRegionPolicy, redact_location_outputs++ try:+ policy = ResultRegionPolicy()+ restricted = any(policy.restricted_region(row["lat"], row["lon"]) is not None for row in rows)+ except RegionPolicyUnavailable:+ redact_location_outputs(output_dir)+ raise ValueError("The result could not be checked against the configured regional boundaries.") from None+ if restricted:+ redact_location_outputs(output_dir)+ raise ValueError("The result falls within a restricted region.")++def _validated_scoring_chunk(chunk):"""Reject invalid chunk sizes before scoring or producing artifacts."""if type(chunk) is not int or chunk < 1:@@ -335,6 +349,7 @@ def run(config_path,output_dir):"reported_trials":reported,"unknown_candidates":unknown})return sorted(ranked,key=lambda row:row["score"],reverse=True)ranked=rank(candidates,points,"grid-scoring")+ _enforce_location_policy(ranked, output)dump(output/"ranked-grid.json",ranked)# Refine the best location from each flight combination rather than spending# every refinement slot on neighbouring points of the winning combination.@@ -353,6 +368,7 @@ def run(config_path,output_dir):best_pairs={}for row in ranked:best_pairs.setdefault(tuple(row["flight_ids"]),row)+ _enforce_location_policy(ranked, output)dump(output/"ranked.json",ranked)dump(output/"flight-combinations.json",list(best_pairs.values()))provenance.collect_terrain_inputs(ground,terrain)diff --git a/src/dopplergeist/region_policy.py b/src/dopplergeist/region_policy.pyindex ed9b0ad..752664e 100644--- a/src/dopplergeist/region_policy.py+++ b/src/dopplergeist/region_policy.py@@ -67,7 +67,7 @@ class ResultRegionPolicy:def redact_location_outputs(output_dir):output = Path(output_dir)- for name in ("search", "refined-candidates.json", "decision.json", "spectral-comparison.json"):+ for name in ("search", "refined-candidates.json", "decision.json", "spectral-comparison.json", "ranked-grid.json", "ranked.json", "flight-combinations.json", "report.json", "location-scores.png", "model-support.json", "support"):path = output / nameif path.is_symlink() or path.is_file():path.unlink(missing_ok=True)diff --git a/tests/test_region_policy.py b/tests/test_region_policy.pyindex 1b3485a..6b99b76 100644--- a/tests/test_region_policy.py+++ b/tests/test_region_policy.py@@ -1,5 +1,6 @@import pytest+from dopplergeist.pipeline import _enforce_location_policyfrom dopplergeist.region_policy import ResultRegionPolicy, redact_location_outputs@@ -67,3 +68,25 @@ def test_redaction_removes_location_artifacts(tmp_path):assert not (tmp_path / "decision.json").exists()assert not (tmp_path / "spectral-comparison.json").exists()assert (tmp_path / "keep.txt").is_file()++++def test_configured_run_rejects_restricted_candidates_and_redacts_results(tmp_path):+ (tmp_path / "ranked-grid.json").write_text("[]")+ (tmp_path / "ranked.json").write_text("[]")+ (tmp_path / "flight-combinations.json").write_text("[]")+ (tmp_path / "report.json").write_text("{}")+ (tmp_path / "location-scores.png").write_bytes(b"image")+ (tmp_path / "support").mkdir()+ (tmp_path / "support" / "grid-scoring.json").write_text("{}")++ with pytest.raises(ValueError, match="restricted region"):+ _enforce_location_policy([{"lat": 50.4501, "lon": 30.5234}], tmp_path)++ for name in ("ranked-grid.json", "ranked.json", "flight-combinations.json",+ "report.json", "location-scores.png", "support"):+ assert not (tmp_path / name).exists()+++def test_configured_run_allows_ordinary_locations(tmp_path):+ _enforce_location_policy([{"lat": 41.0082, "lon": 28.9784}], tmp_path)