Skip to content

Conversation

@lacoak21
Copy link
Contributor

Change Summary

Overview

I found another place where the code is using the spin number (unit8) and doing gymnastics with the met time to match up to the universal spin table. We should be using the aux packet and coarse time to get the correct spin duration/ event times/ spin number. I missed that the old routine was still being used in l1b.

Updated Files

  • imap_processing/ultra/l1b/ultra_l1b_culling.py
    • Remove outdated function! Merge it with the new function to keep everything in the same place.
  • imap_processing/ultra/l1b/ultra_l1b_extended.py
    • Create a new function that returns the spin and duration using the same logic as the event time calculation
  • imap_processing/ultra/l1c/helio_pset.py and imap_processing/ultra/l1c/spacecraft_pset.py and imap_processing/ultra/l1c/ultra_l1c.py
    • add aux packet as a dependency
  • imap_processing/ultra/l1c/spacecraft_pset.py

Testing

Fix tests

@lacoak21 lacoak21 self-assigned this Dec 17, 2025
@lacoak21 lacoak21 added this to IMAP Dec 17, 2025
@lacoak21 lacoak21 added this to the December 2025 milestone Dec 17, 2025
@lacoak21 lacoak21 changed the title use aux packet to get spins ULTRA l1b use aux packet to get spins Dec 17, 2025
Copy link
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 refactors the ULTRA L1b processing to use auxiliary (aux) packet data for spin number and duration calculations instead of relying on the Universal Spin Table with 8-bit spin number matching. The change eliminates complex time-based matching logic and provides more accurate spin information directly from the aux packet, which contains the full spin numbers (not just 8-bit truncated values).

Key Changes:

  • Removed the outdated get_spin_and_duration function from ultra_l1b_culling.py that relied on Universal Spin Table matching
  • Created a new get_spin_and_duration function in ultra_l1b_extended.py that uses aux packet data directly
  • Refactored get_event_times to return only event times and spin start times (spin numbers now obtained separately via get_spin_and_duration)
  • Updated function signatures throughout L1b and L1c to accept aux_dataset as a required parameter

Reviewed changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
imap_processing/ultra/l1b/ultra_l1b_extended.py Added new get_spin_start_indices helper function and get_spin_and_duration function using aux packet; refactored get_event_times to remove spin_numbers from return
imap_processing/ultra/l1b/ultra_l1b_culling.py Removed old Universal Spin Table-based get_spin_and_duration; updated get_pulses_per_spin signature to require aux_dataset
imap_processing/ultra/l1b/de.py Updated to call both get_event_times and get_spin_and_duration separately with proper aux_dataset parameter
imap_processing/ultra/l1b/extendedspin.py Updated get_pulses_per_spin call to include aux_dataset parameter
imap_processing/ultra/l1b/goodtimes.py Changed from .dims to .sizes for accessing dimension sizes (best practice)
imap_processing/ultra/l1b/badtimes.py Changed from .dims to .sizes for accessing dimension sizes (best practice)
imap_processing/ultra/l1c/ultra_l1c.py Added aux_dataset as required input for helio_pset and spacecraft_pset calculations
imap_processing/ultra/l1c/helio_pset.py Added aux_dataset parameter and passed it through to background rates calculation
imap_processing/ultra/l1c/spacecraft_pset.py Added aux_dataset parameter and passed it through to background rates calculation
imap_processing/ultra/l1c/ultra_l1c_pset_bins.py Updated get_spacecraft_background_rates to accept and use aux_dataset for spin calculations
imap_processing/tests/ultra/unit/test_ultra_l1b_extended.py Added new test for get_spin_and_duration; updated test_get_eventtimes to match new return signature
imap_processing/tests/ultra/unit/test_ultra_l1b_culling.py Updated tests to create aux_dataset and pass it to modified functions
imap_processing/tests/ultra/unit/test_ultra_l1c_pset_bins.py Created aux_ds fixture data for background rates test
imap_processing/tests/ultra/unit/test_ultra_l1c.py Added aux_dataset and rates_dataset fixtures to spacecraft and helio pset tests
imap_processing/tests/ultra/unit/test_spacecraft_pset.py Added aux_dataset and rates_dataset parameters to test functions
imap_processing/tests/ultra/unit/test_ultra_l1b.py Updated fixture names from faux_aux_dataset to aux_dataset for consistency

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

Copy link
Collaborator

@greglucas greglucas left a comment

Choose a reason for hiding this comment

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

Looks good, just one question/comment about code re-use.

@lacoak21 lacoak21 force-pushed the ultra_l1b_fix_get_spin_and_duration branch from 73b532d to 1961b31 Compare December 18, 2025 17:44
@lacoak21 lacoak21 merged commit 5774def into IMAP-Science-Operations-Center:dev Dec 18, 2025
14 checks passed
@lacoak21 lacoak21 deleted the ultra_l1b_fix_get_spin_and_duration branch December 18, 2025 20:13
@github-project-automation github-project-automation bot moved this to Done in IMAP Dec 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants