Skip to content

fix(ewa): use the requested fill value instead of hardcoded NaN - #741

Open
Manny7717 wants to merge 1 commit into
pytroll:mainfrom
Manny7717:fix/ewa-fill-value
Open

fix(ewa): use the requested fill value instead of hardcoded NaN#741
Manny7717 wants to merge 1 commit into
pytroll:mainfrom
Manny7717:fix/ewa-fill-value

Conversation

@Manny7717

Copy link
Copy Markdown

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.

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 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.69%. Comparing base (2e7a3c8) to head (5cfd105).
⚠️ Report is 15 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #741      +/-   ##
==========================================
+ Coverage   93.68%   93.69%   +0.01%     
==========================================
  Files          89       89              
  Lines       13715    13739      +24     
==========================================
+ Hits        12849    12873      +24     
  Misses        866      866              
Flag Coverage Δ
unittests 93.69% <100.00%> (+0.01%) ⬆️

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.

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