Fix Hi L2 flux correction convergence logic#3143
Merged
tmplummer merged 4 commits intoIMAP-Science-Operations-Center:devfrom May 7, 2026
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the Hi ENA flux-correction convergence logic so zero-valued flux bins do not poison the per-pixel convergence metric with NaNs. It also adds a regression test in the ENA maps test suite for a zero-flux scenario.
Changes:
- Replaced
np.meanwithnp.nanmeaninpredictor_corrector_iteration()when computing the convergence ratio. - Added a Hi-specific regression test intended to verify convergence when one ESA flux is set to zero.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
imap_processing/ena_maps/utils/corrections.py |
Adjusts the predictor-corrector convergence calculation to ignore NaN ratio entries. |
imap_processing/tests/ena_maps/test_corrections.py |
Adds a regression test for zero-flux convergence behavior in the Hi correction path. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
230f4c0
into
IMAP-Science-Operations-Center:dev
14 checks passed
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
Fixes a bug in how convergence criteria was being calculated. The bug occurred when an input flux is zero causing the computed chi_n for that pixel to be NaN which will never be less than the convergence criteria. The easy fix is to just use a nanmean when computing the mean ratio. This is appropriate because zero fluxes will just stay zeros and thus are already converged.
Testing
I first added the test confirming that when a zero is in the input flux, the max iterations is hit. Once the bug was fixed, the test passes.
Closes: #3142