diff --git a/src/pyiem/grid/util.py b/src/pyiem/grid/util.py index 03bcabd7..105a4b4d 100644 --- a/src/pyiem/grid/util.py +++ b/src/pyiem/grid/util.py @@ -3,26 +3,26 @@ import numpy as np -def grid_smear(grid: np.ndarray, pad: int = 4) -> np.ndarray: +def grid_smear(grid: np.ndarray, shift: int = 4) -> np.ndarray: """Smear data around to fill in masked values (likely near coastlines). Args: grid: 2D numpy array - pad: number of pixels to smear the data around by in each direction + shift: number of pixels to smear the data around by in each direction Returns: 2D numpy array with smeared data """ # Pad grid padded = np.ma.masked_all( - (grid.shape[0] + pad * 2, grid.shape[1] + pad * 2) + (grid.shape[0] + shift * 2, grid.shape[1] + shift * 2) ) # set values from inbound grid - padded[pad:-pad, pad:-pad] = grid + padded[shift:-shift, shift:-shift] = grid - # shift the grid by 4 pixels in each direction to fill in the padded region - for xorigin in [0, pad * 2]: - for yorigin in [0, pad * 2]: + # shift the grid by shift pixels in each direction to fill in the padded + for xorigin in [0, shift * 2]: + for yorigin in [0, shift * 2]: xslice = slice(xorigin, xorigin + grid.shape[0]) yslice = slice(yorigin, yorigin + grid.shape[1]) padded[xslice, yslice] = np.ma.where( @@ -31,4 +31,4 @@ def grid_smear(grid: np.ndarray, pad: int = 4) -> np.ndarray: padded[xslice, yslice], ) - return padded[pad:-pad, pad:-pad] + return padded[shift:-shift, shift:-shift]