Repository navigation
Conversation
…ack#761) apply_align_buffer_coarsen now stops, naming the file and axis, when the align shift passes the window end, matching Python's EmptyAlignedCropWindow. Previously the run continued silently with a point outside the crop. Adds a topo_crop regression for topo types 3 and 4 and records the status in the topo input roadmap. Signed-off-by: Kyle Mandli <kyle.mandli@gmail.com> Assisted-by: claude claude-opus-5-5
mandli
marked this pull request as ready for review
October 19, 2026 15:48
… topo roadmap Signed-off-by: Kyle Mandli <kyle.mandli@gmail.com> Assisted-by: claude claude-opus-5-5
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 #761 and partially addresses #760.
Adds tests for the fixes and changed python and fortran code to match errors so that there are multiple error pathways (that match). Should now be consistent with what is mentione din #760 across all
topo_type.When
coarsen > 1andalignis set, the align step moves the start of the crop window onto the coarse lattice throughalign. If the crop is narrower thancoarsengrid points, that move can pass the end of the window, and then no kept point lies inside the crop. Python and Fortran handled this differently, and both were wrong:coordinate_tools.crop_indices, whichTopography.crop, the type-4 netCDF read, and the dtopo crop all use) returned an inverted window, e.g.(7, 5). That gave an emptyTopographywith no error. When the crop was withincoarsenpoints of the file's upper edge, it raised anIndexErrorinstead.apply_align_buffer_coarsen) carried on and kept a point outside the crop. Next to the file edge, that point could be outside the file. The run finished normally with no warning.Changes
crop_indicesraisesEmptyAlignedCropWindow(a new subclass ofEmptyCropWindow, and so ofValueError) when the aligned start passes the end of the window. Align candidates past the end of the array are now computed from the spacing instead of indexed.topotools._crop_indicesreports this case with its own message ("contains no point of the coarsened grid… widen the crop to at leastcoarsengrid points, or change align"). The sub-cell message is unchanged.apply_align_buffer_coarsenstops with the matching error and prints the file, axis, coarsen and align. It takes two new arguments,fnameandaxis, so it can name them; all four callers are updated (types 2/3 and type 4).dev/design/topo_input_roadmap.md: adds an "In review / open" table covering this PR and the decision on Behavior when creating topo.data if crop_extent goes outside topo.extent for a topofile #760.Crops wider than
coarsenpoints are unaffected. For them every align candidate is a real array point, so the code computes exactly the same values as before.Verification
tests/test_coordinate_tools.py: the upper-edgeIndexErrorcase, the inverted-window case, and a sweep of every window 1 tocoarsenpoints wide across the whole array (both ends included). The sweep checks that each crop either raises or keeps a first point inside the crop.test_crop_with_no_aligned_point_raiseschecks the same case throughTopography.crop.test_crop_with_no_aligned_point_stopsintests/regression/topo_croprunsxgeoclawfor topo types 3 and 4 and checks for a nonzero exit, the error message, the file name, and the axis.0ba4db7band passes with the fix. On the old Fortran, both regression runs exit 0.topo_cropregressions: 7 passed.Related
#760 (a crop that runs off a file). Once a crop that can't keep any point is an error everywhere, a tile-selection helper there can use
crop_indicesto drop tiles that would come out empty after coarsening.