def test_icp_opencv(self): warnings.simplefilter("error") # Do a fast an dirty 3 iteration ICP just to make sure it doesn't error out. icp = coreg.ICP(max_iterations=3) icp.fit(**self.fit_params) aligned_dem = icp.apply(self.tba.data, self.ref.transform) assert aligned_dem.shape == self.ref.data.squeeze().shape
def test_all_nans(self): """Check that the coregistration approaches fail gracefully when given only nans.""" dem1 = np.ones((50, 50), dtype=float) dem2 = dem1.copy() + np.nan affine = rio.transform.from_origin(0, 0, 1, 1) biascorr = coreg.BiasCorr() icp = coreg.ICP() pytest.raises(ValueError, biascorr.fit, dem1, dem2, transform=affine) pytest.raises(ValueError, icp.fit, dem1, dem2, transform=affine) dem2[[3, 20, 40], [2, 21, 41]] = 1.2 biascorr.fit(dem1, dem2, transform=affine) pytest.raises(ValueError, icp.fit, dem1, dem2, transform=affine)
# Apply the bias to a DEM corrected_dem = bias_corr.apply(tba_data, transform=dem_to_be_aligned.transform) # Use median bias instead bias_median = coreg.BiasCorr(bias_func=np.median) # bias_median.fit(... # etc. ############## # SECTION: ICP ############## # Instantiate the object with default parameters icp = coreg.ICP() # Fit the data to a suitable transformation. icp.fit(ref_data, tba_data, transform=transform, inlier_mask=inlier_mask) # Apply the transformation matrix to the data (or any other data) aligned_dem = icp.apply(tba_data, transform=transform) ################### # SECTION: Pipeline ################### pipeline = coreg.CoregPipeline([coreg.BiasCorr(), coreg.ICP()]) # pipeline.fit(... # etc. # This works identically to the syntax above