Skip to content

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

Pass constrained joint-clock intervals to robust scoring without re-expansion (#7)

Cinna Davis8750e914ab51
diff --git a/src/aircraft_geoloc/tiled_search.py b/src/aircraft_geoloc/tiled_search.py
index 0fb45f9..328fbfe 100644
--- a/src/aircraft_geoloc/tiled_search.py
+++ b/src/aircraft_geoloc/tiled_search.py
@@ -163,6 +163,7 @@ def _score(points, tracks, events, measurements, budget, parameters, filters, st
track_lookup = {track.id: track for track in tracks}
for candidate in candidates:
settings = dict(parameters)
+ scoring_candidate = candidate
if start_window:
if start_window[0] == start_window[1] and settings.get("time_origin") is None:
settings["time_origin"] = start_window[0]
@@ -177,8 +178,12 @@ def _score(points, tracks, events, measurements, budget, parameters, filters, st
lo, hi = max(lo, anchor-sweep), min(hi, anchor+sweep)
if lo > hi:
continue
- settings.update(time_origin=(lo + hi) / 2, time_sweep_s=(hi - lo) / 2)
- row = score_candidate(candidate, lookup[candidate["point_id"]], track_lookup, events, measurements, **settings)
+ if "event_indices" in candidate:
+ scoring_candidate = dict(candidate, recording_start_bounds_s=[lo, hi])
+ settings.update(time_origin=None, time_sweep_s=0)
+ else:
+ settings.update(time_origin=(lo + hi) / 2, time_sweep_s=(hi - lo) / 2)
+ row = score_candidate(scoring_candidate, lookup[candidate["point_id"]], track_lookup, events, measurements, **settings)
row["pass_emission_times_s"] = [float(p["emission_time"]) for p in candidate["passes"]]
ranked.append(row)
return merge_candidates(ranked, budget.top_k), dict(counts, cpa_rows=count, candidates=len(candidates))
diff --git a/tests/test_tiled_search.py b/tests/test_tiled_search.py
index e3ad7b4..c764cd4 100644
--- a/tests/test_tiled_search.py
+++ b/tests/test_tiled_search.py
@@ -197,3 +197,19 @@ def test_uncertain_window_keeps_valid_shared_clock_beyond_cpa_anchor(tmp_path):
assert ranked
assert abs(ranked[0]["recording_start_time_s"]-origin) < .02
assert ranked[0]["event_indices"] == [0, 1]
+
+
+def test_narrow_trusted_window_near_sweep_edge_is_not_shrunk_again(tmp_path):
+ _, tracks, events, measurements, bounds, _, origin = scenario(tmp_path, receiver_offset=(250, 250))
+ points = tile_points((1, 7601, 2, 7602), 250, bounds, Terrain(constant_m=0), "EPSG:5070")
+ observer = ecef(points.lat.iloc[0], points.lon.iloc[0], 0)
+ shifted = []
+ for track, (spec, _, weight, fit) in zip(tracks, measurements):
+ factor, _, _ = track.acoustic(origin+7.05+spec.time, observer)
+ shifted.append((spec, 120*factor, weight, fit))
+ window = (origin+7., origin+7.1)
+ ranked, _ = _score(points, tracks, events, shifted, SearchBudget(),
+ {"mode": "robust_ridge", "time_sweep_s": 5., "time_step_s": .5}, {}, start_window=window)
+ assert ranked
+ assert window[0] <= ranked[0]["recording_start_time_s"] <= window[1]
+ assert ranked[0]["event_indices"] == [0, 1]