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
13 changes: 13 additions & 0 deletions imap_processing/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,19 @@ def test_check_source_sequence_counter(caplog):
assert "Found [2] gap(s) in source sequence counter for APID 1234" in caplog.text


@pytest.mark.filterwarnings("error::RuntimeWarning")
def test_check_source_sequence_counter_unsigned_rollover(caplog):
"""Test _check_source_sequence_counter with unsigned counters that roll over."""
data_vars = {
"src_seq_ctr": (["epoch"], np.array([10221, 4933, 4934], dtype=np.uint16)),
}
ds = xr.Dataset(data_vars=data_vars)

utils._check_source_sequence_counter(ds, apid=1188)

assert "(11095 total missing packets)" in caplog.text


def test_extract_data_dict():
"""Test extract_data_dict function."""
data_vars = {
Expand Down
2 changes: 1 addition & 1 deletion imap_processing/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ def _check_source_sequence_counter(ds: xr.Dataset, apid: int) -> None:
# Check for sequential source sequence counters
# CCSDS source sequence counter is a 14-bit field (0-16383)
counter_max = 16384
src_seq_ctr = ds["src_seq_ctr"].data
src_seq_ctr = ds["src_seq_ctr"].data.astype(np.int32)

if len(src_seq_ctr) <= 1:
return
Expand Down