Skip to content

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

Pass trusted clock and original unmatched events to confidence (#10)

Cinna Davisef0cc4c0c0e8
diff --git a/docs/PRODUCT.md b/docs/PRODUCT.md
index af31c01..a8b0723 100644
--- a/docs/PRODUCT.md
+++ b/docs/PRODUCT.md
@@ -1,5 +1,7 @@
# Local upload workflow
+The current location goal accepts up to **1,000 m error**, with **100–500 m or better preferred**. True benchmark error and uncalibrated model sensitivity remain separate. Historical reports below retain their original 100 m thresholds.
+
The automatic product path is separate from the historical research `run` and
`measure` commands. Uploads supply audio, an optional defensible UTC window for
**sample zero**, and declared CONUS search coverage. Event windows, frequency
@@ -148,7 +150,7 @@ job reload, no JavaScript errors, and desktop/mobile layouts; see
[verification PR #33](https://github.com/1337isnot1337/DOPPLERGEIST/pull/33).
A supported unique location through the actual automatic API, independently
-established real recording truth/time, and nationwide real accuracy near 100 m
+established real recording truth/time, and nationwide real accuracy at the current 1,000 m acceptance target (100–500 m preferred)
remain unverified. The measured ambiguity and partial-coverage outcomes must not
be promoted to that acceptance claim. The historical manually configured regional
result remains separate.
diff --git a/src/aircraft_geoloc/automatic.py b/src/aircraft_geoloc/automatic.py
index e586c0e..51a7ba3 100644
--- a/src/aircraft_geoloc/automatic.py
+++ b/src/aircraft_geoloc/automatic.py
@@ -158,11 +158,23 @@ def _coverage(request, search, config):
"limitations": limitations, "requested_area": request["search"], "missing_data": missing}
+def _comparable_refinement(candidate, original, prepared_events):
+ """Preserve newer normalized results; adapt only older raw-loss producers."""
+ if (original.get("score_kind") == "matched_group_support_minus_normalized_residual"
+ and candidate.get("score_kind") != "matched_group_support_minus_normalized_residual"):
+ from .matching import association_score
+ 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
+
+
def _decide(search, events, prepared_events, measurements, indexes, terrain, state, output, config, finish, decision_progress):
# 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 association_score, profile_candidate, refine_candidate
+ from .matching import profile_candidate, refine_candidate
raw = list(search.get("ranked", []))
refined, refinement_failures = [], []
window = state["recording"]["time_window"]
@@ -173,13 +185,6 @@ def _decide(search, events, prepared_events, measurements, indexes, terrain, sta
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
@@ -211,7 +216,7 @@ def _decide(search, events, prepared_events, measurements, indexes, terrain, sta
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)
+ candidate = _comparable_refinement(candidate, row, prepared_events)
refined.append(candidate)
if candidate["score"] > best_refined_score:
best_refined_score = candidate["score"]
@@ -227,7 +232,7 @@ def _decide(search, events, prepared_events, measurements, indexes, terrain, sta
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.append(_comparable_refinement(profiled, leading, prepared_events))
raw.sort(key=order, reverse=True)
except (ValueError, KeyError) as exc:
refinement_failures.append(f"Sensitivity profiling: {exc}")
@@ -248,7 +253,10 @@ def _decide(search, events, prepared_events, measurements, indexes, terrain, sta
candidates.append(validate_candidate(candidate))
rows.append(row)
best = rows[0] if rows else {}
- diagnostics = {"clock_locked": search.get("scoring_time_is_locked", False), "refinement_failures": refinement_failures,
+ original_ids = {event["event_id"]: event.get("event_ids", [event["event_id"]]) for event in prepared_events}
+ unmatched_groups = best.get("unmatched_event_ids", list(original_ids) if not rows else [])
+ unmatched_ids = [event_id for group in unmatched_groups for event_id in original_ids.get(group, [group])]
+ diagnostics = {"recording_start_window_s": list(start_window), "unmatched_event_ids": unmatched_ids, "clock_locked": search.get("scoring_time_is_locked", False), "refinement_failures": refinement_failures,
"refinement_boundary_limited": best.get("sensitivity", {}).get("boundary_limited", True),
"sensitivity": best.get("sensitivity", {}),
"altitude_basis": best.get("altitude_basis", {}),
diff --git a/src/aircraft_geoloc/web/index.html b/src/aircraft_geoloc/web/index.html
index e4ec46f..a65147d 100644
--- a/src/aircraft_geoloc/web/index.html
+++ b/src/aircraft_geoloc/web/index.html
@@ -4,7 +4,7 @@
<body>
<header><a href="/" class="brand">DOPPLER<span>GEIST</span></a><span class="tag">Aircraft sound → location evidence</span></header>
<main>
-<section class="intro"><p class="eyebrow">ACOUSTIC GEOLOCATION</p><h1>Find the flights.<br>Test the location.</h1><p>Upload a recording to discover aircraft Doppler curves, search historical flight tracks, and inspect the evidence. When the evidence cannot support a location, the result is inconclusive.</p><p class="scope">Search coverage: <strong>contiguous United States (CONUS)</strong>. Automatic nationwide accuracy is under evaluation; the approximately 100 m target is not guaranteed.</p></section>
+<section class="intro"><p class="eyebrow">ACOUSTIC GEOLOCATION</p><h1>Find the flights.<br>Test the location.</h1><p>Upload a recording to discover aircraft Doppler curves, search historical flight tracks, and inspect the evidence. When the evidence cannot support a location, the result is inconclusive.</p><p class="scope">Search coverage: <strong>contiguous United States (CONUS)</strong>. Location goal: 100–500 m or better preferred; up to 1,000 m acceptable. Nationwide accuracy remains under evaluation.</p></section>
<div class="layout">
<section class="panel" aria-labelledby="upload-heading"><h2 id="upload-heading">New analysis</h2><form id="upload-form">
<label class="drop" for="audio"><span class="upload-symbol" aria-hidden="true">↑</span><strong>Choose an MP3 recording</strong><span id="file-label">Your original file is preserved with the job.</span><input id="audio" name="audio" type="file" accept=".mp3,audio/mpeg,.wav,.flac,.m4a,.ogg" required></label>
diff --git a/tests/test_automatic.py b/tests/test_automatic.py
index e453b8b..ba28f06 100644
--- a/tests/test_automatic.py
+++ b/tests/test_automatic.py
@@ -107,17 +107,19 @@ def test_subset_association_preserves_original_event_identity(tmp_path):
events = [{"event_id": f"event-{i}", "start_s": i*10., "end_s": i*10.+5, "band_hz": [100., 120.],
"ridge": [{"time_s": i*10.+t, "frequency_hz": 115.-t} for t in (1., 2., 3.)]} for i in range(3)]
search = {"status": "complete", "scoring_time_is_locked": True, "ranked": [
- {"event_indices": [1, 2], "flight_ids": ["second-flight", "third-flight"], "lat": 40., "lon": -100.,
+ {"event_indices": [1, 2], "unmatched_event_ids": ["event-0"], "flight_ids": ["second-flight", "third-flight"], "lat": 40., "lon": -100.,
"score": -1., "recording_start_time_s": 1788897600., "event_diagnostics": [{"rmse_hz": .1}, {"rmse_hz": .2}]}]}
state = {"recording": {"time_window": WINDOW}, "coverage": {"search_complete": True, "data_status": "available", "limitations": []}}
def finish(status, reason_code=None, message=None, **fields):
return dict(status=status, reason_code=reason_code, message=message, **fields)
final = _decide(search, events, events, [None]*3, [], None, state, tmp_path,
{"refine_finalists": 0}, finish, lambda: None)
- assert final["status"] == "inconclusive" and final["reason_code"] == "unexplained_events"
+ assert final["status"] == "inconclusive"
assert final["candidates"][0]["event_ids"] == ["event-1", "event-2"]
diagnostics = read_json(tmp_path / "refined-candidates.json")["matching_diagnostics"]
assert "event-0" not in diagnostics
+ assert diagnostics["unmatched_event_ids"] == ["event-0"]
+ assert diagnostics["recording_start_window_s"][1] - diagnostics["recording_start_window_s"][0] == 60
assert diagnostics["event-1"]["rmse_hz"] == .1
assert diagnostics["event-2"]["rmse_hz"] == .2
@@ -143,3 +145,15 @@ def test_acquisition_budget_counts_utc_archive_days_across_midnight(tmp_path):
with pytest.raises(MissingData, match="acquisition budget"):
_search(request, recording, [event], tmp_path, {"cache_root": str(tmp_path), "max_acquisition_days": 1}, lambda: None)
assert not (tmp_path/"flights").exists()
+
+
+def test_refinement_adapter_preserves_raw_residual_and_avoids_double_normalization():
+ from aircraft_geoloc.automatic import _comparable_refinement
+ from aircraft_geoloc.matching import association_score
+ events = [{"quality": {"frequency_sigma_hz": 1.}}]
+ raw = {"score": -.6, "event_scores": [-.6], "score_kind": "negative_robust_ridge_loss_hz"}
+ normalized = association_score(raw, events)
+ original = dict(normalized, event_indices=[0])
+ assert _comparable_refinement(raw, original, events) == normalized
+ assert _comparable_refinement(normalized, original, events)["residual_score"] == -.6
+ assert _comparable_refinement(normalized, original, events)["score"] == normalized["score"]