Skip to content

Commit

Permalink
regrid.py: Always pass a copy to regridder.
Browse files Browse the repository at this point in the history
Somehow regridder can affect its input! This was manifesting as ds_to_regrid["time"] losing its attributes.
  • Loading branch information
samsrabin committed Sep 11, 2024
1 parent 17fd56b commit 238aff7
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/landusedata/regrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ def RegridLoop(ds_to_regrid, regridder, test):

# Once the first variable has been included, then we can regrid by variable
else:
ds_regrid[var] = regridder(ds_to_regrid[var])
# Somehow regridder() can affect its input in-place! We don't want this,
# so we pass it in as a copy.
ds_regrid[var] = regridder(ds_to_regrid[var].copy())

# Stop regridding if in test mode
if test:
Expand Down

0 comments on commit 238aff7

Please sign in to comment.