Skip to content

Commit 2bd36a5

Browse files
committed
better vdatum/fes blending; blend inland from final instead of vdatum only
1 parent a6865c7 commit 2bd36a5

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

src/transformez/grid_engine.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,10 @@ def smart_blend(in_grid, background_grid, blend_pixels=50):
190190
dist = ndimage.distance_transform_edt(mask)
191191
alpha = np.clip(dist / blend_pixels, 0.0, 1.0)
192192

193+
# --- Hermite Interpolation ---
194+
# This converts the linear gradient into a smooth S-curve
195+
alpha = alpha * alpha * (3.0 - 2.0 * alpha)
196+
193197
nearest_indices = ndimage.distance_transform_edt(
194198
mask, return_distances=False, return_indices=True
195199
)
@@ -210,6 +214,7 @@ def coastal_aware_composite(
210214
shapefiles=None,
211215
decay_pixels=100,
212216
buffer_pixels=10,
217+
blend_pixels=50,
213218
):
214219
"""Handles inland decay vs. offshore blending, while
215220
filtering out low-resolution global artifacts.
@@ -230,14 +235,13 @@ def coastal_aware_composite(
230235

231236
if is_offshore.any():
232237
blended_ocean = GridEngine.smart_blend(
233-
vdatum_grid, global_grid, blend_pixels=50
238+
vdatum_grid, global_grid, blend_pixels=blend_pixels
234239
)
235240
final_grid[is_offshore] = blended_ocean[is_offshore]
236241

237242
if is_inland.any():
238-
source_for_decay = vdatum_grid if is_vdatum.any() else final_grid
239243
decayed_inland = GridEngine.fill_nans(
240-
source_for_decay,
244+
final_grid,
241245
decay_pixels=decay_pixels,
242246
buffer_pixels=buffer_pixels,
243247
land_mask=land_mask,

0 commit comments

Comments
 (0)