Python tool for aircraft Doppler audio geolocation using historical ADS-B flight data (Source-available)
Python acoustic-geolocationads-baircraft-trackingairplaneaudio-forensicsdoppler-effectdoppler-shiftgeolocationosintsignal-processing
fix: scope CPA motion proof to event window
Cinna Davis48e2efd65a07
diff --git a/docs/PUBLIC_RECORDING_EXPERIMENT_2026-11-03.md b/docs/PUBLIC_RECORDING_EXPERIMENT_2026-11-03.mdindex 3c86239..678f951 100644--- a/docs/PUBLIC_RECORDING_EXPERIMENT_2026-11-03.md+++ b/docs/PUBLIC_RECORDING_EXPERIMENT_2026-11-03.md@@ -92,6 +92,25 @@ unresolved. The displayed leaders are diagnostic rankings, not supported fixes;increasing the refinement budget or removing the bounds would not repair themissing independent acoustic evidence.+### CPA support scope follow-up++Read-only analysis of the saved 2024-04-08 support artifacts found a mismatch+between CPA time filtering and the non-subsonic-track support proof. The bounded+search cropped CPA rows to event receive times, while the fallback proof examined+bad-motion intervals across each complete track. Using the saved run configuration+and track time ranges with the production receive-window calculation, 45 of 46+unique Rochester bad-motion intervals and both East Texas intervals have no+affected CPA sample edge in the query window; one Rochester interval remains+in-window. Fort Worth had no unsupported CPA track intervals.++The follow-up code change passes the same bounded window into the CPA support+proof. It skips only intervals whose affected sample edges fall outside the+actual CPA slice; any interval that can contribute an edge still requires the+existing spatial exclusion proof. Direct acoustic support checks remain+time-local. The saved jobs were not rerun or rewritten, and this correction does+not establish that a location estimate is accurate. Fort Worth remains+source_drift_unresolved; all three old decisions remain inconclusive.+## ReproductionThe source records are linked above. The field collector indiff --git a/src/dopplergeist/geometry.py b/src/dopplergeist/geometry.pyindex d3866ae..43f2f59 100644--- a/src/dopplergeist/geometry.py+++ b/src/dopplergeist/geometry.py@@ -148,7 +148,8 @@ class Track:raise AcousticSupportError(self.id, "non_subsonic_motion",emission_intervals_s=[[float(self.time[i]), float(self.time[i+1])] for i in indices])- def _cpa_interval_exclusion(self, observers, radius, c, sample_time, sample_position, max_step):+ def _cpa_interval_exclusion(self, observers, radius, c, sample_time, sample_position, max_step,+ sample_range=None):"""Prove bad native intervals cannot affect this sparse CPA query.Keep the original spline, sample lattice and global maximum sample@@ -156,7 +157,9 @@ class Track:of every lattice edge touching a bad interval must also be outside theoriginal KD-tree radius, so no such edge, sampled minimum or endpointrefinement can be used. A failed proof leaves whole-track CPA unknown.- This says nothing about later acoustic arrivals from those intervals.+ A bounded query only needs proof for intervals whose affected edges+ occur in its selected global-lattice slice. This says nothing about+ later acoustic arrivals from those intervals."""methods = ("position", "speed_vector", "_unsupported_motion_intervals", "validate_motion_support")if (type(self) is not Track or any(name in self.__dict__ for name in methods)@@ -173,6 +176,15 @@ class Track:or sample_time[0] != self.time[0] or sample_time[-1] != self.time[-1]or not np.all(np.diff(sample_time) > 0)):return None+ edge_first, edge_stop = 0, len(sample_time)-1+ if sample_range is not None:+ if (type(sample_range) not in (tuple, list) or len(sample_range) != 2+ or any(type(value) is not int for value in sample_range)):+ return None+ sample_first, sample_last = sample_range+ if not (0 <= sample_first <= sample_last <= len(sample_time)):+ return None+ edge_first, edge_stop = sample_first, max(sample_first, sample_last-1)indices = self._unsupported_motion_intervals(c)if not len(indices):return None@@ -180,6 +192,34 @@ class Track:query_radius = float(np.nextafter(radius + 2 * max_step, np.inf))if not np.isfinite(query_radius):return None+ outside_query = []+ if sample_range is not None:+ relevant = []+ for first in range(0, len(indices), _MOTION_SUPPORT_INTERVAL_BATCH):+ selected = indices[first:first+_MOTION_SUPPORT_INTERVAL_BATCH]+ times = self.time[np.column_stack((selected, selected+1))]+ tolerance = np.maximum(1e-7, 4*np.abs(np.spacing(np.maximum(np.abs(times[:, 0]),+ np.abs(times[:, 1])))))+ left = np.maximum(0, np.searchsorted(sample_time, times[:, 0]-tolerance, side="left")-1)+ right = np.minimum(len(sample_time)-1,+ np.searchsorted(sample_time, times[:, 1]+tolerance, side="right"))+ keep = ((left < edge_stop) & (right > edge_first) & (edge_first < edge_stop))+ if np.any(keep):+ relevant.append(selected[keep])+ outside_query.extend(times[~keep].tolist())+ indices = np.concatenate(relevant) if relevant else np.empty(0, dtype=int)+ if not len(indices):+ return {"track_id": self.id, "method": "outside_bounded_cpa_sample_edges",+ "emission_time_range_s": [float(self.time[0]), float(self.time[-1])],+ "emission_intervals_s": [],+ "outside_query_scope_intervals_s": [[float(a), float(b)] for a, b in outside_query],+ "sound_speed_mps": float(c), "max_distance_m": float(radius),+ "max_sample_step_m": float(max_step), "query_radius_m": query_radius,+ "hull_distance_lower_m": None, "edge_distance_lower_m": None,+ "sample_count": len(sample_time), "affected_sample_edges": 0,+ "sample_range": [sample_first, sample_last],+ "receiver_point_count": len(observers),+ "observer_box_ecef_m": [lower.tolist(), upper.tolist()]}affected_edges = np.zeros(len(sample_time)-1, dtype=bool)hull_lower = np.inf# No interval-by-receiver matrix: the receiver box encloses the actual@@ -208,6 +248,9 @@ class Track:left = max(0, int(np.searchsorted(sample_time, start-tolerance, side="left"))-1)right = min(len(affected_edges), int(np.searchsorted(sample_time, end+tolerance, side="right")))affected_edges[left:right] = True+ if sample_range is not None:+ affected_edges[:edge_first] = False+ affected_edges[edge_stop:] = Falseedges = np.flatnonzero(affected_edges)if not len(edges):return None@@ -219,13 +262,17 @@ class Track:distances = np.nextafter(np.linalg.norm(separation, axis=1)-margin, -np.inf)if not np.isfinite(distances).all() or not np.all(distances > query_radius):return None- return {"track_id": self.id, "method": "outside_native_hulls_and_sample_edges",+ return {"track_id": self.id,+ "method": ("outside_native_hulls_and_bounded_sample_edges" if sample_range is not None+ else "outside_native_hulls_and_sample_edges"),"emission_time_range_s": [float(self.time[0]), float(self.time[-1])],"emission_intervals_s": [[float(self.time[i]), float(self.time[i+1])] for i in indices],+ "outside_query_scope_intervals_s": [[float(a), float(b)] for a, b in outside_query],"sound_speed_mps": float(c), "max_distance_m": float(radius),"max_sample_step_m": float(max_step), "query_radius_m": query_radius,"hull_distance_lower_m": hull_lower, "edge_distance_lower_m": float(distances.min()),"sample_count": len(sample_time), "affected_sample_edges": len(edges),+ "sample_range": None if sample_range is None else [sample_first, sample_last],"receiver_point_count": len(observers), "observer_box_ecef_m": [lower.tolist(), upper.tolist()]}def outside_observer_radius(self, observers, radius, c=343.0):diff --git a/src/dopplergeist/search.py b/src/dopplergeist/search.pyindex 267b699..0a28e52 100644--- a/src/dopplergeist/search.py+++ b/src/dopplergeist/search.py@@ -112,10 +112,28 @@ def _cpa_rows(tracks, observers, point_ids, max_distance, c=343.0, step_s=2.0, creturn _ordered_cpa_rows(rows, step_s)+def _bounded_cpa_sample_range(sample_time, receive_time_bounds, max_distance, c, step_s):+ """Return the exact global-lattice slice used by a bounded CPA query."""+ if receive_time_bounds is None:+ return None+ try:+ padding = 4 * step_s+ lower = receive_time_bounds[0] - max_distance / c - padding+ upper = receive_time_bounds[1] + padding+ if not (math.isfinite(lower) and math.isfinite(upper) and lower <= upper):+ return None+ except (IndexError, TypeError, ValueError, ZeroDivisionError, OverflowError):+ return None+ first = max(0, int(np.searchsorted(sample_time, lower, side="left")) - 1)+ last = min(len(sample_time), int(np.searchsorted(sample_time, upper, side="right")) + 1)+ return first, last++class _PreparedCPATrack:"""One validated track/step, reused only across one call's receiver chunks."""- def __init__(self, track, c, step_s, *, _sample_cache=None, motion_observers=None, max_distance=None):+ def __init__(self, track, c, step_s, *, _sample_cache=None, motion_observers=None, max_distance=None,+ receive_time_bounds=None):self.motion_support = Nonemotion_error = Nonetry:@@ -138,11 +156,14 @@ class _PreparedCPATrack:else:_, self.time, self.position, self.max_step = sampledif motion_error is not None:+ sample_range = _bounded_cpa_sample_range(self.time, receive_time_bounds, max_distance, c, step_s)self.motion_support = Track._cpa_interval_exclusion(track, motion_observers, max_distance, c,- self.time, self.position, float(self.max_step))+ self.time, self.position, float(self.max_step), sample_range=sample_range)if self.motion_support is None:raise motion_errorself.motion_support["sample_step_s"] = float(step_s)+ if sample_range is not None:+ self.motion_support["receive_time_bounds_s"] = tuple(map(float, receive_time_bounds))self.lower, self.upper = self.position.min(axis=0), self.position.max(axis=0)self.tree = Noneself._tree_sample_range = None@@ -151,25 +172,27 @@ class _PreparedCPATrack:if self.motion_support is not None:support = self.motion_supportlower, upper = np.asarray(support["observer_box_ecef_m"])+ expected_bounds = support.get("receive_time_bounds_s")+ try:+ requested_bounds = None if receive_time_bounds is None else tuple(map(float, receive_time_bounds))+ except (TypeError, ValueError):+ requested_bounds = None+ reported_intervals = list(support["emission_intervals_s"])+ reported_intervals.extend(support.get("outside_query_scope_intervals_s", []))if (not np.isfinite(max_distance) or max_distance > support["max_distance_m"]or self.c != support["sound_speed_mps"] or self.step_s != support["sample_step_s"]+ or (expected_bounds is not None and requested_bounds != expected_bounds)or not np.isfinite(observers).all() or not np.all((observers >= lower) & (observers <= upper))):raise AcousticSupportError(self.track.id, "non_subsonic_motion",- emission_intervals_s=support["emission_intervals_s"])+ emission_intervals_s=reported_intervals)rows = []track, t, pos, c = self.track, self.time, self.position, self.c- sample_first, sample_last = 0, len(t)- if receive_time_bounds is not None:- # Keep the global grid, max-step radius, bounding box and motion- # proof unchanged. Four steps retain both projection neighbours- # and the preceding raw CPA used by adjacent-row deduplication.- padding = 4 * self.step_s- lower = receive_time_bounds[0] - max_distance / c - padding- upper = receive_time_bounds[1] + padding- if math.isfinite(lower) and math.isfinite(upper) and lower <= upper:- sample_first = max(0, int(np.searchsorted(t, lower, side="left")) - 1)- sample_last = min(len(t), int(np.searchsorted(t, upper, side="right")) + 1)- t, pos = t[sample_first:sample_last], pos[sample_first:sample_last]+ sample_range = _bounded_cpa_sample_range(t, receive_time_bounds, max_distance, c, self.step_s)+ sample_first, sample_last = sample_range or (0, len(t))+ if sample_range is not None:+ # Four steps retain projection neighbours and the preceding raw+ # CPA used by adjacent-row deduplication; the global lattice stays intact.+ t, pos = t[sample_first:sample_last], pos[sample_first:sample_last]if len(t) < 2:return rowsnear=np.flatnonzero(np.all((observers>=self.lower-max_distance)&diff --git a/src/dopplergeist/tiled_search.py b/src/dopplergeist/tiled_search.pyindex 6d87526..13cc3a1 100644--- a/src/dopplergeist/tiled_search.py+++ b/src/dopplergeist/tiled_search.py@@ -588,7 +588,8 @@ def _score(points, tracks, events, measurements, budget, parameters, filters, stif error.reason == "non_subsonic_motion":try:prepared = _PreparedCPATrack(track, parameters.get("c", 343.0), budget.cpa_step_s,- motion_observers=observers, max_distance=radius)+ motion_observers=observers, max_distance=radius,+ receive_time_bounds=receive_bounds)if prepared.motion_support is None:raise errortrack_batches, track_rows = _track_cpa_batches(prepared, observers, point_ids, radius,