Skip to content

Fix user fill value not being used in EWA - #741

Merged
djhoese merged 3 commits into
pytroll:mainfrom
Manny7717:fix/ewa-fill-value
Sep 18, 2026
Merged

djhoese merged 3 commits into
pytroll:mainfrom
Manny7717:fix/ewa-fill-value

Conversation

@Manny7717

Copy link
Copy Markdown
Contributor

What

fornav() resolves a fill value from the input data (NaN for floats, -999 for integers, or the caller's fill argument) but then passed hardcoded np.nan as both the input and output fill to the C resampler (_fornav.fornav_wrapper). Two consequences (reported in #689):

  • Integer swath data cannot be resampled — NaN cannot be written into an integer output array.
  • A user-specified fill (e.g. fill=0) was ignored for float data: uncovered pixels still got NaN.

Change

Pass the resolved fill value as both input and output fill to fornav_wrapper. Default behavior is unchanged (float data with fill=None still gets NaN, matching the documented default); only fill-specified and integer paths change. The dask EWA resampler already forwarded its fill value and is unaffected.

Tests

  • New test_fornav_integer_swath_with_fill: int8 swath + fill=0 resamples without error; output contains only data and fill values.
  • New test_fornav_fill_value_used_in_output: float32 swath + fill=0 — uncovered pixels are 0, no NaN anywhere.
  • Both tests fail on the previous implementation (verified) and pass with the fix.
  • pytest test_ewa_fornav.py test_dask_ewa.py → 89 passed, 20 skipped (pre-existing skips). ruff clean.

@djhoese djhoese self-assigned this Sep 1, 2026
@djhoese djhoese added the bug label Sep 1, 2026
@codecov

codecov Bot commented Sep 1, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.90%. Comparing base (82b485c) to head (4a46786).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #741      +/-   ##
==========================================
+ Coverage   93.87%   93.90%   +0.03%     
==========================================
  Files          89       89              
  Lines       13888    13924      +36     
==========================================
+ Hits        13037    13075      +38     
+ Misses        851      849       -2     
Flag Coverage Δ
unittests 93.90% <100.00%> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@djhoese djhoese left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for fixing this. The fix looks good. Could you please combine the two new tests outside of the unittest TestCase class and use pytest's parametrize? This will also require changing the assert method calls to normal assert X conditions.

Manny7717 and others added 3 commits September 18, 2026 10:14
fornav() computed a fill value from the input data (np.nan for floats,
-999 for integers, or the user-supplied fill) but always passed
np.nan as the input/output fill to the C resampler. Integer swath
data therefore failed (NaN cannot be written into integer output),
and a user-specified fill was ignored for float data. Pass the
resolved fill value through. Closes pytroll#689
@djhoese

djhoese commented Sep 18, 2026

Copy link
Copy Markdown
Member

Thanks for this. I'm sorry it took so long to merge such an obvious change. Other EWA resampling PRs that were merged made some conflicts. Claude also pointed out to me that the integer fill value was out of the range for the integer dtype (int8, default was -999.0). I've tacked on a fix for that to this PR. I rebased your branch and force pushed it. This should be good to merge once CI finishes. Thanks again.

@djhoese djhoese changed the title fix(ewa): use the requested fill value instead of hardcoded NaN Fix user fill value not being used in EWA Sep 18, 2026
@djhoese
djhoese merged commit 0890644 into pytroll:main Sep 18, 2026
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants