From d8e7520cf017e9559d698528549dd4b51d720d8d Mon Sep 17 00:00:00 2001 From: Jesse Mapel <jmapel@usgs.gov> Date: Wed, 20 May 2020 15:28:16 -0700 Subject: [PATCH] Added Sigma0 tests --- knoten/bundle.py | 8 ++++---- tests/test_bundle.py | 28 ++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/knoten/bundle.py b/knoten/bundle.py index 13bae31..574d4f0 100644 --- a/knoten/bundle.py +++ b/knoten/bundle.py @@ -452,13 +452,13 @@ def compute_sigma(V, dX, W_parameters, W_observations): Parameters ---------- - V : np.array - An array of residuals of the difference between registered measure - and back projected ground points in image space. + V : ndarray + An array of residuals of the difference between registered measure + and back projected ground points in image space. dX : ndarray The array of parameter updates W_parameters: ndarray - The parameter weight matrix (i.e.: sensor parameters and point weights) + The parameter weight matrix (i.e.: sensor parameters and point weights) W_observations : ndarray The observation weight matrix (i.e.: measure weights) diff --git a/tests/test_bundle.py b/tests/test_bundle.py index b1265d3..4f5aaaa 100644 --- a/tests/test_bundle.py +++ b/tests/test_bundle.py @@ -171,3 +171,31 @@ def test_compute_residuals(control_network, sensors): V = bundle.compute_residuals(control_network, sensors) assert V.shape == (18,) np.testing.assert_allclose(V, [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, -0.9, -0.8, -0.7, -0.6, -0.5, -0.4, -0.3, -0.2, -0.1]) + +def test_compute_sigma0(): + V = np.arange(0, 16) + 1 + W_obs = np.diag(np.arange(16, 0, -1)) + W_params = np.array( + [[1, 2, 3, 0, 0, 0], + [4, 5, 6, 0, 0, 0], + [7, 8, 9, 0, 0, 0], + [0, 0, 0, -1, -2, -3], + [0, 0, 0, -4, -5, -6], + [0, 0, 0, -7, -8, -9]] + ) + dX = np.arange(-6, 0) + assert bundle.compute_sigma(V, dX, W_params, W_obs) == np.sqrt(7809 / 10) + +def test_compute_sigma0_sparse(): + V = np.arange(0, 16) + 1 + W_obs = np.diag(np.arange(16, 0, -1)) + W_sensors = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) + W_points = { + "point_1" : np.array([[-1, -2, -3], [-4, -5, -6], [-7, -8, -9]]) + } + dX = np.arange(-6, 0) + column_dict = { + "image_1" : (0, 3), + "point_1" : (3, 6) + } + assert bundle.compute_sigma_sparse(V, dX, W_sensors, W_points, W_obs, column_dict) == np.sqrt(7809 / 10) -- GitLab