@@ -454,6 +454,7 @@ def _nuth_kaab_iteration_step(
454
454
aspect : NDArrayf ,
455
455
res : tuple [int , int ],
456
456
params_fit_bin : InFitOrBinDict ,
457
+ apply_vertical_shift : bool = True ,
457
458
) -> tuple [tuple [float , float , float ], float ]:
458
459
"""
459
460
Iteration step of Nuth and Kääb (2011), passed to the iterate_method function.
@@ -466,6 +467,7 @@ def _nuth_kaab_iteration_step(
466
467
:param slope_tan: Array of slope tangent.
467
468
:param aspect: Array of aspect.
468
469
:param res: Resolution of DEM.
470
+ :param apply_vertical_shift: Whether to apply the vertical shift or not (default is True).
469
471
"""
470
472
471
473
# Calculate the elevation difference with offsets
@@ -497,7 +499,7 @@ def _nuth_kaab_iteration_step(
497
499
new_coords_offsets = (
498
500
coords_offsets [0 ] + easting_offset * res [0 ],
499
501
coords_offsets [1 ] + northing_offset * res [1 ],
500
- float (vshift ),
502
+ float (vshift ) if apply_vertical_shift else 0 ,
501
503
)
502
504
503
505
# Compute statistic on offset to know if it reached tolerance
@@ -520,6 +522,7 @@ def nuth_kaab(
520
522
params_random : InRandomDict ,
521
523
z_name : str ,
522
524
weights : NDArrayf | None = None ,
525
+ apply_vertical_shift : bool = True ,
523
526
** kwargs : Any ,
524
527
) -> tuple [tuple [float , float , float ], int ]:
525
528
"""
@@ -565,7 +568,14 @@ def nuth_kaab(
565
568
res = _res (transform )
566
569
# Iterate through method of Nuth and Kääb (2011) until tolerance or max number of iterations is reached
567
570
assert sub_aux_vars is not None # Mypy: dictionary cannot be None here
568
- constant_inputs = (sub_dh_interpolator , sub_aux_vars ["slope_tan" ], sub_aux_vars ["aspect" ], res , params_fit_or_bin )
571
+ constant_inputs = (
572
+ sub_dh_interpolator ,
573
+ sub_aux_vars ["slope_tan" ],
574
+ sub_aux_vars ["aspect" ],
575
+ res ,
576
+ params_fit_or_bin ,
577
+ apply_vertical_shift ,
578
+ )
569
579
final_offsets = _iterate_method (
570
580
method = _nuth_kaab_iteration_step ,
571
581
iterating_input = initial_offset ,
@@ -1287,6 +1297,7 @@ def __init__(
1287
1297
bin_sizes : int | dict [str , int | Iterable [float ]] = 72 ,
1288
1298
bin_statistic : Callable [[NDArrayf ], np .floating [Any ]] = np .nanmedian ,
1289
1299
subsample : int | float = 5e5 ,
1300
+ apply_vertical_shift : bool = True ,
1290
1301
) -> None :
1291
1302
"""
1292
1303
Instantiate a new Nuth and Kääb (2011) coregistration object.
@@ -1299,8 +1310,11 @@ def __init__(
1299
1310
:param bin_sizes: Size (if integer) or edges (if iterable) for binning variables later passed in .fit().
1300
1311
:param bin_statistic: Statistic of central tendency (e.g., mean) to apply during the binning.
1301
1312
:param subsample: Subsample the input for speed-up. <1 is parsed as a fraction. >1 is a pixel count.
1313
+ :param apply_vertical_shift: Whether to apply the vertical shift or not (default is True).
1302
1314
"""
1303
1315
1316
+ self .apply_vertical_shift = apply_vertical_shift
1317
+
1304
1318
# Input checks
1305
1319
_check_inputs_bin_before_fit (
1306
1320
bin_before_fit = bin_before_fit , fit_optimizer = fit_optimizer , bin_sizes = bin_sizes , bin_statistic = bin_statistic
@@ -1390,6 +1404,7 @@ def _fit_rst_pts(
1390
1404
params_fit_or_bin = params_fit_or_bin ,
1391
1405
max_iterations = self ._meta ["inputs" ]["iterative" ]["max_iterations" ],
1392
1406
tolerance = self ._meta ["inputs" ]["iterative" ]["tolerance" ],
1407
+ apply_vertical_shift = self .apply_vertical_shift ,
1393
1408
)
1394
1409
1395
1410
# Write output to class
0 commit comments