Python tool for aircraft Doppler audio geolocation using historical ADS-B flight data (Source-available)
Python acoustic-geolocationads-baircraft-trackingairplaneaudio-forensicsdoppler-effectdoppler-shiftgeolocationosintsignal-processing
Respect GLO90 pixel edges and version raw normalization caches (#6)
Cinna Davisb013995ae4a8
diff --git a/src/aircraft_geoloc/data_access.py b/src/aircraft_geoloc/data_access.pyindex 7d63752..d1ecb1c 100644--- a/src/aircraft_geoloc/data_access.py+++ b/src/aircraft_geoloc/data_access.py@@ -308,11 +308,13 @@ class FlightCache:self.session = session or requests.Session()def acquire_day(self, day, *, provider="staging-0"):+ from . import tracks as normalizerday = date.fromisoformat(day)tag = f"v{day:%Y.%m.%d}-planes-readsb-{provider}"directory = self.root / day.isoformat() / providerdirectory.mkdir(parents=True, exist_ok=True)- index = directory / "all-types-v1.sqlite"+ normalizer_hash = sha256(normalizer.__file__)+ index = directory / f"all-types-v1-{normalizer_hash[:12]}.sqlite"if index.exists():return FlightIndex(index)release_path = directory / "release.json"@@ -340,6 +342,7 @@ class FlightCache:coverage = {"bounds": [-180, -90, 180, 90], "time_range_s": [start, start + 86400],"all_aircraft": True, "provider": "ADSB.lol", "release_tag": tag,"release_sha256": sha256(release_path), "license": "ODbL", "missing_receiver_data_possible": True}+ coverage["normalizer_sha256"] = normalizer_hashtypes_path = self.root / "icao_aircraft_types.js"type_source = download("https://raw.githubusercontent.com/wiedehopf/tar1090-db/master/db/icao_aircraft_types.js",types_path, offline=self.offline, session=self.session)@@ -404,7 +407,9 @@ class CachedTerrain:lat, lon = np.broadcast_arrays(lat, lon)shape = lat.shapelat, lon = lat.ravel(), lon.ravel()- degrees = np.column_stack((np.floor(lat).astype(int), np.floor(lon).astype(int)))+ # Published COG tiles omit the original bottom/right overlap pixels.+ # Their outer edges are shifted north/west by half a GLO90 pixel.+ degrees = np.column_stack((np.floor(lat - 1 / 2400).astype(int), np.floor(lon + 1 / 2400).astype(int)))self.last_sample_files = {"tileList.txt", self.geoid_path.name}tiles, inverse = np.unique(degrees, axis=0, return_inverse=True)height = np.zeros(len(lat))diff --git a/tests/test_data_access.py b/tests/test_data_access.pyindex fcf3572..65927f1 100644--- a/tests/test_data_access.py+++ b/tests/test_data_access.py@@ -135,3 +135,17 @@ def test_terrain_offline_datum_missing_and_corruption(tmp_path):(tmp_path / "tileList.txt").write_text("broken")with pytest.raises(DataUnavailable, match="corrupt"):CachedTerrain(tmp_path, offline=True, geoid_path=tmp_path / "geoid.tif")+++def test_terrain_degree_boundary_uses_published_cog_extent(tmp_path):+ import rasterio+ from rasterio.transform import from_origin+ tag = "Copernicus_DSM_COG_30_N39_00_W100_00_DEM"+ (tmp_path / "tileList.txt").write_text(tag + "/\n")+ for name, value in [(tag + ".tif", 100.), ("geoid.tif", -30.)]:+ with rasterio.open(tmp_path / name, "w", driver="GTiff", height=2, width=2, count=1,+ dtype="float32", crs="EPSG:4326", transform=from_origin(-100, 40.000416666667, .5, .5)) as raster:+ raster.write(np.full((2, 2), value, dtype="float32"), 1)+ terrain = CachedTerrain(tmp_path, offline=True, geoid_path=tmp_path / "geoid.tif", adopt_existing=True)+ assert terrain.sample([40.], [-99.5]).tolist() == [70.]+ assert tag in str(terrain.provenance()["files"])