Skip to content

Implement goodtimes culling of entire pointing when gain config does … - #3554

Merged
tmplummer merged 1 commit into
IMAP-Science-Operations-Center:devfrom
tmplummer:3551-hi-goodtimes-cull-the-full-pointing-when-its-gain-state-matches-no-cal-prod-gain_config_id
Oct 8, 2026
Merged

tmplummer merged 1 commit into
IMAP-Science-Operations-Center:devfrom
tmplummer:3551-hi-goodtimes-cull-the-full-pointing-when-its-gain-state-matches-no-cal-prod-gain_config_id

Conversation

@tmplummer

Copy link
Copy Markdown
Contributor

…not match cal-prod file

Change Summary

Overview

Closes #3551. When a pointing's detector gain state matches no gain_config_id in the cal-prod file, L1C already sets its counts to zero, but its exposure stayed at full length. That bias pulls L2 map intensities low. Goodtimes now culls the whole pointing in that case, so its exposure is zero too and L2 leaves it out.

File changes

  • imap_processing/hi/hi_goodtimes.py
    • New mark_unmatched_gain_config() filter. It reads mcp_delta_v, cem_a_delta_v, cem_b_delta_v and tof_v from the L1B DE global attributes and passes them to match_gain_config_id(). If that returns None (no match, more than one match, or a NaN or missing value), every time and spin bin is marked BAD_HV_VALUE and a warning is logged.
    • It runs in _apply_goodtimes_filters() right after mark_bad_voltage, using the cal-prod config goodtimes already loads.
  • imap_processing/tests/hi/test_hi_goodtimes.py
    • New TestMarkUnmatchedGainConfig class.
    • Existing TestApplyGoodtimesFilters tests now patch out the new filter.

Testing

  • New unit tests cover the match (no change), no-match, multiple-match, NaN, missing-attribute and existing-cull-code cases.
  • All tests in tests/hi/ pass.

Closes: #3551

@tmplummer
tmplummer requested review from laspsandoval, leowerneck and vineetbansal and a balanced review from Copilot October 7, 2026 17:50
@tmplummer tmplummer self-assigned this Oct 7, 2026
@tmplummer tmplummer added this to IMAP Oct 7, 2026

Copilot AI left a comment

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.

🟢 Approval recommended

The implementation matches the issue requirements and includes comprehensive focused tests.

0 open findings

What changed in this PR

Ensures unmatched Hi gain configurations receive zero exposure, preventing biased L2 map intensities.

Changes:

  • Cull entire pointings whose gain state lacks exactly one cal-prod match.
  • Add coverage for matching, ambiguous, missing, NaN, and existing cull states.
File Description
imap_processing/​hi/​hi_goodtimes.py Adds and invokes gain-config culling.
imap_processing/​tests/​hi/​test_hi_goodtimes.py Tests the new filter and orchestration.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@leowerneck leowerneck added enhancement New feature or request Ins: Hi Related to the IMAP-Hi instrument labels Oct 7, 2026

@leowerneck leowerneck left a comment

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.

LGTM

@tmplummer
tmplummer merged commit b0a88e2 into IMAP-Science-Operations-Center:dev Oct 8, 2026
22 checks passed
@tmplummer
tmplummer deleted the 3551-hi-goodtimes-cull-the-full-pointing-when-its-gain-state-matches-no-cal-prod-gain_config_id branch October 8, 2026 16:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request Ins: Hi Related to the IMAP-Hi instrument

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Hi goodtimes: cull the full pointing when its gain state matches no cal-prod gain_config_id

3 participants