Skip to content

CoDICE l2 sw species metadata update - #3378

Open
lacoak21 wants to merge 4 commits into
IMAP-Science-Operations-Center:devfrom
lacoak21:codice_l2_fix_metdata
Open

CoDICE l2 sw species metadata update#3378
lacoak21 wants to merge 4 commits into
IMAP-Science-Operations-Center:devfrom
lacoak21:codice_l2_fix_metdata

Conversation

@lacoak21

Copy link
Copy Markdown
Contributor

Change Summary

closes #3353

Overview

Update lo l2 species products to use energy_per_charge variable as the depend 1 variable. This required also creating energy_per_charge_label. I thought it then made sense to put these into a dedicated l1b yaml file.

File changes

  • imap_processing/cdf/config/imap_codice_l1b_variable_attrs.yaml
    • create dedicated yaml file for clarity and readability (I found it hard to track down where the energy_per_charge attrs were getting assigned)
  • imap_processing/cdf/config/imap_codice_l2-lo-species_variable_attrs.yaml
    • Replace esa_step with energy_per_charge and esa_step_label with energy_per_charge_label
  • imap_processing/codice/codice_l1b.py
    • Get l1b attrs from yaml file instead of modifying old attrs

@lacoak21 lacoak21 added this to the August 2026 milestone Aug 11, 2026
@lacoak21
lacoak21 requested review from bryan-harter, mstarkey2158 and tech3371 and a lite review from Copilot August 11, 2026 18:43
@lacoak21 lacoak21 self-assigned this Aug 11, 2026
@lacoak21 lacoak21 added this to IMAP Aug 11, 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.

Pull request overview

Updates CoDICE LO L2 species product metadata so spectrograms use physical energy-per-charge (keV/e) on the y-axis by switching DEPEND_1/label pointers from esa_step to energy_per_charge, and introduces L1b variable-attribute YAML support for the new coordinate/label variables.

Changes:

  • Add a dedicated CoDICE L1b variable-attributes YAML defining energy_per_charge and energy_per_charge_label.
  • Update L2 LO species variable attributes to depend on energy_per_charge (and point labels to energy_per_charge_label) instead of ESA step indices.
  • Update CoDICE L1b processing to load L1b variable attrs and to create energy_per_charge/energy_per_charge_label using those attrs.

Reviewed changes

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

File Description
imap_processing/codice/codice_l1b.py Loads L1b variable attrs and uses them to create energy_per_charge and a new energy_per_charge_label support variable.
imap_processing/cdf/config/imap_codice_l2-lo-species_variable_attrs.yaml Switches species products’ DEPEND_1/LABL_PTR_1 from esa_step(_label) to energy_per_charge(_label).
imap_processing/cdf/config/imap_codice_l1b_variable_attrs.yaml New YAML file defining variable attributes for energy_per_charge and energy_per_charge_label.
Suppressed comments (1)

imap_processing/codice/codice_l1b.py:58

  • If cdf_attrs is made optional (or any call path forgets to pass it), this block will raise when calling cdf_attrs.get_variable_attributes(...). Provide a fallback attribute dict when cdf_attrs is None so LO processing continues to work in callers that don’t use the CDF attribute manager.
    if descriptor.startswith("lo-"):
        # Calculate energy_per_charge using voltage_table and k_factor
        # 1e3 is to convert eV to keV
        energy_per_charge = (
            dataset["voltage_table"].values * dataset["k_factor"].values * 1e-3

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

Comment thread imap_processing/codice/codice_l1b.py
Comment thread imap_processing/codice/codice_l1b.py
@mstarkey2158

Copy link
Copy Markdown
Collaborator

I approve.

@lacoak21
lacoak21 requested a review from laspsandoval August 12, 2026 17:44
@tech3371

Copy link
Copy Markdown
Contributor

I am going to ping @jtniehof and @pleasant-menlo for impact on L3 pipeline. Appreciate their review!

@tech3371 tech3371 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.

The changes looks good. Thank you for doing this! I tagged L3 reviewer since our recent L2 will have more impact in L3 pipeline now.

Comment on lines +72 to +73
if cdf_attrs is not None
else {},

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.

so this is handler for I-ALiRT use case? If so, can you add note about that? I am afraid that we will loose this context in the future.

Same comment for below if check.

# Get the L1b CDF attributes
cdf_attrs = ImapCdfAttributes()
cdf_attrs.add_instrument_global_attrs("codice")
cdf_attrs.add_instrument_variable_attrs("codice", "l1b")

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.

I see. I didn't realize we are not using l1b attrs. Nice addition!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

Fix CODICE 2_lo-sw-species DEPEND_1s

4 participants