Repository navigation
FIX: Preserve NaN regions in zoom_xarray - #4175
Open
thaliamontreux wants to merge 1 commit into
Open
thaliamontreux wants to merge 1 commit into
thaliamontreux wants to merge 1 commit into
Conversation
thaliamontreux
requested review from
dopplershift
and removed request for
a team
October 20, 2026 09:33
thaliamontreux
force-pushed
the
fix-frontogenesis-arcsin
branch
2 times, most recently
from
October 24, 2026 23:49
c9168ae to
c91ce39
Compare
thaliamontreux
force-pushed
the
fix-frontogenesis-arcsin
branch
from
October 27, 2026 19:49
c91ce39 to
5da77a1
Compare
scipy.ndimage.zoom's spline interpolation propagates a single NaN across its whole stencil neighborhood, so data with any missing points (as produced by e.g. frontogenesis) came back mostly or entirely NaN, which made smooth_contour plots disappear (Unidata#3672). When NaNs are present, do a normalized weighted zoom instead: interpolate the data with NaNs zeroed and a validity-weight field at the same spline order, then divide, treating non-positive weights (spline overshoot around holes) as missing.
thaliamontreux
force-pushed
the
fix-frontogenesis-arcsin
branch
from
October 27, 2026 22:32
5da77a1 to
fde681d
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Partially addresses #3672. As diagnosed there by @kgoebber,
smooth_contourproduces an empty plot becausezoom_xarrayreturns all-NaN when the input contains any NaN --scipy.ndimage.zoom's spline stencil propagates one NaN across its whole neighborhood.When NaNs are present, this does a normalized weighted zoom instead: interpolate
datawith NaNs zeroed and a validity-weight field (1 valid / 0 NaN) at the same spline order, then divide. Non-positive weights (spline overshoot around holes) become NaN. NaN-free input takes the original path unchanged.Note: the companion
frontogenesisNaN issue from that thread no longer reproduces on main --frontogenesisnow computescos(2*beta)via the1 - 2*sin(beta)**2identity rather than arcsin, so no arcsin domain error remains.Checklist