diff --git a/tests/test_coreg/test_workflows.py b/tests/test_coreg/test_workflows.py index 388f7be4..f111ee30 100644 --- a/tests/test_coreg/test_workflows.py +++ b/tests/test_coreg/test_workflows.py @@ -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"] + )