Skip to content

Remove non-finite fill values for pf.ice_ext() calculation#235

Merged
JanStreffing merged 3 commits intomainfrom
bugfix/ice-extent
Mar 26, 2026
Merged

Remove non-finite fill values for pf.ice_ext() calculation#235
JanStreffing merged 3 commits intomainfrom
bugfix/ice-extent

Conversation

@FinnHeu
Copy link
Copy Markdown
Collaborator

@FinnHeu FinnHeu commented Mar 17, 2026

With the fill value change from 0 to nan in fesom2.7 the pf.ice_ext() did return incorrect values.

With the fill value change from 0 to nan in fesom2.7 the pf.ice_ext() did return incorrect values.
@FinnHeu FinnHeu requested a review from patrickscholz March 17, 2026 16:49
@FinnHeu FinnHeu self-assigned this Mar 17, 2026
@JanStreffing JanStreffing requested a review from koldunovn March 24, 2026 09:23
@FinnHeu FinnHeu closed this Mar 25, 2026
FinnHeu and others added 2 commits March 25, 2026 11:22
Replace finite mask calculation to handle NaN values and update data accordingly.
The previous fix still had the critical bug where .where() operations
converted NaN land cells to ice (value=1), causing 10x overestimation.

This commit replaces the .where() logic with xr.where() that creates
a proper binary field while explicitly preserving NaN values for land.

Changes:
- xarray path: Use xr.where() to create binary field, then preserve NaN
- numpy path: Create binary field with np.where(), then restore NaN values
- Both paths now correctly exclude land cells from ice extent calculation

Tested with AWI-ESM3 data - values now show realistic ~20 million km²
instead of inflated ~200 million km².
@JanStreffing
Copy link
Copy Markdown
Contributor

Why closed?
I just pushed the working fix on that branch.

@JanStreffing JanStreffing reopened this Mar 25, 2026
@JanStreffing
Copy link
Copy Markdown
Contributor

Before (and after putting proper NaNs into fesom output):
sea_ice_extent_comparison
After:
sea_ice_extent_comparison

(ignore the apparent unit change. that was a separate oversight. nothing changed in the computation other than what you see in the PR)

@JanStreffing
Copy link
Copy Markdown
Contributor

Not sure why the tests are failing. @pgierz ?

@JanStreffing
Copy link
Copy Markdown
Contributor

Ready for review from my side.
Not sure why the tests are failing. Unrelated?

@JanStreffing JanStreffing added the bug Something isn't working label Mar 26, 2026
@JanStreffing JanStreffing merged commit 59a208d into main Mar 26, 2026
19 of 28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants