Skip to content

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

Merge remote-tracking branch 'origin/main' into perf/batch-ridge-fits-20261103

Cinna Davis0276fb64e3f1
diff --cc src/dopplergeist/search.py
index d50578b,3a54236..8c1e16d
--- a/src/dopplergeist/search.py
+++ b/src/dopplergeist/search.py
@@@ -401,7 -401,7 +401,7 @@@ def _validate_score_ceiling_inputs(even
raise ValueError("Source frequency bounds must be finite, positive and ordered")
- def _screen_association_trial(tracks, events, measurements, observer, start, c, acoustic_at, floor, first_fit=None):
-def _screen_association_trial(tracks, events, measurements, observer, start, c, acoustic_at, floor, dual_at=None):
++def _screen_association_trial(tracks, events, measurements, observer, start, c, acoustic_at, floor, dual_at=None, first_fit=None):
"""Fit groups until a conservative residual ceiling cannot reach the floor.
Unperformed groups each contribute at most one. The existing validated-fit
@@@ -411,11 -411,10 +411,13 @@@
diagnostics = []
missing = {"score": -np.inf, "f0_hz": np.nan, "support_fraction": 0.0}
for index, (track, event, measurement) in enumerate(zip(tracks, events, measurements)):
+ if dual_at is not None and dual_at(index):
+ return None, -np.inf
acoustic = None if acoustic_at is None else [acoustic_at(index)]
- single = score_ridges([track], [event], [measurement], observer, start, c, acoustic_results=acoustic)
+ if index == 0 and first_fit is not None:
+ single = {"event_diagnostics": [first_fit]}
+ else:
+ single = score_ridges([track], [event], [measurement], observer, start, c, acoustic_results=acoustic)
diagnostics.extend(single["event_diagnostics"])
remaining = len(events) - len(diagnostics)
if remaining:
@@@ -516,7 -515,8 +518,9 @@@ def score_candidate(candidate, point, t
batches = []
else:
batches = batch_acoustic_trials(selected_tracks, measurements, observer, anchor + shifts, c)
+ first_fits, first_batch_attempted = None, False
+ dual_flags = {}
+ dual_pruned = 0
for trial, shift in enumerate(() if floor_pruned else shifts):
if mode == "robust_ridge":
from .matching import score_ridges
@@@ -528,17 -528,26 +532,33 @@@
return None if batch is None else (batch[0][trial], batch[1][trial])
precomputed = ([acoustic_at(index) for index in range(len(events))]
if batches is not None and lazy_batches is None else None)
+ def dual_at(index):
+ nonlocal dual_pruned
+ if index != 0:
+ return False
+ if index not in dual_flags:
+ acoustic_at(index)
+ batch = batches[index]
+ if batch is None:
+ dual_flags[index] = np.zeros(len(shifts), dtype=bool)
+ else:
+ from .acoustic_screen import ridge_trial_rejections
+ dual_flags[index] = ridge_trial_rejections(measurements[index], events[index], *batch)
+ rejected = bool(dual_flags[index][trial])
+ dual_pruned += int(rejected)
+ return rejected
try:
if association and score_floor is not None:
+ if not first_batch_attempted and batches is not None and lazy_batches is not None and time_origin is None:
+ first_batch_attempted = True
+ acoustic_at(0)
+ if batches[0] is not None:
+ from .batch_ridge import first_event_fits
+ first_fits = first_event_fits(measurements[0], events[0], *batches[0])
result, upper = _screen_association_trial(selected_tracks, events, measurements, observer,
anchor+shift, c, acoustic_at if batches is not None else None,
- score_floor, first_fits[trial] if first_fits is not None else None)
- score_floor, dual_at if batches is not None and time_origin is None else None)
++ score_floor, dual_at if batches is not None and time_origin is None else None,
++ first_fits[trial] if first_fits is not None else None)
if result is None:
partial_prunes += 1
assessment["unknown_trials"] += 1