From 808021dd3ceeb65058c50d130bf000560da8c0c8 Mon Sep 17 00:00:00 2001 From: konstntokas Date: Thu, 16 Jan 2025 17:13:42 +0100 Subject: [PATCH] address Norman's review --- xcube/core/resampling/spatial.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/xcube/core/resampling/spatial.py b/xcube/core/resampling/spatial.py index 22b3e79b3..05c6dc4e9 100644 --- a/xcube/core/resampling/spatial.py +++ b/xcube/core/resampling/spatial.py @@ -209,16 +209,17 @@ def resample_in_space( # transform the source_gm so its CRS matches the target CRS: transformed_source_gm = source_gm.transform(target_gm.crs, xy_res=target_gm.xy_res) source_ds = source_ds.drop_vars(source_gm.xy_dim_names) - if "crs" in source_ds: - source_ds = source_ds.drop_vars("crs") - if "spatial_ref" in source_ds: - source_ds = source_ds.drop_vars("spatial_ref") - source_ds = source_ds.copy() for var in source_ds.data_vars: if "grid_mapping" in source_ds[var].attrs: attrs = source_ds[var].attrs + source_ds = source_ds.drop_vars(attrs["grid_mapping"]) del attrs["grid_mapping"] source_ds[var] = source_ds[var].assign_attrs(attrs) + if "crs" in source_ds: + source_ds = source_ds.drop_vars("crs") + if "spatial_ref" in source_ds: + source_ds = source_ds.drop_vars("spatial_ref") + source_ds = source_ds.copy() transformed_x, transformed_y = transformed_source_gm.xy_coords attrs = dict(grid_mapping="spatial_ref") transformed_x.attrs = attrs