Initial shift in case of CoregPipeline - #992
Conversation
| reference_elev = reference_elev.translate(-shift_x, -shift_y) # type: ignore | ||
| initial_shift_apply = True | ||
| else: | ||
| transform = _translate(transform, xoff=-shift_x, yoff=-shift_y) |
There was a problem hiding this comment.
Case if ref_dem is an array
| # We only run this step if it's not the last, otherwise it is unused! | ||
| if i != (len(self.pipeline) - 1): | ||
| if isinstance(tba_dem_mod, gpd.GeoDataFrame): | ||
| if isinstance(tba_dem_mod, (Raster, gpd.GeoDataFrame, PointCloud)): |
There was a problem hiding this comment.
fit the apply returns management
| shift_z = coreg.meta["outputs"]["affine"].get("shift_z", np.nan) | ||
|
|
||
| x, y = ( | ||
| x, y = to_be_aligned_elev.transform * ( |
| assert dem_aligned.raster_equal(manually_aligned, warn_failure_reason=True) | ||
|
|
||
| @staticmethod | ||
| @pytest.mark.parametrize( |
There was a problem hiding this comment.
move the "tests" in test_affine with the others
There was a problem hiding this comment.
I created a new pipeline.py module in #759. I'm going to have fun merging 😅
| for method in pipelines[1:]: | ||
| if "affine" in method.meta["inputs"] and "initial_shift" in method.meta["inputs"]["affine"]: | ||
| warnings.warn( | ||
| message="No initial shift can be initialized in a coregistration pipeline other " |
There was a problem hiding this comment.
I think we need to more precise on what is done: We override. And repeat for every step:
"No initial shift can be defined in a coregistration pipeline other than for the first step. Overridding to initial_shift=None for step number {X}. Remove initial shift parameters outside of the first step to silence this warning."
There was a problem hiding this comment.
Great, thanks! As I commented separately before, I still think we need to move the logic to CoregPipeline.__init__, because this is the function that actually chains the step, and its class description is public.
So someone could do CoregPipeline([NuthKaab(), NuthKaab(initial_shift=(2, 2, 2))]) and it would not raise an error/warning, yet be correctly documented code. This would be a problem.
Resolves #801
This PR proposes the option to use the
initial_shiftparameter in a coregistration pipeline.Behavior
initial_shiftin the first method of the Pipelineinitial_shiftin all other method afterError message : No initial shift can be initialized in a coregistration pipeline other than for the first element.
Development Information
Initial Shift management
Currently, removing all the initial shift was done in:
Coreg.__add__: to managecoreg1 + coreg2CoregPipeline.__add__: to managecoreg1 + coreg2 + coreg3(=coregPipeline1 + coreg3) andCoregPileline(list_of_coreg)I kept this strategy but without deleting the initial_shift for the:
Coreg.__add__pipeline[0])initial_shiftinCoregPipeline.__add__Preprocessing
Had to remove the preprocess in the

CoregPipeline.fit()here and only use the existing preprocess in theCoreg.fit()to have the same result betweencoreg1 + xandcoreg1in case of aninitial_shift