Skip to content

Commit

Permalink
test: add a shift before coregistration test
Browse files Browse the repository at this point in the history
  • Loading branch information
vschaffn committed Nov 19, 2024
1 parent aca9e5f commit e7f3724
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions tests/test_coreg/test_workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,9 +255,28 @@ def test_dem_coregistration(self) -> None:
out_fig.close()

# Testing different coreg method
dem_coreg, coreg_method, coreg_stats, inlier_mask = dem_coregistration(
dem_coreg2, coreg_method2, coreg_stats2, inlier_mask2 = dem_coregistration(
tba_dem, ref_dem, coreg_method=xdem.coreg.Deramp()
)
assert isinstance(coreg_method, xdem.coreg.Deramp)
assert abs(coreg_stats["med_orig"].values) > abs(coreg_stats["med_coreg"].values)
assert coreg_stats["nmad_orig"].values > coreg_stats["nmad_coreg"].values
assert isinstance(coreg_method2, xdem.coreg.Deramp)
assert abs(coreg_stats2["med_orig"].values) > abs(coreg_stats2["med_coreg"].values)
assert coreg_stats2["nmad_orig"].values > coreg_stats2["nmad_coreg"].values

# Testing with initial shift
test_shift = [10, 5]
tba_dem_shift = tba_dem.copy()
dem_coreg2, coreg_method2, coreg_stats2, inlier_mask2 = dem_coregistration(
tba_dem_shift, ref_dem, estimated_initial_shift=test_shift
)
tba_dem_shift_test = tba_dem.translate(test_shift[0] * tba_dem.res[0], test_shift[1] * tba_dem.res[1])
assert tba_dem_shift.raster_equal(tba_dem_shift_test)
assert isinstance(coreg_method2, xdem.coreg.CoregPipeline)
assert isinstance(coreg_method2.pipeline[0], xdem.coreg.AffineCoreg)
assert (
coreg_method2.pipeline[0].meta["outputs"]["affine"]["shift_x"]
== coreg_method.pipeline[0].meta["outputs"]["affine"]["shift_x"]
)
assert (
coreg_method2.pipeline[0].meta["outputs"]["affine"]["shift_y"]
== coreg_method.pipeline[0].meta["outputs"]["affine"]["shift_y"]
)

0 comments on commit e7f3724

Please sign in to comment.