Skip to content

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

Profile the leading global hypothesis and keep refinement scores comparable (#10)

Cinna Davisb19b03a665e6
diff --git a/evidence/product-20261102/ui-wheel-receipt.json b/evidence/product-20261102/ui-wheel-receipt.json
new file mode 100644
index 0000000..154a25f
--- /dev/null
+++ b/evidence/product-20261102/ui-wheel-receipt.json
@@ -0,0 +1,22 @@
+{
+ "wheel": "aircraft_geoloc_reproduction-0.1.0-py3-none-any.whl",
+ "sha256": "5fd02cbb573cf0a34327c340f341252a72e1197383dbb2ae97aa2a2e0bab47cd",
+ "isolated_wheel_runtime": {
+ "/": {
+ "status": 200,
+ "bytes": 3556,
+ "type": "text/html"
+ },
+ "/app.js": {
+ "status": 200,
+ "bytes": 8762,
+ "type": "text/javascript"
+ },
+ "/style.css": {
+ "status": 200,
+ "bytes": 4576,
+ "type": "text/css"
+ }
+ },
+ "scope": "bundled UI assets served by the actual installed-wheel HTTP implementation; no scientific localization claim"
+}
diff --git a/src/aircraft_geoloc/automatic.py b/src/aircraft_geoloc/automatic.py
index 28e8dde..10e9527 100644
--- a/src/aircraft_geoloc/automatic.py
+++ b/src/aircraft_geoloc/automatic.py
@@ -2,6 +2,7 @@
from datetime import datetime, timezone
import hashlib
import json
+import math
from pathlib import Path
import time
@@ -151,16 +152,29 @@ def _decide(search, events, prepared_events, measurements, indexes, terrain, sta
# The confidence producer supplies this adapter; missing decision machinery
# can never turn the highest raw score into a supported location.
from .confidence import decide_location
- from .matching import refine_candidate
+ from .matching import association_score, profile_candidate, refine_candidate
raw = list(search.get("ranked", []))
refined, refinement_failures = [], []
window = state["recording"]["time_window"]
start_window = tuple(utc_timestamp(window[key]).timestamp() for key in ("start_utc", "end_utc"))
# Refine global competing approaches with their original whole trajectories.
# The index iterator is bounded by the same local acoustic support envelope.
- seen = set()
+ def approach(row):
+ return (tuple(row.get("event_indices", range(len(prepared_events)))), tuple(row["flight_ids"]),
+ tuple(round(t) for t in row.get("pass_emission_times_s", [])))
+
+ def comparable(candidate, original):
+ if original.get("score_kind") == "matched_group_support_minus_normalized_residual":
+ chosen = [prepared_events[i] for i in original["event_indices"]]
+ candidate = association_score(candidate, chosen)
+ if not math.isfinite(candidate["score"]):
+ raise ValueError("Refinement no longer supports the matched event association")
+ return candidate
+
+ seen, track_sets = set(), {}
+ best_refined_score = -math.inf
for row in raw:
- key = (tuple(row.get("event_indices", range(len(prepared_events)))), tuple(row["flight_ids"]), tuple(round(t) for t in row.get("pass_emission_times_s", [])))
+ key = approach(row)
if key in seen:
continue
seen.add(key)
@@ -178,17 +192,35 @@ def _decide(search, events, prepared_events, measurements, indexes, terrain, sta
for track in index.query(bounds, (lo, hi)):
if track.id in needed:
tracks[track.id] = track
+ sample_limit = config.get("search_budget", {}).get("max_track_samples_per_tile", 500000)
+ if sum(len(item.time) for item in tracks.values()) > sample_limit:
+ raise ValueError("Refinement trajectory sample budget exceeded")
if needed - tracks.keys():
raise ValueError("Candidate flight segments are unavailable for refinement")
row = dict(row, altitude_basis={flight: sorted(set(getattr(track, "altitude_basis", ["unspecified"]))) for flight, track in tracks.items()})
candidate = refine_candidate(row, tracks, prepared_events, measurements, terrain,
radius_m=config.get("refine_radius_m", 500.0),
recording_start_window_s=start_window, c=config.get("sound_speed_mps", 343.0))
+ candidate = comparable(candidate, row)
refined.append(candidate)
+ if candidate["score"] > best_refined_score:
+ best_refined_score = candidate["score"]
+ track_sets = {key: tracks}
except (ValueError, KeyError) as exc:
refinement_failures.append(str(exc))
raw.extend(refined)
- raw.sort(key=lambda row: (row["score"], bool(row.get("sensitivity", {}).get("complete"))), reverse=True)
+ order = lambda row: (row["score"], bool(row.get("sensitivity", {}).get("complete")), len(row.get("sensitivity", {}).get("sources", [])))
+ raw.sort(key=order, reverse=True)
+ if raw and approach(raw[0]) in track_sets:
+ leading = raw[0]
+ try:
+ profiled = profile_candidate(leading, track_sets[approach(leading)], prepared_events, measurements, terrain,
+ radius_m=config.get("refine_radius_m", 500.0), recording_start_window_s=start_window,
+ c=config.get("sound_speed_mps", 343.0))
+ raw.append(comparable(profiled, leading))
+ raw.sort(key=order, reverse=True)
+ except (ValueError, KeyError) as exc:
+ refinement_failures.append(f"Sensitivity profiling: {exc}")
candidates, rows = [], []
for row in raw:
event_ids, flight_ids = [], []
@@ -222,7 +254,7 @@ def _decide(search, events, prepared_events, measurements, indexes, terrain, sta
write_json(output / "decision.json", decision)
fields = {key: value for key, value in decision.items() if key not in {"schema_version", "job_id", "status", "stage", "progress", "artifacts", "recording", "events", "diagnostics"}}
- status = fields.pop("status", decision["status"])
+ status = decision["status"]
reason = fields.pop("reason_code", None)
message = fields.pop("message", None)
return finish(status, reason, message, **fields)