Skip to content

3165 bug hi l2 problems propegating error and uncertainty in maps#3166

Open
tmplummer wants to merge 3 commits intoIMAP-Science-Operations-Center:devfrom
tmplummer:3165-bug---hi-l2---problems-propegating-error-and-uncertainty-in-maps
Open

3165 bug hi l2 problems propegating error and uncertainty in maps#3166
tmplummer wants to merge 3 commits intoIMAP-Science-Operations-Center:devfrom
tmplummer:3165-bug---hi-l2---problems-propegating-error-and-uncertainty-in-maps

Conversation

@tmplummer
Copy link
Copy Markdown
Contributor

Change Summary

Overview

Fix NaN propagation issues in Hi L2 ena_intensity_stat_uncert and ena_intensity_sys_err variables.

Changes

imap_processing/ena_maps/utils/corrections.py

  • Fixed negative flux clamping to use xr.where() instead of .where() method to ensure proper NaN preservation during the clamping operation

imap_processing/hi/hi_l2.py

  • calculate_ena_intensity(): Added np.errstate(divide="ignore") context manager around systematic error calculation to suppress divide-by-zero warnings when exposure is zero (result correctly becomes NaN)
  • combine_calibration_products(): Added skipna=False to the quadrature sum of systematic errors to ensure NaN values propagate correctly rather than being silently ignored

imap_processing/tests/ena_maps/test_corrections.py

  • Added test_nan_input_propagation() to verify that NaN inputs in flux, statistical uncertainty, and systematic error properly propagate to NaN outputs during heliocentric frame interpolation

imap_processing/tests/hi/test_hi_l2.py

  • Added test_combine_maps_handles_nan_uncertainties() to verify that when one map has NaN in ena_intensity_stat_uncert, the combined result correctly uses only the valid map's values

Closes: #3165

tmplummer added 2 commits May 8, 2026 13:38
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses NaN propagation bugs in Hi L2 ENA map uncertainty/error variables, ensuring that NaNs are preserved through interpolation, clamping, and calibration-product/map combination logic.

Changes:

  • Preserve NaNs when clamping negative interpolated flux values by switching to xr.where.
  • Adjust Hi L2 systematic error computation and calibration-product systematic error aggregation to avoid incorrect non-NaN outputs.
  • Add regression tests covering NaN propagation in heliocentric interpolation and NaN handling during map combination.

Reviewed changes

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

File Description
imap_processing/ena_maps/utils/corrections.py Updates negative-flux clamping to preserve NaNs during heliocentric-frame interpolation.
imap_processing/hi/hi_l2.py Tweaks systematic error computation (warning suppression) and systematic error aggregation across calibration products.
imap_processing/tests/ena_maps/test_corrections.py Adds a test verifying NaN inputs propagate to NaN outputs through interpolation.
imap_processing/tests/hi/test_hi_l2.py Adds a test ensuring NaN statistical uncertainties don’t poison combined-map results.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread imap_processing/hi/hi_l2.py Outdated
Comment thread imap_processing/hi/hi_l2.py
Comment thread imap_processing/tests/hi/test_hi_l2.py
Test the correct function
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.

BUG - Hi L2 - problems propegating error and uncertainty in maps

2 participants