Implement fallback to linear interpolation in interpolate_map_flux_to…#3150
Conversation
…_helio_frame method
laspsandoval
left a comment
There was a problem hiding this comment.
Nice job. Thanks Tim!
| # Allow for some numerical variation due to interpolation | ||
| np.testing.assert_allclose(ratio, 0.2, rtol=0.01) | ||
|
|
||
| def test_linear_fallback_when_flux_left_zero(self): |
There was a problem hiding this comment.
Double check that clamping happens in this test. Claude says:
interp_fraction < 0 and flux_sc_linear stays positive. The assertions only confirm non-negativity of already-positive outputs, not that the clamp fires.
There was a problem hiding this comment.
This test is not meant to test the clamping. It tests that the linear interpolation fallback is used when the left flux value used for interpolation is zero. The clamping is tested below in the test_negative_interpolated_flux_clamped_to_zero test.
b1dee10
into
IMAP-Science-Operations-Center:dev
…_helio_frame method
Change Summary
Overview
Fixes #3149 - Adds linear interpolation fallback for zero-flux cases in the Compton-Getting correction.
When one or more fluxes are zero, the power-law interpolation in interpolate_map_flux_to_helio_frame produces NaN because log(0) is undefined. This PR detects these conditions and falls back to linear interpolation.
Changes
imap_processing/ena_maps/utils/corrections.py
Modified interpolate_map_flux_to_helio_frame to:
imap_processing/tests/ena_maps/test_corrections.py
Added 5 new test cases:
Closes: #3149