From 47c34ac8fbf87a04f552d767b290d6c9d52019b7 Mon Sep 17 00:00:00 2001 From: Matthew Bourque Date: Tue, 13 Feb 2024 12:56:59 -0700 Subject: [PATCH 1/2] Fixed path issues with IDEX tests; added module docstrings; changed name of test file to reflect naming convention --- ...imap_idex_l0_raw_20230725_20230725_v01-00.pkts} | Bin imap_processing/tests/idex/test_decom.py | 13 +++++++++++-- imap_processing/tests/idex/test_l1_cdfs.py | 13 ++++++++++--- 3 files changed, 21 insertions(+), 5 deletions(-) rename imap_processing/tests/idex/{imap_idex_l0_20230725_v01-00.pkts => imap_idex_l0_raw_20230725_20230725_v01-00.pkts} (100%) diff --git a/imap_processing/tests/idex/imap_idex_l0_20230725_v01-00.pkts b/imap_processing/tests/idex/imap_idex_l0_raw_20230725_20230725_v01-00.pkts similarity index 100% rename from imap_processing/tests/idex/imap_idex_l0_20230725_v01-00.pkts rename to imap_processing/tests/idex/imap_idex_l0_raw_20230725_20230725_v01-00.pkts diff --git a/imap_processing/tests/idex/test_decom.py b/imap_processing/tests/idex/test_decom.py index 403c39185..b5c353355 100644 --- a/imap_processing/tests/idex/test_decom.py +++ b/imap_processing/tests/idex/test_decom.py @@ -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): @@ -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() diff --git a/imap_processing/tests/idex/test_l1_cdfs.py b/imap_processing/tests/idex/test_l1_cdfs.py index d419ae22b..f2cb200d7 100644 --- a/imap_processing/tests/idex/test_l1_cdfs.py +++ b/imap_processing/tests/idex/test_l1_cdfs.py @@ -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): @@ -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") From 7b9f2855dbee0bba4e29e66593bb8112677a5d05 Mon Sep 17 00:00:00 2001 From: Matthew Bourque Date: Tue, 13 Feb 2024 12:58:50 -0700 Subject: [PATCH 2/2] Fixed path issue in HIT tests --- imap_processing/tests/hit/test_hit_decom.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/imap_processing/tests/hit/test_hit_decom.py b/imap_processing/tests/hit/test_hit_decom.py index 7cca2edae..cf491a289 100644 --- a/imap_processing/tests/hit/test_hit_decom.py +++ b/imap_processing/tests/hit/test_hit_decom.py @@ -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