From e7f37247c3da5e197bc5ad7d3cb86ecc5302df54 Mon Sep 17 00:00:00 2001 From: vschaffn Date: Thu, 14 Nov 2024 17:43:19 +0100 Subject: [PATCH] test: add a shift before coregistration test --- tests/test_coreg/test_workflows.py | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) 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"] + )