Skip to content

mask netcdf output by wet-cell topography instead of value==0#929

Open
JanStreffing wants to merge 2 commits into
mainfrom
fix_output_fillvalue_landmask
Open

mask netcdf output by wet-cell topography instead of value==0#929
JanStreffing wants to merge 2 commits into
mainfrom
fix_output_fillvalue_landmask

Conversation

@JanStreffing

Copy link
Copy Markdown
Collaborator

PR #799 set any accumulated output value below 1e-30 to _FillValue. That also masks legitimate ocean zeros: ice-free sea-ice concentration (a_ice and all other 2D ice variables) and vanishing 3D fields such as IDEMIX energy were written as NaN instead of 0, contrary to the CMIP/CMOR convention. The masking was applied uniformly to 2D and 3D fields.

Replace the value-based test with a proper wet-cell mask derived from the mesh level arrays (ulevels/nlevels for elements, ulevels_nod2D/ nlevels_nod2D for nodes). Only cells above a cavity or below the bottom topography are written as _FillValue; every wet cell keeps its averaged value, including a genuine zero. 2D fields and non-spatial vertical axes (density / ice classes) are never masked.

@chrisdane Can you check if this fixes what you flagged in #799 ?

PR #799 set any accumulated output value below 1e-30 to _FillValue. That
also masks legitimate ocean zeros: ice-free sea-ice concentration (a_ice
and all other 2D ice variables) and vanishing 3D fields such as IDEMIX
energy were written as NaN instead of 0, contrary to the CMIP/CMOR
convention. The masking was applied uniformly to 2D and 3D fields.

Replace the value-based test with a proper wet-cell mask derived from the
mesh level arrays (ulevels/nlevels for elements, ulevels_nod2D/
nlevels_nod2D for nodes). Only cells above a cavity or below the bottom
topography are written as _FillValue; every wet cell keeps its averaged
value, including a genuine zero. 2D fields and non-spatial vertical axes
(density / ice classes) are never masked.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@JanStreffing JanStreffing self-assigned this Jun 3, 2026
@JanStreffing
JanStreffing requested a review from chrisdane June 3, 2026 14:25
Comment thread src/io_meandata.F90
@JanStreffing

Copy link
Copy Markdown
Collaborator Author

Adding a data point in favor of this fix: #939 is another symptom of the value-based masking from #799, this time on river runoff. Same pattern as #821: a sparse 2D field where _FillValue lands at every node that should hold a legitimate zero, so xr.mean() over nodes divides by the nonzero count and inflates the apparent magnitude by N_total / N_nonzero ≈ 2.6×. Worth prioritizing for 2.7.1.

@JanStreffing
JanStreffing marked this pull request as ready for review June 24, 2026 15:17
@JanStreffing
JanStreffing requested a review from suvarchal June 24, 2026 15:17
@JanStreffing JanStreffing added this to the FESOM 2.8 milestone Jun 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants