From d347d494c8ff17e9a5e4e12b6704db4092d9ed60 Mon Sep 17 00:00:00 2001 From: Jeremy Maurer Date: Tue, 9 Nov 2021 16:15:56 -0600 Subject: [PATCH 1/2] Fix the bug, add unit tests. Heading is CW from N, ENU is from ground to sensor --- test/test_losreader.py | 19 ++++++++++++------- tools/RAiDER/losreader.py | 2 +- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/test/test_losreader.py b/test/test_losreader.py index 3a2b3fb92..4576a4835 100644 --- a/test/test_losreader.py +++ b/test/test_losreader.py @@ -192,25 +192,30 @@ def test_los_to_lv_3c(): def test_los_to_lv_4(): assert np.allclose( - inc_hd_to_enu(35, 0), - np.array([0, np.sin(np.radians(35)), np.cos(np.radians(35))]) + inc_hd_to_enu(90, 0), + np.array([0, 1, 0]) ) def test_los_to_lv_5(): assert np.allclose( - inc_hd_to_enu(35, 180), - np.array([0, -np.sin(np.radians(35)), np.cos(np.radians(35))]) + inc_hd_to_enu(90, 90), + np.array([1, 0, 0]) ) - def test_los_to_lv_6(): assert np.allclose( - inc_hd_to_enu(35, 90), - np.array([-np.sin(np.radians(35)), 0, np.cos(np.radians(35))]) + inc_hd_to_enu(90, 180), + np.array([0, -1, 0]) ) +def test_los_to_lv_7(): + assert np.allclose( + inc_hd_to_enu(90, 270), + np.array([-1, 0, 0]) + ) + def test_zenith_1(): assert np.allclose( getZenithLookVecs(np.array([0]), np.array([0]), np.array([0])), diff --git a/tools/RAiDER/losreader.py b/tools/RAiDER/losreader.py index d0fbcfb26..bacd452dc 100644 --- a/tools/RAiDER/losreader.py +++ b/tools/RAiDER/losreader.py @@ -247,7 +247,7 @@ def inc_hd_to_enu(incidence, heading): if np.any(incidence < 0): raise ValueError('inc_hd_to_enu: Incidence angle cannot be less than 0') - east = sind(incidence) * cosd(heading + 90) + east = - sind(incidence) * cosd(heading + 90) north = sind(incidence) * sind(heading + 90) up = cosd(incidence) From 4fa7cab21192083cd3ce616abcd4c161e3c42601 Mon Sep 17 00:00:00 2001 From: Jeremy Maurer Date: Tue, 9 Nov 2021 16:20:44 -0600 Subject: [PATCH 2/2] one more unit test one more unit test --- test/test_losreader.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/test_losreader.py b/test/test_losreader.py index 4576a4835..fdca1e7c6 100644 --- a/test/test_losreader.py +++ b/test/test_losreader.py @@ -216,6 +216,18 @@ def test_los_to_lv_7(): np.array([-1, 0, 0]) ) +def test_los_to_lv_8(): + assert np.allclose( + inc_hd_to_enu(45, 90), + np.array([np.sqrt(2)/2, 0, np.sqrt(2)/2]) + ) + +def test_los_to_lv_9(): + assert np.allclose( + inc_hd_to_enu(45, 180), + np.array([0, -np.sqrt(2)/2, np.sqrt(2)/2]) + ) + def test_zenith_1(): assert np.allclose( getZenithLookVecs(np.array([0]), np.array([0]), np.array([0])),