Skip to content

Commit

Permalink
fix(resample_to_grid): fix unintended extrapolation (modflowpy#2331)
Browse files Browse the repository at this point in the history
* remove nan masking from standard scipy resampling methods
* allow extrapolate_edges kwarg to be applied to nearest neighbor resampling
  • Loading branch information
jlarsen-usgs authored Oct 9, 2024
1 parent 99d57e6 commit 15f1b94
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions flopy/utils/rasters.py
Original file line number Diff line number Diff line change
Expand Up @@ -537,13 +537,6 @@ def resample_to_grid(
arr = self.get_array(band, masked=True)
arr = arr.flatten()

# filter out nan values from the original dataset
if np.isnan(np.sum(arr)):
idx = np.isfinite(arr)
rxc = rxc[idx]
ryc = ryc[idx]
arr = arr[idx]

# step 3: use griddata interpolation to snap to grid
data = griddata(
(rxc, ryc),
Expand Down Expand Up @@ -574,7 +567,7 @@ def resample_to_grid(
else:
raise TypeError(f"{method} method not supported")

if extrapolate_edges and method != "nearest":
if extrapolate_edges:
xc = modelgrid.xcellcenters
yc = modelgrid.ycellcenters

Expand Down

0 comments on commit 15f1b94

Please sign in to comment.