Skip to content

Commit

Permalink
Fixed path issues with IDEX tests; added module docstrings; changed n…
Browse files Browse the repository at this point in the history
…ame of test file to reflect naming convention
  • Loading branch information
bourque committed Feb 13, 2024
1 parent 96be9a0 commit 47c34ac
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
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 47c34ac

Please sign in to comment.