Skip to content

Commit

Permalink
codacy
Browse files Browse the repository at this point in the history
  • Loading branch information
dbrakenhoff committed Mar 13, 2023
1 parent c2bb7a0 commit 2a2e805
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions nlmod/dims/resample.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,9 +474,9 @@ def structured_da_to_ds(da, ds, method="average", nodata=np.NaN):
kwargs = {}
if ds.gridtype == "structured":
kwargs["fill_value"] = "extrapolate"

da_out = da.interp(x=ds.x, y=ds.y, method=method, kwargs=kwargs)

# some stuff is added by the interp function that should not be there
added_coords = set(da_out.coords) - set(ds.coords)
return da_out.drop_vars(added_coords)
Expand Down Expand Up @@ -532,16 +532,16 @@ def structured_da_to_ds(da, ds, method="average", nodata=np.NaN):
# some stuff is added by the reproject_match function that should not be there
added_coords = set(da_out.coords) - set(ds.coords)
da_out = da_out.drop_vars(added_coords)

if "grid_mapping" in da_out.encoding:
del da_out.encoding["grid_mapping"]

# remove the long_name, standard_name and units attributes of the x and y coordinates
for coord in ['x', 'y']:
for name in ['long_name', 'standard_name', 'units', 'axis']:
for coord in ["x", "y"]:
for name in ["long_name", "standard_name", "units", "axis"]:
if name in da_out[coord].attrs.keys():
del da_out[coord].attrs[name]

return da_out


Expand Down

0 comments on commit 2a2e805

Please sign in to comment.