Fix gradient returning all NaN on SCRIP-derived grids by rajeeja · Pull Request #1533 · UXARRAY/uxarray · GitHub
Skip to content

Fix gradient returning all NaN on SCRIP-derived grids#1533

Open
rajeeja wants to merge 1 commit into
mainfrom
rajeeja/gradient_fix
Open

Fix gradient returning all NaN on SCRIP-derived grids#1533
rajeeja wants to merge 1 commit into
mainfrom
rajeeja/gradient_fix

Conversation

@rajeeja

@rajeeja rajeeja commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Skip edges with incomplete edge_face_connectivity in the gradient stencil instead of NaN-ing the entire face. Fixes #1452.

The ne120np4 grid in #1452 is a spectral element cubed-sphere mesh read through SCRIP format. UXarray's SCRIP reader deduplicates corner coordinates with exact floating-point comparison, but SE grids compute shared boundary nodes independently per element, so coordinates at element junctions can differ by machine epsilon. This prevents node merging and produces edges that only one face claims, leaving INT_FILL_VALUE in edge_face_connectivity for most edges. The boundary check then falsely flags nearly every face and sets the gradient to NaN — exactly what @jpan84 observed (1 non-NaN value out of 777,602 faces).

This fix skips those incomplete edges per-edge rather than rejecting the whole face, which is sufficient for exploratory analysis of smooth fields. The proper long-term fix is tolerance-based node deduplication in the SCRIP reader or native SE grid support (#1402).

…re face

Fixes #1452 — gradient() returned all NaN on SCRIP-derived grids (ne120np4)
because _check_face_on_boundary falsely flagged every face as boundary.
@rajeeja rajeeja force-pushed the rajeeja/gradient_fix branch from 869903b to 353f5c6 Compare June 26, 2026 20:44
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.

.gradient() returns only one non-NaN value on ne120np4 grid

1 participant