3395 hi l1c look up geometric factor by gain state via extended cal prod schema - #3398
Merged
Conversation
…schema Replace the separate gain-configuration ancillary file and config_id classification (added in IMAP-Science-Operations-Center#3358, retired in IMAP-Science-Operations-Center#3394) with a gain-state- dependent geometric factor lookup folded directly into the existing imap_hi_{sensor}-cal-prod_*.csv file, keyed on measured detector voltage differences (front/back) and the U-Can voltage, per Paul Janzen's feedback (IMAP-Science-Operations-Center#3391). - hi/utils.py: extend CalibrationProductConfig with a new leading gain_config_id index level, GAIN_MATCH_FIELDS, gain_match_columns (forward-filled per gain_config_id group, placed as the final columns of the file), an extended _validate(), and match_gain_config_id(). - Ancillary CSV (test fixture): add gain_config_id and mcp_delta_v/cem_a_delta_v/cem_b_delta_v/tof_v (+ _tol) columns. Deltas are computed as back-voltage minus front-voltage (positive), matching real flight detector voltages. - hi/hi_l1c.py: implement pset_geometric_factor() to match the L1B DE product's gain_match_{field} attributes (from IMAP-Science-Operations-Center#3394) against CalibrationProductConfig.match_gain_config_id(), recording the geometric factor per (esa_energy_step, calibration_prod) pair -- the PSET geometric_factor variable gains a calibration_prod dimension instead of summing across calibration products. Fix pset_counts()'s config_row.Index positional lookup, which shifts because of the new leading index level. - hi/hi_l2.py: select a single gain_config_id before the CalibrationProductConfig DataFrame is converted to xarray and reindexed against the map dataset (also a consequence of the new index level). - imap_hi_variable_attrs.yaml: add DEPEND_2/LABL_PTR_2 (calibration_prod) to hi_pset_geometric_factor. Not yet consumed by L2 map-combination processing across different gain states -- that remains a follow-on. Part of IMAP-Science-Operations-Center#3391. Closes IMAP-Science-Operations-Center#3395. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
refactor pset_geometric_factor function
Contributor
There was a problem hiding this comment.
Pull request overview
Adds gain-state-aware geometric-factor lookup across Hi L1B/L1C processing.
Changes:
- Extends calibration-product configuration with gain-state matching.
- Records detector voltage deltas and populates PSET geometric factors.
- Updates L2 compatibility, CDF dimensions, fixtures, and tests.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
imap_processing/hi/utils.py |
Adds gain matching and schema validation. |
imap_processing/hi/hi_l1b.py |
Records pointing HV deltas. |
imap_processing/hi/hi_l1c.py |
Selects geometric factors by gain state. |
imap_processing/hi/hi_l2.py |
Handles the additional configuration index. |
imap_processing/cdf/config/imap_hi_variable_attrs.yaml |
Adds the calibration-product dimension. |
imap_processing/tests/hi/test_utils.py |
Tests configuration parsing and matching. |
imap_processing/tests/hi/test_hi_l1b.py |
Updates gain-filter tests. |
imap_processing/tests/hi/test_hi_l1c.py |
Tests geometric-factor population. |
imap_processing/tests/hi/data/l1/imap_hi_90sensor-cal-prod_20240101_v001.csv |
Extends the ancillary fixture schema. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…n cal prod dataframe
leowerneck
reviewed
Aug 20, 2026
Co-authored-by: Leo Werneck <wernecklr@gmail.com>
tmplummer
merged commit Aug 26, 2026
0b0b734
into
IMAP-Science-Operations-Center:dev
22 checks passed
tmplummer
deleted the
3395-hi-l1c-look-up-geometric-factor-by-gain-state-via-extended-cal-prod-schema
branch
August 26, 2026 15:51
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Change Summary
Overview
Adds a gain-state-aware geometric factor lookup to Hi L1C processing, replacing the previous placeholder/stubbed value. A pointing's detector high-voltage deltas, computed and recorded at L1B, are matched against an extended cal-prod ancillary schema at L1C to determine the correct geometric factor per (esa_energy_step, calibration_prod).
Closes: #3395
File changes
deltas) and match_gain_config_id() (matches a pointing's HV deltas to a gain_config_id row, returning None on NaN input, no match, or ambiguous match).
CalibrationProductConfig.GAIN_MATCH_FIELDS as the single source of truth for field names.
add_pset_geometric_factor(pset_ds, l1b_de_ds, config_df)).
Testing