Skip to content

Commit 737b248

Browse files
committed
glows bugfix
1 parent 6508b63 commit 737b248

5 files changed

Lines changed: 30 additions & 2 deletions

File tree

imap_processing/glows/l1a/glows_l1a.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ def process_de_l0(
136136
l1a_output.append(first_de)
137137

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

141141
return l1a_output
142142

imap_processing/glows/l1a/glows_l1a_data.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,16 @@ def _generate_direct_events(self, direct_events: bytearray) -> list[DirectEvent]
441441
An array containing DirectEvent objects.
442442
"""
443443
# read the first direct event, which is always uncompressed
444+
445+
if len(direct_events) < 8:
446+
print(direct_events)
447+
logger.warning(
448+
"GLOWS: Direct event data is too short to contain any events "
449+
f"(got {len(direct_events)} bytes, need at least 8). "
450+
"Returning empty event list."
451+
)
452+
return []
453+
print(direct_events[:8])
444454
current_event = self._build_uncompressed_event(direct_events[:8])
445455
processed_events = [current_event]
446456

imap_processing/tests/external_test_data_config.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,5 +277,6 @@
277277
("swe_l0_unpacked-data_20240510_v001_VALIDATION_L2_bins_v0H_14_6.dat", "swe/l2_validation/"),
278278

279279
# GLOWS
280-
("combined_de_l1a.csv", "glows/validation_data")
280+
("combined_de_l1a.csv", "glows/validation_data"),
281+
("imap_glows_l0_raw_20260202-repoint00145_v001.pkts", "glows/validation_data"),
281282
] # fmt: skip

imap_processing/tests/glows/conftest.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,16 @@ def packet_path():
2222
return current_directory / "validation_data" / "glows_test_packet_20110921_v01.pkts"
2323

2424

25+
@pytest.fixture
26+
def repoint_packet_path():
27+
current_directory = Path(__file__).parent
28+
return (
29+
current_directory
30+
/ "validation_data"
31+
/ "imap_glows_l0_raw_20260202-repoint00145_v001.pkts"
32+
)
33+
34+
2535
@pytest.fixture
2636
def decom_test_data(packet_path):
2737
"""Read test data from file"""

imap_processing/tests/glows/test_glows_l1a_data.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -589,3 +589,10 @@ def test_glows_l1a_no_packet_data(decom_packets_mock):
589589
decom_packets_mock.return_value = ([], [])
590590
output = glows_l1a("fake/filepath/packets.bin")
591591
assert output == []
592+
593+
594+
def test_glows_l1a_empty_de_packet(repoint_packet_path):
595+
"""Test that L1A processing handles packets with no direct event data."""
596+
result = glows_l1a(repoint_packet_path)
597+
598+
assert len(result) == 2

0 commit comments

Comments
 (0)