Python tool for aircraft Doppler audio geolocation using historical ADS-B flight data (Source-available)
Python acoustic-geolocationads-baircraft-trackingairplaneaudio-forensicsdoppler-effectdoppler-shiftgeolocationosintsignal-processing
Index silence-veto passage windows
Cinna Davis59c764dd1f65
diff --git a/src/dopplergeist/matching.py b/src/dopplergeist/matching.pyindex 5ed8ac0..264404d 100644--- a/src/dopplergeist/matching.py+++ b/src/dopplergeist/matching.py@@ -185,7 +185,13 @@ def association_candidates(table, events, offset_tolerance_s=5.0, time_origin=No[start + tolerance for start, _ in ordered],[index for _, index in ordered])grouped.append(groups)- by_point = {p: frame for p, frame in table.groupby("point_id")}+ silence_index = {}+ if silence:+ for point, frame in table.groupby("point_id"):+ indices = list(frame.index)+ reserve(len(indices) * max(1, len(indices).bit_length()))+ ordered = sorted((records[i]["receive_time"], i) for i in indices)+ silence_index[point] = ([value for value, _ in ordered], [i for _, i in ordered])def indexed_options(index, point_id, lower, upper):starts, ends, indices = grouped[index][point_id]@@ -241,13 +247,15 @@ def association_candidates(table, events, offset_tolerance_s=5.0, time_origin=Noexamined += 1passes = tuple(row for _, row in path)if silence and len(path) > 1:- frame = by_point[point_id]- reserve(len(frame))margin = silence.get("edge_margin_s", 60)distance = max(p["distance_m"] for p in passes)*silence.get("distance_multiplier", 1)- between = frame[(frame.receive_time > passes[0]["receive_time"]+margin) &- (frame.receive_time < passes[-1]["receive_time"]-margin) & (frame.distance_m <= distance)]- if any((r.flight_id, r.emission_time) not in used for r in between.itertuples()):+ times, indices = silence_index[point_id]+ left = bisect_right(times, passes[0]["receive_time"] + margin)+ right = bisect_left(times, passes[-1]["receive_time"] - margin)+ reserve(2 * max(1, len(times).bit_length()) + max(0, right - left))+ if any(records[i]["distance_m"] <= distance and+ (records[i]["flight_id"], records[i]["emission_time"]) not in used+ for i in indices[left:right]):continueif len(candidates) >= max_candidates:raise ValueError("Association candidate budget exceeded; search is incomplete")diff --git a/tests/test_real_association_budget.py b/tests/test_real_association_budget.pyindex eeff2c8..72cf6ba 100644--- a/tests/test_real_association_budget.py+++ b/tests/test_real_association_budget.py@@ -31,3 +31,12 @@ def test_real_passages_fit_association_budget_without_losing_hypotheses():):assert candidates[index]['event_indices'] == event_indicesassert [p['flight_id'] for p in candidates[index]['passes']] == flight_ids+++def test_real_silence_filter_remains_within_work_budget():+ fixture = json.loads((Path(__file__).parent / 'data' / 'reference-cpa-real.json').read_text())+ candidates, counts = association_candidates(pd.DataFrame(fixture['cpa_rows']), fixture['events'],+ offset_tolerance_s=5, max_candidates=20000,+ silence={'edge_margin_s': 60})+ assert len(candidates) == 1590+ assert counts['work_units'] <= 400000