Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion imap_processing/glows/l1a/glows_l1a.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def process_de_l0(
l1a_output.append(first_de)

# Filter out DE records with no direct_events (incomplete packet sequences)
l1a_output = [de for de in l1a_output if de.direct_events is not None]
l1a_output = [de for de in l1a_output if de.direct_events]

return l1a_output

Expand Down
8 changes: 8 additions & 0 deletions imap_processing/glows/l1a/glows_l1a_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,14 @@ def _generate_direct_events(self, direct_events: bytearray) -> list[DirectEvent]
An array containing DirectEvent objects.
"""
# read the first direct event, which is always uncompressed

if len(direct_events) < 8:
logger.warning(
"GLOWS: Direct event data is too short to contain any events "
f"(got {len(direct_events)} bytes, need at least 8). "
"Returning empty event list."
)
return []
current_event = self._build_uncompressed_event(direct_events[:8])
processed_events = [current_event]

Expand Down
3 changes: 2 additions & 1 deletion imap_processing/tests/external_test_data_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,5 +277,6 @@
("swe_l0_unpacked-data_20240510_v001_VALIDATION_L2_bins_v0H_14_6.dat", "swe/l2_validation/"),

# GLOWS
("combined_de_l1a.csv", "glows/validation_data")
("combined_de_l1a.csv", "glows/validation_data"),
("imap_glows_l0_raw_20260202-repoint00145_v001.pkts", "glows/validation_data"),
] # fmt: skip
10 changes: 10 additions & 0 deletions imap_processing/tests/glows/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@ def packet_path():
return current_directory / "validation_data" / "glows_test_packet_20110921_v01.pkts"


@pytest.fixture
def repoint_packet_path():
current_directory = Path(__file__).parent
return (
current_directory
/ "validation_data"
/ "imap_glows_l0_raw_20260202-repoint00145_v001.pkts"
)


@pytest.fixture
def decom_test_data(packet_path):
"""Read test data from file"""
Expand Down
8 changes: 8 additions & 0 deletions imap_processing/tests/glows/test_glows_l1a_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -589,3 +589,11 @@ def test_glows_l1a_no_packet_data(decom_packets_mock):
decom_packets_mock.return_value = ([], [])
output = glows_l1a("fake/filepath/packets.bin")
assert output == []


@pytest.mark.external_test_data
def test_glows_l1a_empty_de_packet(repoint_packet_path):
"""Test that L1A processing handles packets with no direct event data."""
result = glows_l1a(repoint_packet_path)

assert len(result) == 2
Loading