Skip to content

Add culling of bad esa_energy_steps to hi goodtimes#3151

Merged
tmplummer merged 2 commits intoIMAP-Science-Operations-Center:devfrom
tmplummer:3043-hi-goodtimes---cull-non-matching-esa-voltage-times
May 8, 2026
Merged

Add culling of bad esa_energy_steps to hi goodtimes#3151
tmplummer merged 2 commits intoIMAP-Science-Operations-Center:devfrom
tmplummer:3043-hi-goodtimes---cull-non-matching-esa-voltage-times

Conversation

@tmplummer
Copy link
Copy Markdown
Contributor

@tmplummer tmplummer commented May 6, 2026

Change Summary

Summary

Add ESA voltage mismatch culling to Hi Goodtimes processing. This marks times as bad when ESA voltages don't match expected values, which is detected by esa_energy_step being set to 0 (calibration mode) or FILLVAL (255, voltage mismatch) in the L1B DE
data.

Changes

imap_processing/hi/hi_goodtimes.py

  • Added BAD_ESA_VOLTAGE = 1 << 7 (128) to CullCode enum
  • Added mark_bad_esa_voltage() function that:
    • Identifies packets with invalid ESA energy steps (0 or FILLVAL)
    • Marks all spin bins for affected 8-spin periods as bad
    • Logs statistics about calibration vs voltage mismatch packets
  • Updated _apply_goodtimes_filters() to call the new filter first (before other filters)
  • Updated hi_goodtimes() docstring to document the new filter

imap_processing/tests/hi/test_hi_goodtimes.py

  • Added mark_bad_esa_voltage to imports
  • Updated test_cull_code_values to verify BAD_ESA_VOLTAGE == 128
  • Added TestMarkBadEsaVoltage test class with 4 test cases:
    • test_mark_bad_esa_voltage_all_valid - No culling when all ESA steps valid
    • test_mark_bad_esa_voltage_with_zero - Culls times with esa_energy_step=0
    • test_mark_bad_esa_voltage_with_fillval - Culls times with esa_energy_step=255
    • test_mark_bad_esa_voltage_custom_cull_code - Custom cull code works

Closes: #3043

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 adds a new IMAP-Hi goodtimes culling step to flag 8-spin histogram periods as bad when L1B DE esa_energy_step indicates an invalid ESA voltage configuration (calibration mode or voltage mismatch), improving downstream data quality selection.

Changes:

  • Added a new CullCode.BAD_ESA_VOLTAGE bit flag and a mark_bad_esa_voltage() culling function based on esa_energy_step values (0 or FILLVAL).
  • Updated the goodtimes filter application order so ESA voltage mismatch culling runs first.
  • Added unit tests validating the new cull code value and mark_bad_esa_voltage() behavior.

Reviewed changes

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

File Description
imap_processing/hi/hi_goodtimes.py Adds the new culling flag + mark_bad_esa_voltage() and applies it first in the goodtimes pipeline.
imap_processing/tests/hi/test_hi_goodtimes.py Adds tests for the new cull code and the new culling function.

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

Comment thread imap_processing/hi/hi_goodtimes.py
Comment thread imap_processing/tests/hi/test_hi_goodtimes.py
Copy link
Copy Markdown
Contributor

@tech3371 tech3371 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 to me!

@tmplummer tmplummer merged commit 4193d64 into IMAP-Science-Operations-Center:dev May 8, 2026
14 checks passed
@github-project-automation github-project-automation Bot moved this to Done in IMAP May 8, 2026
@tmplummer tmplummer deleted the 3043-hi-goodtimes---cull-non-matching-esa-voltage-times branch May 8, 2026 21:00
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.

Hi Goodtimes - cull non-matching esa voltage times

3 participants