Repository navigation
Compute ocean transect interfaces as slices through triangular prisms - #784
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Interfaces at transect nodes were computed as the average SSH minus the cumulative sum of average layer thicknesses, where SSH was averaged over all interpolation cells but each layer's thickness only over the cells where that layer is valid. Where neighboring cells have different numbers of layers, this put interfaces (and the seafloor) below the beds of every cell used at the node. Now, interfaces are computed at cell centers from the bed up. At each vertex (the ends of the triangle side a node lies on), each interface is the kite-area-weighted average over the cells in which it is valid, adjusted to be non-increasing with depth where needed. Interfaces are then linear between the two ends. Interpolation weights for fields are renormalized over valid cells separately at each end, and vertical weights are now linear in z between layer middles, as documented. Land cells in the middle of a transect now produce invalid segments rather than an error, and cell 0 is no longer treated as invalid. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The SSH and seafloor lines now follow the top and bottom of the valid layers in each segment, with vertical steps between segments and breaks across invalid segments, rather than cutting diagonally between nodes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Collaborator
Author
TestingFilchner–Ronne section from #783Setup:
The same check on a regional subset of an E3SM SOwISC12to60 restart, along the same line:
What the plots show:
Temperature from the initial state: Other checks
Posted by Claude Code on xylar's behalf. The testing and wording above are AI-authored; please check them accordingly. |
This was referenced Nov 21, 2026
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.




Fixes #783
compute_transect()misplaced layer interfaces at transect nodes wherever the cells used at a node have different numbers of layers. It took SSH averaged over all of those cells, minus a cumulative sum of layer thicknesses, but each layer's thickness was averaged only over the cells where that layer is valid. Under ice shelves and on steep slopes this moves interfaces and the seafloor by more than 100 m. On the Filchner–Ronne section from #783, columns of deep cells were drawn up to 145 m too shallow.With this PR, the transect is a slice through triangular prisms, one per cell edge, with the cell center and the edge's two vertices as corners. These are the triangles
mesh_to_triangles()already uses for the horizontal part of the transect.bottomDepthusinglayerThickness.Other fixes
interp_mpas_to_transect_nodes(), used bymethod='bilinear'inplot_transect():maxLevelCellof 0) in the middle of a transect now give invalid (masked) segments. Before, they failed an assertion.plot_transect()draws the SSH and seafloor lines as steps that follow each segment's valid layers. Before, they were diagonals across empty space.Compatibility
Output variables and dimensions are unchanged. Two behavior changes:
sshandzSeafloorat a node are the top and bottom of the valid layers in the segments on either side. They are NaN between two invalid segments.Not in this PR
The transect's end points and bend points are not nodes. Sections start and end where they first and last cross a triangle side, and a bend inside a triangle is drawn straight. Adding these points would change
nHorizWeights, which MPAS-Analysis relies on, so that is left for a separate PR.Testing
New tests in
conda_package/tests/test_ocean_viz_transect.pyuse a planar hex mesh:compute_transect()matches an independent, loop-based implementation of the prism geometry.zMidandzInterfaceto the nodes reproduces the node elevations.The random-layer, linear-in-z and land tests fail on
master. Results and before/after plots on the case from #783 are in a comment below.🤖 Generated with Claude Code