Skip to content

Commit

Permalink
revert last 2 commits but keeping enhanced tests
Browse files Browse the repository at this point in the history
  • Loading branch information
konstntokas committed Jan 15, 2025
1 parent c72acb4 commit 61fbcda
Showing 1 changed file with 13 additions and 24 deletions.
37 changes: 13 additions & 24 deletions xcube/core/resampling/spatial.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,34 +208,23 @@ def resample_in_space(
# If CRSes are not both geographic and their CRSes are different
# 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
# del attrs["grid_mapping"]
# source_ds[var] = source_ds[var].assign_attrs(attrs)
# transformed_x, transformed_y = transformed_source_gm.xy_coords
# attrs = dict(grid_mapping="spatial_ref")
# transformed_x.attrs = attrs
# transformed_y.attrs = attrs
# source_ds = source_ds.assign_coords(
# spatial_ref=xr.DataArray(0, attrs=transformed_source_gm.crs.to_cf()),
# transformed_x=transformed_x,
# transformed_y=transformed_y,
# )
source_ds = source_ds.drop_vars(source_gm.xy_dim_names)
if "crs" in source_ds:
source_ds = source_ds.drop_vars("crs")

Check warning on line 213 in xcube/core/resampling/spatial.py

View check run for this annotation

Codecov / codecov/patch

xcube/core/resampling/spatial.py#L213

Added line #L213 was not covered by tests
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
del attrs["grid_mapping"]
source_ds[var] = source_ds[var].assign_attrs(attrs)
transformed_x, transformed_y = transformed_source_gm.xy_coords
attrs = dict(grid_mapping="transformed_spatial_ref")
attrs = dict(grid_mapping="spatial_ref")
transformed_x.attrs = attrs
transformed_y.attrs = attrs
source_ds = source_ds.assign_coords(
transformed_spatial_ref=xr.DataArray(
0, attrs=transformed_source_gm.crs.to_cf()
),
spatial_ref=xr.DataArray(0, attrs=transformed_source_gm.crs.to_cf()),
transformed_x=transformed_x,
transformed_y=transformed_y,
)
Expand Down

0 comments on commit 61fbcda

Please sign in to comment.