Skip to content

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

Tie batch safety guard to emission solver tolerance

Cinna Davis7f6f03531acc
diff --git a/src/dopplergeist/geometry.py b/src/dopplergeist/geometry.py
index 7fcfda5..6701fdb 100644
--- a/src/dopplergeist/geometry.py
+++ b/src/dopplergeist/geometry.py
@@ -11,6 +11,8 @@ from scipy.interpolate import CubicHermiteSpline
from scipy.optimize import minimize_scalar
from scipy.signal import find_peaks
+_EMISSION_ITERATION_TOLERANCE_S = 1e-7
+
class AcousticSupportError(ValueError):
"""A trajectory cannot support the assumed emission-time acoustic model."""
@@ -186,7 +188,7 @@ class Track:
tau = updated
# A fixed point at Unix-epoch precision would repeat identically
# even when its unrounded correction exceeds the tolerance.
- if np.max(np.abs(correction)) < 1e-7 or unchanged:
+ if np.max(np.abs(correction)) < _EMISSION_ITERATION_TOLERANCE_S or unchanged:
break
delta = self.position(tau) - observer
distance = np.linalg.norm(delta, axis=-1)
diff --git a/src/dopplergeist/matching.py b/src/dopplergeist/matching.py
index f5a1512..5740633 100644
--- a/src/dopplergeist/matching.py
+++ b/src/dopplergeist/matching.py
@@ -16,7 +16,7 @@ import numpy as np
from pyproj import Transformer
from scipy.optimize import minimize
-from .geometry import Track, ecef
+from .geometry import Track, _EMISSION_ITERATION_TOLERANCE_S, ecef
@dataclass
@@ -449,11 +449,11 @@ def batch_acoustic_trials(tracks, measurements, observer, starts, c=343.0, max_s
for track, measurement in zip(tracks, measurements):
spec, ridge, weight, _ = measurement
times, ridge, weight = (np.asarray(a, dtype=float) for a in (spec.time, ridge, weight))
- # The solver's 1e-7 stopping tolerance is below half a floating-point
- # ULP throughout these emission times. Once an individual trial has
- # stopped, further vector iterations therefore leave it unchanged.
- # Older epochs retain the original per-trial path.
- if track.time[0] < 2**30:
+ # Once the solver tolerance is below half an emission-time ULP, a
+ # stopped individual trial remains unchanged in further iterations.
+ # Negative or lower-precision epochs retain the per-trial path.
+ if (track.time[0] < 0 or
+ np.spacing(track.time[0]) <= 2 * _EMISSION_ITERATION_TOLERANCE_S):
batches.append(None)
continue
if times.shape != ridge.shape or times.shape != weight.shape or times.ndim != 1: