Skip to content

Handling for duplicate packet fragments in idex_l1a.py#3222

Open
aldo9253 wants to merge 1 commit into
IMAP-Science-Operations-Center:devfrom
aldo9253:pkts_dup_l1a_patch
Open

Handling for duplicate packet fragments in idex_l1a.py#3222
aldo9253 wants to merge 1 commit into
IMAP-Science-Operations-Center:devfrom
aldo9253:pkts_dup_l1a_patch

Conversation

@aldo9253
Copy link
Copy Markdown
Collaborator

Change Summary

Overview

Patch l1a to handle duplicate pkts segments.

File changes

idex_l1a.py, test_idex_l1a.py

Testing

processed locally on 20260513 v001 and v002 pkts files.

@lacoak21 lacoak21 requested review from Copilot and lacoak21 May 20, 2026 15:16
@lacoak21 lacoak21 self-assigned this May 20, 2026
@lacoak21 lacoak21 added the Ins: IDEX Related to the IDEX instrument label May 20, 2026
@lacoak21 lacoak21 added this to IMAP May 20, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates IDEX L1A science packet parsing to better handle retransmitted/duplicate science packet fragments, preventing duplicate fragments from corrupting waveform assembly and ensuring conflicting duplicates can be detected and skipped.

Changes:

  • Introduces a stable EventKey and updates science event tracking to avoid collisions when grouping packets into events.
  • Reworks RawDustEvent fragment handling to de-duplicate fragment slots (drop exact duplicates, prefer longer retransmits, and skip events on conflicting duplicates).
  • Adds targeted tests covering exact-duplicate, shorter/longer duplicate, and conflicting duplicate fragment cases.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
imap_processing/idex/idex_l1a.py Implements fragment-slot de-duplication and event-keyed science event assembly logic.
imap_processing/tests/idex/test_idex_l1a.py Adds regression tests for duplicate fragment handling and conflict behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +785 to +789
scitype = Scitype(int(packet["IDX__SCI0TYPE"]))
fragoff = int(packet["IDX__SCI0FRAGOFF"])
raw_fragment = bytes(packet["IDX__SCI0RAW"])
fragment_slot = (int(scitype), fragoff)
stored_fragments = self.fragments_by_scitype[scitype]
Copy link
Copy Markdown
Contributor

@lacoak21 lacoak21 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK this looks good! @aldo9253 Just confirming that you have processed files l1a-l2a and validated them?

Dataset containing processed dust events.
"""
dust_events = {}
dust_events: dict[EventKey, RawDustEvent] = {}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice - good system here.


self.event_number = header_packet["IDX__SCI0EVTNUM"]
self.event_number = int(header_packet["IDX__SCI0EVTNUM"])
self.event_key = self.get_event_key(header_packet)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of calling this twice maybe you should just add event_key as a constructor parameter to RawDustEvent

self.Target_Low_bits = ""
self.Target_High_bits = ""
self.Ion_Grid_bits = ""
# Keep one fragment per (science type, fragment offset) slot and assemble the
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont know enough about this. What is a fragment offset? Can you add more info about this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Ins: IDEX Related to the IDEX instrument

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

3 participants