Skip to content

Hi L1B: filter gain tests using the pointing's own reference voltages - #3397

Merged
tmplummer merged 3 commits into
IMAP-Science-Operations-Center:devfrom
tmplummer:3394-hi-l1b-filter-gain-tests-using-the-pointings-own-reference-voltages-no-ancillary-lookup
Aug 18, 2026
Merged

Hi L1B: filter gain tests using the pointing's own reference voltages#3397
tmplummer merged 3 commits into
IMAP-Science-Operations-Center:devfrom
tmplummer:3394-hi-l1b-filter-gain-tests-using-the-pointings-own-reference-voltages-no-ancillary-lookup

Conversation

@tmplummer

@tmplummer tmplummer commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Sorry for the large PR. I couldn't find a good way to break this up more than this.

Change Summary

Reworks IMAP-Hi gain-state handling in three steps:

  1. L1B gain-test filtering — detect gain-test intervals by comparing each pointing's HVSCI segments against its own reference voltages (hardcoded tolerances), replacing the old ancillary-table lookup. Writes gain_match_{field} attrs onto L1B DE output for L1C to consume. (Closes Hi L1B: filter gain tests using the pointing's own reference voltages (no ancillary lookup) #3394)

Follow on work:

  • Modify L1C to read the gain_match{field} attributes and lookup correct geometric factors.
  • L2 correctly handle combination across differing geometric factors.

tmplummer and others added 2 commits August 17, 2026 16:57
Retire the ancillary-file-based gain-configuration classification
(config_id, GainConfigLookupTable, load_gain_configuration) added in
IMAP-Science-Operations-Center#3358. Gain test intervals are now detected by comparing every HVSCI
segment's median detector voltages against the pointing's own first
HVSCI segment (first ~3 packets), using hardcoded per-field tolerances
(HiConstants.GAIN_TEST_HV_DELTA_V) rather than an ancillary lookup
table, per Paul Janzen's feedback (IMAP-Science-Operations-Center#3391).

- hi/utils.py: remove load_gain_configuration()/GainConfigLookupTable;
  add GoodMetRangeLookupTable and HiConstants.GAIN_TEST_HV_DELTA_V.
- hi/hi_l1b.py: replace de_gain_configuration()/
  classify_gain_configuration()/get_gain_configuration_lut() with
  de_gain_test_filter(), compute_reference_hv_values(), and
  compute_gain_match_values(). The latter's output (gain_match_{field}
  global attrs) is the new L1B->L1C interface for a future gain-state
  geometric factor lookup (IMAP-Science-Operations-Center#3395).
- hi/hi_l1c.py: drop the retired gain_config_anc dependency; the
  geometric_factor lookup is stubbed to FILLVAL until IMAP-Science-Operations-Center#3395 implements
  the real gain-state-aware lookup.
- cli.py: drop the gain-configuration ancillary dependency from both
  the L1B DE and L1C PSET branches.
- Delete the gain-configuration ancillary test fixture (no production
  file exists yet).

Part of IMAP-Science-Operations-Center#3391. Closes IMAP-Science-Operations-Center#3394.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…ation

de_gain_test_filter() was classifying direct events as good/bad using
"ccsds_met" (the CCSDS packet creation time, logged by flight software
only after the data was collected). Verified against a real gain-test
pointing (repoint 152, 2026-02-09): ccsds_met lags esa_step_met (the
MET when the ESA was actually stepped, i.e. when data collection for
that 8-spin group began) by ~30-120 seconds. Out of 2713 direct event
packets, 51 were classified differently depending on which time was
used -- including cases where good data would be wrongly excluded and
cases where gain-test data would be wrongly included as good, right at
segment transitions.

Switch to "esa_step_met" for the good_met_ranges query, and reorder
annotate_direct_events() to compute it (de_esa_step_met()) before
de_gain_test_filter() runs.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@tmplummer
tmplummer requested review from leowerneck and tech3371 and a balanced review from Copilot August 18, 2026 17:27

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.

Pull request overview

Replaces ancillary-based Hi gain classification with per-pointing reference-voltage filtering and prepares the L1B-to-L1C gain-state interface.

Changes:

  • Filters gain-test HVSCI intervals using first-segment reference voltages.
  • Adds gain_match_* L1B attributes and hardcoded tolerances.
  • Removes gain-configuration ancillary dependencies and updates tests/docs.

Reviewed changes

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

Show a summary per file
File Description
imap_processing/hi/hi_l1b.py Implements reference-voltage gain-test filtering.
imap_processing/hi/utils.py Adds tolerances and boolean MET-range lookup.
imap_processing/hi/hi_l1c.py Removes legacy gain lookup and uses placeholder factors.
imap_processing/hi/hi_goodtimes.py Updates voltage-filter documentation.
imap_processing/cli.py Removes gain ancillary dependencies.
imap_processing/quality_flags.py Clarifies detector-voltage flag meaning.
imap_processing/cdf/config/imap_hi_variable_attrs.yaml Updates quality-flag metadata.
imap_processing/tests/hi/test_hi_l1b.py Tests gain filtering and derived attributes.
imap_processing/tests/hi/test_utils.py Tests good-MET range lookup.
imap_processing/tests/hi/test_hi_l1c.py Tests placeholder geometric factors.
imap_processing/tests/test_cli.py Updates CLI dependency cases.
imap_processing/tests/hi/conftest.py Removes obsolete fixture.
imap_processing/tests/hi/data/l1/imap_hi_90sensor-gain-configuration_20240101_v001.csv Deletes obsolete ancillary data.

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

@tmplummer tmplummer self-assigned this Aug 18, 2026
@tmplummer tmplummer added this to IMAP Aug 18, 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. See some suggestions for minor docstrings/comments fixes.

Comment thread imap_processing/cdf/config/imap_hi_variable_attrs.yaml
Comment thread imap_processing/hi/hi_l1b.py Outdated
Comment thread imap_processing/hi/hi_l1b.py Outdated
@tmplummer
tmplummer merged commit a33e631 into IMAP-Science-Operations-Center:dev Aug 18, 2026
16 checks passed
@github-project-automation github-project-automation Bot moved this to Done in IMAP Aug 18, 2026
@tmplummer
tmplummer deleted the 3394-hi-l1b-filter-gain-tests-using-the-pointings-own-reference-voltages-no-ancillary-lookup branch August 18, 2026 21:54
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 L1B: filter gain tests using the pointing's own reference voltages (no ancillary lookup)

3 participants