Skip to content

Commit

Permalink
test: replace moving_to_next_line and moving_along_lines
Browse files Browse the repository at this point in the history
  • Loading branch information
adebardo committed Nov 13, 2023
1 parent 8bca507 commit d5a2e78
Showing 1 changed file with 47 additions and 10 deletions.
57 changes: 47 additions & 10 deletions tests/geofunctions/test_rectification.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@
compute_epipolar_angle,
compute_stereorectification_epipolar_grids,
get_epipolar_extent,
moving_along_lines,
moving_to_next_line,
moving_along_axis,
prepare_rectification,
)
from shareloc.geofunctions.rectification_grid import RectificationGrid
Expand Down Expand Up @@ -506,7 +505,7 @@ def test_prepare_rectification_footprint():


@pytest.mark.unit_tests
def test_rectification_moving_along_line():
def test_rectification_moving_along_lines():
"""
Test moving along line in epipolar geometry
"""
Expand All @@ -517,7 +516,7 @@ def test_rectification_moving_along_line():
os.path.join(data_path(), "rectification", "right_image.geom"), topleftconvention=True
)

current_left_coords = np.array([[5000.5, 5000.5, 0.0]], dtype=np.float64)
current_coords = np.array([[5000.5, 5000.5, 0.0]], dtype=np.float64)
mean_spacing = 1
epi_step = 1
alphas = 0
Expand All @@ -527,8 +526,15 @@ def test_rectification_moving_along_line():
col_pixel_size = 1.0
reference_next_cords = np.array([[5000.5, 5000.5 + col_pixel_size, 0.0]], dtype=np.float64)

next_cords, _ = moving_along_lines(
geom_model_left, geom_model_right, current_left_coords, mean_spacing, default_elev, epi_step, alphas
next_cords, _ = moving_along_axis(
geom_model_left,
geom_model_right,
current_coords,
mean_spacing,
default_elev,
epi_step,
alphas,
1,
)

np.testing.assert_array_equal(reference_next_cords, next_cords)
Expand All @@ -546,23 +552,54 @@ def test_rectification_moving_to_next_line():
os.path.join(data_path(), "rectification", "right_image.geom"), topleftconvention=True
)

current_left_coords = np.array([5000.5, 5000.5, 0.0], dtype=np.float64)
current_coords = np.array([[5000.5, 5000.5, 0.0]], dtype=np.float64)
mean_spacing = 1
epi_step = 1
alphas = 0
default_elev = 0.0
# ground truth next pixel
# row pixel size of the image
row_pixel_size = 1.0
reference_next_cords = np.array([5000.5 + row_pixel_size, 5000.5, 0.0], dtype=np.float64)
reference_next_cords = np.array([[5000.5 + row_pixel_size, 5000.5, 0.0]], dtype=np.float64)

next_cords, _ = moving_to_next_line(
geom_model_left, geom_model_right, current_left_coords, mean_spacing, default_elev, epi_step, alphas
next_cords, _ = moving_along_axis(
geom_model_left,
geom_model_right,
current_coords,
mean_spacing,
default_elev,
epi_step,
alphas,
0,
)

np.testing.assert_array_equal(reference_next_cords, next_cords)


@pytest.mark.unit_tests
def test_rectification_moving_to_axis_error():
"""
Test moving along axis with wrong axis
"""
geom_model_left = RPC.from_any(
os.path.join(data_path(), "rectification", "left_image.geom"), topleftconvention=True
)
geom_model_right = RPC.from_any(
os.path.join(data_path(), "rectification", "right_image.geom"), topleftconvention=True
)

current_coords = np.array([5000.5, 5000.5, 0.0], dtype=np.float64)
mean_spacing = 1
epi_step = 1
alphas = 0
default_elev = 0.0

with pytest.raises(ValueError):
_, _ = moving_along_axis(
geom_model_left, geom_model_right, current_coords, mean_spacing, default_elev, epi_step, alphas, 2
)


@pytest.mark.unit_tests
def test_epipolar_angle():
"""
Expand Down

0 comments on commit d5a2e78

Please sign in to comment.