Part of #3391. Depends on #3394 for the gain_match_{field} L1B DE global attributes.
Summary
Replace the separate gain-configuration ancillary file and config_id classification (added in #3358) 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 referenced in #3391.
Changes
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 CSVs (production
imap_hi_45sensor-cal-prod_*.csv and the test fixture): add the gain_config_id index column 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_l1c.py: rewrite pset_geometric_factor() to match the L1B DE product's gain_match_{field} attributes against CalibrationProductConfig.match_gain_config_id(), and record 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_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).
cli.py: drop gain-configuration from the L1C PSET ancillary dependencies (2 required instead of 3).
imap_hi_variable_attrs.yaml: add DEPEND_2/LABL_PTR_2 (calibration_prod) to hi_pset_geometric_factor.
- Update/add tests in
test_hi_l1c.py, test_hi_l2.py, remaining parts of test_utils.py/test_cli.py.
Out of scope
Combining PSETs from different gain states into a single L2 map remains a follow-on (not addressed here).
Part of #3391. Depends on #3394 for the
gain_match_{field}L1B DE global attributes.Summary
Replace the separate
gain-configurationancillary file andconfig_idclassification (added in #3358) with a gain-state-dependent geometric factor lookup folded directly into the existingimap_hi_{sensor}-cal-prod_*.csvfile, keyed on measured detector voltage differences (front/back) and the U-Can voltage, per Paul Janzen's feedback referenced in #3391.Changes
hi/utils.py: extendCalibrationProductConfigwith a new leadinggain_config_idindex level,GAIN_MATCH_FIELDS,gain_match_columns(forward-filled pergain_config_idgroup, placed as the final columns of the file), an extended_validate(), andmatch_gain_config_id().imap_hi_45sensor-cal-prod_*.csvand the test fixture): add thegain_config_idindex column andmcp_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_l1c.py: rewritepset_geometric_factor()to match the L1B DE product'sgain_match_{field}attributes againstCalibrationProductConfig.match_gain_config_id(), and record the geometric factor per(esa_energy_step, calibration_prod)pair — the PSETgeometric_factorvariable gains acalibration_proddimension instead of summing across calibration products. Fixpset_counts()'sconfig_row.Indexpositional lookup, which shifts because of the new leading index level.hi_l2.py: select a singlegain_config_idbefore theCalibrationProductConfigDataFrame is converted to xarray and reindexed against the map dataset (also a consequence of the new index level).cli.py: dropgain-configurationfrom the L1C PSET ancillary dependencies (2 required instead of 3).imap_hi_variable_attrs.yaml: addDEPEND_2/LABL_PTR_2(calibration_prod) tohi_pset_geometric_factor.test_hi_l1c.py,test_hi_l2.py, remaining parts oftest_utils.py/test_cli.py.Out of scope
Combining PSETs from different gain states into a single L2 map remains a follow-on (not addressed here).