This commit is contained in:
Andras Schmelczer 2026-07-03 18:28:56 +01:00
parent 909e241907
commit 1ee796b282
29 changed files with 250 additions and 126 deletions

View file

@ -85,24 +85,24 @@ RESOLUTION = NATIVE_RESOLUTION
# Defra encodes TRUE "no data" with this sentinel (NOT 0.0). A 0.0 cell that is
# otherwise inside the raster means "modelled below the lowest reporting band",
# i.e. genuinely quiet — see noise_overlay_tiles.py:167.
# i.e. genuinely quiet (see noise_overlay_tiles.py:167).
NOISE_NODATA_SENTINEL = np.float32(-96.0)
# Lowest modelled Defra Lden reporting band (dB). Verified against the actual
# rasters: the minimum positive in-coverage value is 40.0 dB with NO values in
# (0, 40) — below the band, cells are encoded as 0.0 (genuinely quiet). We floor
# (0, 40). Below the band, cells are encoded as 0.0 (genuinely quiet). We floor
# in-coverage cells to 40.0 so a below-band 0.0 surfaces as "we know it's quiet"
# (~40 dB) instead of collapsing to null ("we don't know"), WITHOUT inflating the
# ~35% of genuine 40-44.99 dB readings that a 45.0 floor would wrongly bump to 45.
# NB: 45.0 is the overlay's lowest *paint* stop (noise_overlay_tiles.
# NOISE_COLOR_STOPS[0]) a rendering threshold, not the data's reporting floor.
# NOISE_COLOR_STOPS[0]), a rendering threshold, not the data's reporting floor.
NOISE_QUIET_FLOOR_DB = np.float32(40.0)
# Sample noise at the postcode representative point itself (no neighbourhood
# window). A 50m MAX-of-window grabbed the single loudest 10m cell within ~1.2 ha
# of every postcode; because Defra road contours hug every modelled road and
# representative points sit on/near streets, that inflated postcode noise by
# roughly +9 dB (log scale) making ~94% of England read >=55 dB Lden and
# roughly +9 dB (log scale), making ~94% of England read >=55 dB Lden and
# collapsing the metric's discrimination at the quiet end. Radius 0 ->
# filter_size 1 -> the maximum_filter is skipped and each postcode reads the
# 10m cell it actually sits in.
@ -110,8 +110,8 @@ POSTCODE_NOISE_RADIUS_M = 0
# Adjacent download tiles overlap by the sampling radius so every postcode's
# sampling footprint is fully contained in at least one tile. With point
# sampling (radius 0) this is 0 a representative point falls inside exactly
# one tile but the relationship is kept so any future non-zero radius keeps
# sampling (radius 0) this is 0 (a representative point falls inside exactly
# one tile), but the relationship is kept so any future non-zero radius keeps
# its window seam-safe.
TILE_OVERLAP_M = POSTCODE_NOISE_RADIUS_M
@ -273,7 +273,7 @@ def _download_tile(
NoGeoTiffError,
httpx.HTTPStatusError,
# TransportError is the superset of TimeoutException, ConnectError,
# ReadError and ProtocolError including RemoteProtocolError, raised
# ReadError and ProtocolError, including RemoteProtocolError, raised
# when the WCS server closes the connection mid-stream ("incomplete
# chunked read"). All are transient; retry/split rather than letting
# one flaky tile crash the whole raster download.
@ -446,7 +446,7 @@ def sample_noise_at_postcodes(
# Defra rasters encode TRUE nodata as the -96.0 sentinel (and
# occasionally non-finite / dataset.nodata); genuinely quiet ground
# below the model's lowest reporting band is encoded as 0.0. Only
# the former is "we don't know" — the latter is a real "we know it's
# the former is "we don't know". The latter is a real "we know it's
# quiet" reading and must not collapse to null. So treat ONLY true
# nodata as -inf (it never wins a max and never counts as coverage),
# and clamp every in-coverage cell up to NOISE_QUIET_FLOOR_DB so a
@ -555,7 +555,7 @@ def main() -> None:
if not tile_paths:
print(
f"[{label}] WARNING: No tiles downloaded column will be all null"
f"[{label}] WARNING: No tiles downloaded; column will be all null"
)
series = pl.Series(col_name, [None] * len(lat), dtype=pl.Float32)
else: