diff --git a/nlmod/dims/resample.py b/nlmod/dims/resample.py index 5ed713e8..58567c6f 100644 --- a/nlmod/dims/resample.py +++ b/nlmod/dims/resample.py @@ -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) @@ -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