Python tool for aircraft Doppler audio geolocation using historical ADS-B flight data (Source-available)
Python acoustic-geolocationads-baircraft-trackingairplaneaudio-forensicsdoppler-effectdoppler-shiftgeolocationosintsignal-processing
Score overlapping refinement grid cells once without dropping hypotheses
Cinna Davis2c1c4bff7115
diff --git a/docs/verification/REFINEMENT_UNION_01a19ec6.md b/docs/verification/REFINEMENT_UNION_01a19ec6.mdnew file mode 100644index 0000000..8dfd38c--- /dev/null+++ b/docs/verification/REFINEMENT_UNION_01a19ec6.md@@ -0,0 +1,33 @@+# Avoid repeated refinement-grid work++The actual automatic MP3 run at integration `0633b9b` requested 8,405 fine+point visits across five refinement rectangles, covering only 5,863 distinct+global grid cells. Two retained flight hypotheses requested the same rectangle.+Dropping a hypothesis would discard useful ambiguity evidence.++The driver now removes cells inside previously completed refinement rectangles+before acquiring/scoring their tracks. It still searches the complete union of+all requested rectangles against every relevant track, with the same common+recording clock and ranking. Bookkeeping stores at most one rectangle per+refinement finalist; it does not accumulate a national per-cell cache. Points+outside the requested geographic bounds remain excluded. Failure and source+coverage rules are unchanged.++The regression builds two translated physical flight pairs with competing+locations. It records the requested fine-grid union and every scored point,+then compares the retained flight/coordinate/score/clock tuples with a separate+dense evaluation over that union. Coordinates and flight associations match;+the existing comparator checks scores to eight decimal places and clocks to+five. At least two flight associations must survive the comparison.++Before the fix, the test fails because 50 scored points contain only 35 distinct+cells. After the fix, all 35 cells are scored once and 15 duplicate visits are+skipped. All five tiled-search tests pass; the full base-branch suite passes+83 tests in 23.58 s. The adjacent receipt records hashes and commands.++The large automatic run's 2,542 duplicate visits are a measured workload+opportunity, not a measured wall-time speedup. This change does not tighten+uncertainty, remove competing modes or establish a supported location. The+underlying full synthetic upload's leading hypothesis is 5.5531 m from truth+but remains inconclusive for ambiguity; independent real-audio acceptance is+still open.diff --git a/docs/verification/refinement-union-01a19ec6.json b/docs/verification/refinement-union-01a19ec6.jsonnew file mode 100644index 0000000..bd13586--- /dev/null+++ b/docs/verification/refinement-union-01a19ec6.json@@ -0,0 +1,57 @@+{+ "baseline_commit": "b831c78",+ "before_fix": {+ "point_visits": 50,+ "unique_points": 35,+ "regression": "Failed because 50 evaluations contained only 35 distinct cells"+ },+ "after_fix": {+ "refinement_points_searched": 35,+ "refinement_points_skipped": 15,+ "status": "complete"+ },+ "dense_union_physics_oracle": "Passed flight/coordinate/score/clock comparison at existing eight-decimal score and five-decimal clock precision; retained at least two flight associations.",+ "source_sha256": "826b4baa960242b3200bcd47d6f76629771fa37da143f1dd6b8427c2dc21569b",+ "test_command": "PYTHONPATH=src /home/cinna/dopplergeist-e2e-01a19ec6/.venv/bin/python -m pytest -q --basetemp=results/refinement-union-full-01a19ec6",+ "test_result": "83 passed, 1 warning in 23.58s",+ "runtime_speedup_claim": null,+ "national_fixture_overlap": {+ "coarse_finalists": 5,+ "fine_point_visits": 8405,+ "unique_fine_cells": 5863,+ "duplicate_point_visits": 2542,+ "duplicate_fraction": 0.3024390243902439,+ "rectangles": [+ [+ -3420,+ 18960,+ -3379,+ 19001+ ],+ [+ 5400,+ 13420,+ 5441,+ 13461+ ],+ [+ 5400,+ 13420,+ 5441,+ 13461+ ],+ [+ -12940,+ 23300,+ -12899,+ 23341+ ],+ [+ 5420,+ 13420,+ 5461,+ 13461+ ]+ ]+ }+}diff --git a/src/aircraft_geoloc/tiled_search.py b/src/aircraft_geoloc/tiled_search.pyindex d90d75a..57caa3c 100644--- a/src/aircraft_geoloc/tiled_search.py+++ b/src/aircraft_geoloc/tiled_search.py@@ -254,6 +254,7 @@ def search_national(indexes, terrain, events, measurements, *, time_range_s, outcoarse = list(ranked)# Refine only global finalists; tile selection never controls refinement rank.refinement_failure = None+ refinement_points_searched, refinement_points_skipped = 0, 0if ranked and budget.refine_spacing_m < budget.spacing_m:chosen, seen = [], set()for row in ranked:@@ -266,16 +267,27 @@ def search_national(indexes, terrain, events, measurements, *, time_range_s, outtry:fine = budget.refine_spacing_mwidth = math.ceil(budget.spacing_m / fine)+ completed_rectangles = []for row in chosen:# Subdivide the refinement square as well, retaining hard grid limits.cx, cy = round(row["x"] / fine), round(row["y"] / fine)for y0 in range(cy - width, cy + width + 1, budget.tile_cells):for x0 in range(cx - width, cx + width + 1, budget.tile_cells):cells = (x0, y0, min(cx + width + 1, x0 + budget.tile_cells), min(cy + width + 1, y0 + budget.tile_cells))- tracks = _tracks(indexes, _expanded_bounds(cells, fine, radius, crs), time_range_s, budget)points = tile_points(cells, fine, bounds, terrain, crs)- rows, _ = _score(points, tracks, events, measurements, budget, parameters, filters, start_window) if len(points) else ([], {})+ keep = np.ones(len(points), dtype=bool)+ for left, bottom, right, top in completed_rectangles:+ keep &= ~((points.x >= left * fine) & (points.x < right * fine)+ & (points.y >= bottom * fine) & (points.y < top * fine))+ refinement_points_skipped += int((~keep).sum())+ points = points[keep]+ if not len(points):+ continue+ tracks = _tracks(indexes, _expanded_bounds(cells, fine, radius, crs), time_range_s, budget)+ rows, _ = _score(points, tracks, events, measurements, budget, parameters, filters, start_window)+ refinement_points_searched += len(points)ranked = merge_candidates(itertools.chain(ranked, rows), budget.top_k)+ completed_rectangles.append((cx - width, cy - width, cx + width + 1, cy + width + 1))except (DataUnavailable, ValueError, OSError) as error:refinement_failure = str(error)coverage = [i.coverage_for(bounds, time_range_s) for i in indexes]@@ -299,6 +311,7 @@ def search_national(indexes, terrain, events, measurements, *, time_range_s, out"coarse_ranked": coarse, "tiles_total": total, "tiles_completed": done, "tiles_resumed": resumed,"tile_failures": failures, "unsearched_tiles": total - done, "grid_points_searched": points_searched,"data_coverage": coverage, "data_scope_complete": data_complete, "refinement_failure": refinement_failure,+ "refinement_points_searched": refinement_points_searched, "refinement_points_skipped": refinement_points_skipped,"required_flight_bounds": flight_bounds,"candidate_retention_limit": budget.top_k, "alternative_modes_exhaustively_assessed": False,"elapsed_s": time.monotonic() - began, "process_peak_rss_mib": resource.getrusage(resource.RUSAGE_SELF).ru_maxrss / 1024,diff --git a/tests/test_tiled_search.py b/tests/test_tiled_search.pyindex da70a90..12a1e76 100644--- a/tests/test_tiled_search.py+++ b/tests/test_tiled_search.py@@ -103,3 +103,61 @@ def test_ridge_only_adapter_and_exact_recording_clock(tmp_path):scoring={"mode": "ridge", "recording_start_window_s": [origin, origin]})assert result["ranked"]assert all(row["recording_start_time_s"] == origin for row in result["ranked"])+++def test_overlapping_refinement_scores_the_complete_grid_union_once(tmp_path, monkeypatch):+ from aircraft_geoloc import tiled_search++ index, tracks, events, measurements, bounds, times, origin = scenario(tmp_path)+ # A translated alternative flight pair produces a competing location whose+ # refinement overlaps the first pair. Both associations must be retained.+ forward = Transformer.from_crs("EPSG:4326", "EPSG:5070", always_xy=True)+ inverse = Transformer.from_crs("EPSG:5070", "EPSG:4326", always_xy=True)+ frames = []+ for track in list(tracks):+ x, y = forward.transform(track.lon, track.lat)+ lon, lat = inverse.transform(x + 1000, y)+ alternative = Track("alternative-" + track.id, track.time, lat, lon, track.altitude)+ tracks.append(alternative)+ for item in (track, alternative):+ frames.append(pd.DataFrame({"flight_id": item.id, "time_s": item.time,+ "lat": item.lat, "lon": item.lon, "alt_m": item.altitude,+ "altitude_basis": "ellipsoidal"}))+ index = FlightIndex.build(tmp_path / "alternatives.sqlite", frames, sources=[],+ coverage=index.report["coverage"])+ terrain = Terrain(constant_m=0)+ budget = SearchBudget(spacing_m=1000, tile_cells=4, top_k=200,+ refine_spacing_m=500, refine_finalists=4)+ settings = {"mode": "ridge", "time_origin": origin, "time_sweep_s": 0}+ requested, evaluated = [], []+ fine_phase = False++ def observe_points(cells, spacing, *args):+ nonlocal fine_phase+ fine_phase = spacing == budget.refine_spacing_m+ points = tile_points(cells, spacing, *args)+ if fine_phase:+ requested.append(points.copy())+ return points++ def observe_score(points, *args, **kwargs):+ if fine_phase:+ evaluated.extend(zip(points.x, points.y))+ return _score(points, *args, **kwargs)++ monkeypatch.setattr(tiled_search, "tile_points", observe_points)+ monkeypatch.setattr(tiled_search, "_score", observe_score)+ result = search_national([index], terrain, events, measurements, time_range_s=times,+ output_dir=tmp_path / "overlap", bounds=bounds, budget=budget, scoring=settings)+ all_points = pd.concat(requested, ignore_index=True)+ union = all_points.drop_duplicates(["x", "y"]).copy()+ assert len(all_points) > len(union), "Fixture must include overlapping refinement rectangles"+ assert len(evaluated) == len(set(evaluated))+ assert set(evaluated) == set(zip(union.x, union.y))+ assert result["refinement_points_searched"] == len(union)+ assert result["refinement_points_skipped"] == len(all_points) - len(union)+ union["point_id"] = np.arange(len(union))+ expected, _ = _score(union, tracks, events, measurements, budget, settings, {})+ expected = merge_candidates(result["coarse_ranked"] + expected, budget.top_k)+ assert len({tuple(row["flight_ids"]) for row in expected}) >= 2+ assert compact(result["ranked"]) == compact(expected)