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 worker/fixed-clock-filter-20261103

Cinna Davisea37100ee33c
diff --cc src/dopplergeist/matching.py
index 6ccba97,264404d..0a6fce3
--- a/src/dopplergeist/matching.py
+++ b/src/dopplergeist/matching.py
@@@ -171,11 -172,39 +172,39 @@@ def association_candidates(table, event
records = table.to_dict("records")
grouped, survivors = [], []
for event in events:
- frame = filter_event(table, event, time_origin, time_tolerance_s)
+ frame = filter_association_event(table, event, offset_tolerance_s, time_origin, time_tolerance_s)
reserve(len(frame))
survivors.append(len(frame))
- grouped.append({p: [records[i] for i in group.index] for p, group in frame.groupby("point_id")})
- by_point = {p: frame for p, frame in table.groupby("point_id")}
+ groups = {}
+ tolerance = event.get("quality", {}).get("cpa_tolerance_s", 0) + offset_tolerance_s/2
+ for point, group in frame.groupby("point_id"):
+ indices = list(group.index)
+ reserve(len(indices) * max(1, len(indices).bit_length()))
+ ordered = sorted((records[i]["receive_time"] - event["cpa_receive_s"], i) for i in indices)
+ groups[point] = ([start - tolerance for start, _ in ordered],
+ [start + tolerance for start, _ in ordered],
+ [index for _, index in ordered])
+ grouped.append(groups)
+ 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]
+ # These endpoints use exactly the arithmetic of the intersection below,
+ # including floating-point rounding at inclusive boundaries.
+ left = bisect_left(ends, lower)
+ right = bisect_right(starts, upper)
+ # The returned original-order slice must itself fit the work budget;
+ # reserve before allocating and sorting it at every branch.
+ selected = max(0, right - left)
+ reserve(selected * max(1, selected.bit_length()))
+ return chain((records[i] for i in sorted(indices[left:right])), [None])
+
for point_id in sorted(set().union(*(g.keys() for g in grouped))):
available = [i for i, group in enumerate(grouped) if point_id in group]
if len(available) < min_events: