Skip to content

Commit

Permalink
code cov update
Browse files Browse the repository at this point in the history
  • Loading branch information
laspsandoval committed Aug 20, 2024
1 parent 32bcb30 commit f08ed2b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 9 deletions.
8 changes: 3 additions & 5 deletions imap_processing/pointing_frame_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,6 @@ def get_coverage(ck_kernel: str) -> tuple[float, float, np.ndarray]:
et_times : numpy.ndarray
Array of times between et_start and et_end.
"""
# Each spin is 15 seconds. We want 10 quaternions per spin.
# duration / # samples (nominally 15/10 = 1.5 seconds)
step = 1.5

# Get the spacecraft ID.
# https://spiceypy.readthedocs.io/en/main/documentation.html#spiceypy.spiceypy.gipool
id_imap_spacecraft = spice.gipool("FRAME_IMAP_SPACECRAFT", 0, 1)
Expand All @@ -64,7 +60,9 @@ def get_coverage(ck_kernel: str) -> tuple[float, float, np.ndarray]:
cover = spice.ckcov(ck_kernel, int(id_imap_spacecraft), True, "SEGMENT", 0, "TDB")
# https://spiceypy.readthedocs.io/en/main/documentation.html#spiceypy.spiceypy.wnfetd
et_start, et_end = spice.wnfetd(cover, 0)
et_times = np.arange(et_start, et_end, step)
# Each spin is 15 seconds. We want 10 quaternions per spin.
# duration / # samples (nominally 15/10 = 1.5 seconds)
et_times = np.arange(et_start, et_end, 1.5)

return et_start, et_end, et_times

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ def create_kernel_list(kernel_path):
return kernels, ck_kernel


@pytest.mark.xfail(reason="Will fail unless kernels in pointing_frame/test_data.")
def test_get_coverage(create_kernel_list):
@pytest.fixture()
def et_times(create_kernel_list):
"""Tests get_coverage function."""
kernels, ck_kernel = create_kernel_list

Expand All @@ -66,8 +66,27 @@ def test_get_coverage(create_kernel_list):
assert et_start == 802008069.184905
assert et_end == 802094467.184905

return et_times


def test_create_rotation_matrix(et_times, kernel_path):
"""Tests create_rotation_matrix function."""

kernels = [str(file) for file in kernel_path.iterdir()]

with spice.KernelPool(kernels):
rotation_matrix, z_avg = create_rotation_matrix(et_times)

rotation_matrix_expected = np.array(
[[0.0000, 0.0000, 1.0000], [0.9104, -0.4136, 0.0000], [0.4136, 0.9104, 0.0000]]
)
z_avg_expected = np.array([0.4136, 0.9104, 0.0000])

np.testing.assert_allclose(z_avg, z_avg_expected, atol=1e-4)
np.testing.assert_allclose(rotation_matrix, rotation_matrix_expected, atol=1e-4)


@pytest.mark.xfail(reason="Will fail unless kernels in pointing_frame/test_data.")
# @pytest.mark.xfail(reason="Will fail unless kernels in pointing_frame/test_data.")
def test_create_pointing_frame(monkeypatch, kernel_path, create_kernel_list):
"""Tests create_pointing_frame function."""
monkeypatch.setenv("EFS_MOUNT_PATH", str(kernel_path))
Expand All @@ -93,7 +112,7 @@ def test_create_pointing_frame(monkeypatch, kernel_path, create_kernel_list):
np.testing.assert_allclose(rotation_matrix_1, rotation_matrix_expected, atol=1e-4)


@pytest.mark.xfail(reason="Will fail unless kernels in pointing_frame/test_data.")
# @pytest.mark.xfail(reason="Will fail unless kernels in pointing_frame/test_data.")
def test_z_axis(create_kernel_list):
"""Tests Inertial z axis and provides visualization."""
kernels, ck_kernel = create_kernel_list
Expand Down

0 comments on commit f08ed2b

Please sign in to comment.