Add D-inf and MFD variants of flow_path, watershed, and HAND#1020
Open
brendancol wants to merge 5 commits intomasterfrom
Open
Add D-inf and MFD variants of flow_path, watershed, and HAND#1020brendancol wants to merge 5 commits intomasterfrom
brendancol wants to merge 5 commits intomasterfrom
Conversation
Implements six new hydrology modules, each with four backends (numpy, cupy, dask, dask+cupy) and full test coverage: - flow_path_dinf: D-inf flow path tracing (dominant neighbor) - flow_path_mfd: MFD flow path tracing (dominant neighbor) - watershed_dinf: D-inf watershed delineation - watershed_mfd: MFD watershed delineation - hand_dinf: D-inf Height Above Nearest Drainage - hand_mfd: MFD Height Above Nearest Drainage Closes #1014, closes #1015, closes #1016, closes #1017, closes #1018, closes #1019
Moves 30 hydrology source modules and 30 test files into xrspatial/hydrology/ and xrspatial/hydrology/tests/ respectively. Also moves _boundary_store.py which is used exclusively by hydrology code. All internal cross-references updated. Top-level imports (from xrspatial import flow_direction, etc.) still work via xrspatial/__init__.py re-exports. The new xrspatial.hydrology subpackage also provides direct access (from xrspatial.hydrology import flow_direction). 457 hydrology tests pass, 2050 non-hydrology tests pass.
Rename all 13 unsuffixed D8 source files and their test files to include a _d8 suffix (e.g. flow_direction.py -> flow_direction_d8.py), matching the existing _dinf/_mfd convention. Public functions inside each file are also renamed (flow_direction -> flow_direction_d8, etc.). stream_order_d8's "method" parameter (strahler/shreve) is renamed to "ordering" to avoid collision with the routing dispatch. hydro/__init__.py now provides unified wrappers via _RoutingDispatch, so callers can do flow_direction(dem, routing='dinf') instead of importing flow_direction_dinf directly. D8-only functions (basin, sink, fill, twi, snap_pour_point) accept routing= for forward compatibility. All cross-module imports, dinf/mfd helper imports, test imports, and example imports are updated accordingly.
The cross-backend tests parametrize size and dtype for the random_data fixture but the test functions didn't declare those parameters, causing pytest collection to fail.
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.
Summary
Each module supports all four backends (numpy, cupy, dask, dask+cupy) and follows the same architecture as the existing D8 implementations. The D-inf variants use angle decomposition from
_angle_to_neighbors; the MFD variants follow the highest-fraction neighbor at each step.Six new modules, 84 new tests, all passing. No changes to existing modules or tests.
Test plan
pytest xrspatial/tests/test_{flow_path,watershed,hand}_{dinf,mfd}.py)Closes #1014, closes #1015, closes #1016, closes #1017, closes #1018, closes #1019