Skip to content

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

Report abstained candidate errors separately from returned locations

Cinna Davis18650f65282b
diff --git a/src/aircraft_geoloc/evaluation.py b/src/aircraft_geoloc/evaluation.py
index 3cce579..e9d4062 100644
--- a/src/aircraft_geoloc/evaluation.py
+++ b/src/aircraft_geoloc/evaluation.py
@@ -100,13 +100,21 @@ def evaluate(manifest, predictions, truth, threshold_m=100, iou_threshold=0.3):
if located and not candidates:
raise ValueError(f"Successful result for {key} has no candidate")
row["location_returned"] = located
+ if candidates and "location" in label:
+ best = candidates[0]
+ for name, low, high in (("lat", -90, 90), ("lon", -180, 180)):
+ if not math.isfinite(best[name]) or not low <= best[name] <= high:
+ raise ValueError(f"Invalid {name} for {key}")
+ row["diagnostic_best_candidate_error_m"] = distance_m([best["lat"], best["lon"]], label["location"])
+ if "flight_ids" in label:
+ row["diagnostic_flight_ids_correct"] = best.get("flight_ids") == label["flight_ids"]
if located:
best = candidates[0]
for name, low, high in (("lat", -90, 90), ("lon", -180, 180)):
if not math.isfinite(best[name]) or not low <= best[name] <= high:
raise ValueError(f"Invalid {name} for {key}")
if "location" in label:
- row["location_error_m"] = distance_m([best["lat"], best["lon"]], label["location"])
+ row["location_error_m"] = row["diagnostic_best_candidate_error_m"]
row["within_threshold"] = row["location_error_m"] <= threshold_m
if "flight_ids" in label:
row["flight_ids_correct"] = best.get("flight_ids") == label["flight_ids"]
diff --git a/tests/test_evaluation.py b/tests/test_evaluation.py
index 8ca1da7..6a2c9b3 100644
--- a/tests/test_evaluation.py
+++ b/tests/test_evaluation.py
@@ -34,6 +34,8 @@ def test_all_outcomes_and_eligibility():
assert report["summary"]["false_localizations"] == 1
assert report["summary"]["execution_failures"] == 1
assert not report["cases"][1]["location_returned"]
+ assert report["cases"][1]["diagnostic_best_candidate_error_m"] > 100
+ assert "location_error_m" not in report["cases"][1]
assert report["cases"][3]["location_error_m"] > 100