Skip to content

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

Reuse transformer during flight index construction

Cinna Davisbf4303b29335
diff --git a/src/dopplergeist/data_access.py b/src/dopplergeist/data_access.py
index f3216bc..3e30861 100644
--- a/src/dopplergeist/data_access.py
+++ b/src/dopplergeist/data_access.py
@@ -7,6 +7,7 @@ from collections import Counter
from contextlib import contextmanager
from dataclasses import dataclass
from datetime import date, datetime, timedelta, timezone
+from functools import lru_cache
import gzip
import hashlib
import io
@@ -36,6 +37,12 @@ def _frame_track(name, frame):
return track
+@lru_cache(maxsize=1)
+def _ecef_to_geographic():
+ from pyproj import Transformer
+ return Transformer.from_crs("EPSG:4978", "EPSG:4979", always_xy=True)
+
+
def _continuous_bounds(track):
"""Bound entire Hermite curves using their cubic Bezier control hulls.
@@ -44,7 +51,6 @@ def _continuous_bounds(track):
5500 km lower bound on geodetic curvature radii outside the 6000 km sphere.
Invalid/underground extreme curves fall back to a global box, never a miss.
"""
- from pyproj import Transformer
p0, p1 = track.xyz[:-1], track.xyz[1:]
dt = np.diff(track.time)[:, None]
velocity = track.speed_vector(track.time)
@@ -53,7 +59,7 @@ def _continuous_bounds(track):
radius = np.linalg.norm(controls - centers[:, None, :], axis=2).max(axis=1)
if np.any(np.linalg.norm(centers, axis=1) - radius < 6000000):
return (-180., 180., -90., 90.)
- lon, lat, _ = Transformer.from_crs("EPSG:4978", "EPSG:4979", always_xy=True).transform(*centers.T)
+ lon, lat, _ = _ecef_to_geographic().transform(*centers.T)
latitude_pad = np.rad2deg(radius / 5500000)
horizontal = np.linalg.norm(centers[:, :2], axis=1)
if np.any(radius >= horizontal):