Skip to content

Commit

Permalink
Merge pull request IMAP-Science-Operations-Center#337 from bourque/fi…
Browse files Browse the repository at this point in the history
…x-test-paths-idex-hit

Fix IDEX and HIT tests
  • Loading branch information
bourque authored Feb 13, 2024
2 parents 96be9a0 + 7b9f285 commit 497d446
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 9 deletions.
7 changes: 3 additions & 4 deletions imap_processing/tests/hit/test_hit_decom.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import pytest

from imap_processing import imap_module_directory
from imap_processing.hit.l0 import hit_l1a_decom


@pytest.fixture(scope="session")
def decom_test_data():
"""Read test data from file"""
packet_file = (
"imap_processing/tests/hit/PREFLIGHT_raw_record_2023_256_15_59_04_apid1251.pkts"
)
xtce = "imap_processing/hit/packet_definitions/P_HIT_HSKP.xml"
packet_file = f"{imap_module_directory}/tests/hit/PREFLIGHT_raw_record_2023_256_15_59_04_apid1251.pkts" # noqa
xtce = f"{imap_module_directory}/hit/packet_definitions/P_HIT_HSKP.xml"
data_packet_list = hit_l1a_decom.decom_hit_packets(packet_file, xtce)
return data_packet_list

Expand Down
13 changes: 11 additions & 2 deletions imap_processing/tests/idex/test_decom.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
"""Tests the decommutation process for IDEX CCSDS Packets."""

from pathlib import Path

import numpy as np
import pytest

from imap_processing import imap_module_directory
from imap_processing.idex.idex_packet_parser import PacketParser


@pytest.fixture(scope="session")
def decom_test_data():
return PacketParser("imap_processing/tests/idex/imap_idex_l0_20230725_v01-00.pkts")
test_file = Path(
f"{imap_module_directory}/tests/idex/imap_idex_l0_raw_20230725_20230725_v01-00.pkts"
)
return PacketParser(test_file)


def test_idex_decom_length(decom_test_data):
Expand All @@ -23,6 +31,7 @@ def test_idex_decom_event_num(decom_test_data):
def test_idex_tof_high_data(decom_test_data):
# Verify that a sample of the data is correct
# impact_14_tof_high_data.txt has been verified correct by the IDEX team
with open("imap_processing/tests/idex/impact_14_tof_high_data.txt") as f:

with open(f"{imap_module_directory}/tests/idex/impact_14_tof_high_data.txt") as f:
data = np.array([int(line.rstrip("\n")) for line in f])
assert (decom_test_data.data["TOF_High"][13].data == data).all()
13 changes: 10 additions & 3 deletions imap_processing/tests/idex/test_l1_cdfs.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
"""Tests the L1 processing for decommutated IDEX data"""

from pathlib import Path

import numpy as np
import pytest
import xarray as xr
from cdflib.xarray import cdf_to_xarray
from cdflib.xarray.xarray_to_cdf import ISTPError

from imap_processing import idex
from imap_processing import idex, imap_module_directory
from imap_processing.cdf.utils import write_cdf
from imap_processing.idex.idex_packet_parser import PacketParser


@pytest.fixture()
def decom_test_data():
return PacketParser("imap_processing/tests/idex/imap_idex_l0_20230725_v01-00.pkts")
test_file = Path(
f"{imap_module_directory}/tests/idex/imap_idex_l0_raw_20230725_20230725_v01-00.pkts"
)
return PacketParser(test_file)


def test_idex_cdf_file(decom_test_data):
Expand Down Expand Up @@ -75,7 +82,7 @@ def test_descriptor_in_file_name(decom_test_data):
def test_idex_tof_high_data_from_cdf(decom_test_data):
# Verify that a sample of the data is correct inside the CDF file
# impact_14_tof_high_data.txt has been verified correct by the IDEX team
with open("imap_processing/tests/idex/impact_14_tof_high_data.txt") as f:
with open(f"{imap_module_directory}/tests/idex/impact_14_tof_high_data.txt") as f:
data = np.array([int(line.rstrip()) for line in f])

file_name = write_cdf(decom_test_data.data, descriptor="test")
Expand Down

0 comments on commit 497d446

Please sign in to comment.