Python tool for aircraft Doppler audio geolocation using historical ADS-B flight data (Source-available)
Python acoustic-geolocationads-baircraft-trackingairplaneaudio-forensicsdoppler-effectdoppler-shiftgeolocationosintsignal-processing
Feature real flyover near README introduction (#234)
Cinna Davis21262e031388
diff --git a/README.md b/README.mdindex bc66d91..f154fa9 100644--- a/README.md+++ b/README.md@@ -4,6 +4,10 @@DOPPLERGEIST investigates **where an audio recording was made** by comparing the Doppler patterns of passing aircraft with historical flight trajectories. It combines acoustic measurements, aircraft motion, sound travel time and terrain to rank possible recording locations.+++<sub>From a real aircraft flyover, DOPPLERGEIST’s highest-scoring point landed **481 m from a reference derived from other flight tracks**. This demonstration uses the known aircraft and a bounded time and area; [see the full results and limitations](docs/LIVERMORE_DEMO.md).</sub>+**This is experimental software, still in a very early beta. Contributors welcome.** The local upload application and automatic audio-to-decision pipeline are available on `main`, alongside configured research replays. Independent nationwide accuracy on real recordings has not (YET) been established. I am currently collecting a swath on audio recordings to benchmark this software.[Current status](#current-status) · [Quickstart](#quickstart) · [How it works](#how-it-works) · [Results](#experimental-results) · [Documentation](#documentation-and-references)@@ -98,12 +102,6 @@ Remaining reliability work includes [unsupported trajectory motion and coverage## Experimental results-### A real flyover, with bounded priors----This configured run combines a real recording with its supplied aircraft track, a narrow time window and a regional search area. Its highest-scoring point is **481 m from a dataset-derived reference**, not surveyed microphone ground truth. The result is inconclusive: model assessment is incomplete and the fitted clock is at the search boundary. [Setup, limitations and reproduction](docs/LIVERMORE_DEMO.md).-The published project artifacts preserve both successful fits and cases where the system could not justify a location. The following are **historical configured replays**, with their original settings and thresholds:| Experiment | Reported finding | Important qualification |diff --git a/docs/LIVERMORE_DEMO.md b/docs/LIVERMORE_DEMO.mdindex 8debaa3..563aa24 100644--- a/docs/LIVERMORE_DEMO.md+++ b/docs/LIVERMORE_DEMO.md@@ -12,11 +12,13 @@ score in this visualization.The highest-scoring point is **481 m from an inferred reference**, not surveyedmicrophone ground truth. That reference was reconstructed from published flight-tracks and reported closest-track offsets across the same dataset; the dataset-does not publish an exact microphone coordinate. The search region was chosen-with that inferred site in mind, so this separation is **not an independent-measurement of location accuracy**. The candidate is within 500 m and 1,000 m-of the inferred reference, but not 100 m; the unknown reference error prevents+tracks and reported closest-track offsets across the same dataset. The fit excludes+the target passage, rejects three of the remaining 39 cases with residuals above+150 m, and has a 4.76 m RMS residual on the remaining 36. This is a model-derived+common-site reference, not a surveyed microphone coordinate. The search used a+Livermore city-area prior chosen before the reference was calculated. This+separation is **not an independent measurement of location accuracy**. The+candidate is within 500 m and 1,000 m of the inferred reference, but not 100 m; the unknown reference error preventsthose figures from establishing those accuracy thresholds.The configured run supplied one aircraft's track, the recording's full 0–85 s@@ -38,7 +40,7 @@ plot does not rule them out.A separate fresh configured two-flyover replay on the same code placed itsleading candidate 43.86 m from an approximate public reference, also withincomplete model support. Both are development examples, not automatic or-independent real-world acceptance. The Livermore run took 20.7 seconds on the+independent real-world acceptance. The Livermore run reported 38.8 seconds on thelocal machine; runtime depends on hardware and load.## Reproduce@@ -58,6 +60,14 @@ PYTHONPATH=src python -m dopplergeist.cli run \results/livermore-prepared/config.json --output results/livermore-run```+To reproduce the inferred reference, extract all four dataset ZIPs under+`path/to/dataset/extracted/` with their category directories intact, then run:++```bash+PYTHONPATH=src python scripts/compare_livermore_reference.py \+ path/to/dataset results/livermore-run+```+The imagery in the figure comes from [USGS The National Map / USDA NAIP](https://imagery.nationalmap.gov/arcgis/rest/services/USGSNAIPImagery/ImageServer).To reproduce the graphic, download the public-domain USGS image for the fixedextent and pass it to the renderer:diff --git a/scripts/compare_livermore_reference.py b/scripts/compare_livermore_reference.pynew file mode 100644index 0000000..894e478--- /dev/null+++ b/scripts/compare_livermore_reference.py@@ -0,0 +1,96 @@+"""Compare the Livermore run to a reference inferred from other flyovers."""++import argparse+import json+from pathlib import Path++import numpy as np+import pandas as pd+from pyproj import Geod+from scipy.optimize import least_squares++from dopplergeist.tracks import read_kml++parser = argparse.ArgumentParser(+ description="Compare a configured Livermore run to an inferred leave-one-case-out reference"+)+parser.add_argument(+ "dataset",+ type=Path,+ help="Zenodo dataset directory with final CSV and extracted case folders",+)+parser.add_argument("run", type=Path, help="Completed run directory")+args = parser.parse_args()+root = args.dataset+rows = pd.read_csv(root / "final_results_40_cases.csv")+tracks = []+for row in rows.itertuples():+ if row.case == "N784MB_R04":+ continue+ d = root / "extracted" / row.category / row.case+ freq = pd.read_csv(d / "frequency_vs_time_used.csv")+ t = pd.to_datetime(freq.time_utc, utc=True)+ mid = (t.iloc[0].timestamp() + t.iloc[-1].timestamp()) / 2+ tr = read_kml(d / row.track_file)+ tr = tr[abs(tr.time_s - mid) < 300]+ x = (tr.lon.to_numpy() + 121.77) * 111320 * np.cos(np.deg2rad(37.68))+ y = (tr.lat.to_numpy() - 37.68) * 110574+ tracks.append(+ (+ row.case,+ x,+ y,+ float(row.L_ADSB_m),+ tr.alt_m.to_numpy(),+ float(row.H_ADSB_above_recorder_m),+ )+ )+++def distance(v, x, y):+ dx = np.diff(x)+ dy = np.diff(y)+ t = np.clip(+ ((v[0] - x[:-1]) * dx + (v[1] - y[:-1]) * dy)+ / np.maximum(dx * dx + dy * dy, 1e-9),+ 0,+ 1,+ )+ ds = np.hypot(x[:-1] + t * dx - v[0], y[:-1] + t * dy - v[1])+ i = np.argmin(ds)+ return ds[i], i, t[i]+++def residual(v, subset):+ return np.array([distance(v, x, y)[0] - L for _, x, y, L, _, _ in subset])+++starts = [+ (x, y) for x in range(-10000, 10001, 2500) for y in range(-10000, 10001, 2500)+]+best = min(starts, key=lambda x: sum(abs(residual(x, tracks))))+fit = least_squares(residual, best, args=(tracks,), loss="soft_l1", f_scale=50)+inliers = [t for t, r in zip(tracks, residual(fit.x, tracks)) if abs(r) < 150]+fit = least_squares(residual, fit.x, args=(inliers,), loss="soft_l1", f_scale=50)+lat = 37.68 + fit.x[1] / 110574+lon = -121.77 + fit.x[0] / (111320 * np.cos(np.deg2rad(37.68)))+alt = []+for _, x, y, L, z, h in inliers:+ _, i, u = distance(fit.x, x, y)+ alt.append(z[i] + u * (z[i + 1] - z[i]) - h)+run = json.loads((args.run / "report.json").read_text())+b = run["best"]+_, _, meters = Geod(ellps="WGS84").inv(lon, lat, b["lon"], b["lat"])+out = {+ "method": "inferred from other cases only using published horizontal offsets and flight tracks; not surveyed reference",+ "excluded_target": "N784MB_R04",+ "initial_count": len(tracks),+ "inliers_150m": len(inliers),+ "excluded_outliers": [t[0] for t in tracks if t[0] not in {a[0] for a in inliers}],+ "lat": lat,+ "lon": lon,+ "median_alt_msl_m": float(np.median(alt)),+ "inlier_rms_m": float(np.sqrt(np.mean(residual(fit.x, inliers) ** 2))),+ "distance_top_to_inferred_m": meters,+}+print(json.dumps(out, indent=2))