From d78c60be057a655125752aed09e9ee2397c7848c Mon Sep 17 00:00:00 2001 From: Laura Sandoval Date: Tue, 20 Aug 2024 13:40:42 -0600 Subject: [PATCH] code cov update --- imap_processing/pointing_frame_handler.py | 2 +- .../test_pointing_frame_handler.py | 24 ++++++++++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/imap_processing/pointing_frame_handler.py b/imap_processing/pointing_frame_handler.py index 14030b5a1..dd6444d4f 100644 --- a/imap_processing/pointing_frame_handler.py +++ b/imap_processing/pointing_frame_handler.py @@ -100,7 +100,7 @@ def average_quaternions(et_times: np.ndarray) -> tuple[np.ndarray, list[np.ndarr body_quat = body_quat * np.sign(body_quat[0]) # Aggregate quaternions into a single matrix. - aggregate += np.outer(np.abs(body_quat), body_quat) + aggregate += np.outer(body_quat, body_quat) # Reference: "On Averaging Rotations" # Link: https://link.springer.com/content/pdf/10.1023/A:1011129215388.pdf diff --git a/imap_processing/tests/pointing_frame/test_pointing_frame_handler.py b/imap_processing/tests/pointing_frame/test_pointing_frame_handler.py index 31a9c892b..8e089c62f 100644 --- a/imap_processing/tests/pointing_frame/test_pointing_frame_handler.py +++ b/imap_processing/tests/pointing_frame/test_pointing_frame_handler.py @@ -60,13 +60,35 @@ def et_times(create_kernel_list): """Tests get_coverage function.""" kernels, ck_kernel = create_kernel_list + with spice.KernelPool(kernels): + et_start, et_end, et_times = get_coverage(str(ck_kernel[0])) + + return et_times + + +@pytest.mark.xfail(reason="Will fail unless kernels in pointing_frame/test_data.") +def test_get_coverage(create_kernel_list): + """Tests get_coverage function.""" + kernels, ck_kernel = create_kernel_list + with spice.KernelPool(kernels): et_start, et_end, et_times = get_coverage(str(ck_kernel[0])) assert et_start == 802008069.184905 assert et_end == 802094467.184905 - return et_times + +@pytest.mark.xfail(reason="Will fail unless kernels in pointing_frame/test_data.") +def test_average_quaternions(et_times, create_kernel_list): + """Tests average_quaternions function.""" + + kernels, ck_kernel = create_kernel_list + with spice.KernelPool(kernels): + q_avg, z_eclip_time = average_quaternions(et_times) + + # Generated from MATLAB code results + q_avg_expected = np.array([-0.6838, 0.5480, -0.4469, -0.1802]) + np.testing.assert_allclose(q_avg, q_avg_expected, atol=1e-4) @pytest.mark.xfail(reason="Will fail unless kernels in pointing_frame/test_data.")