Issue #1787 mask topsystem packages - #1918
Open
JoerivanEngelen wants to merge 29 commits into
Open
JoerivanEngelen wants to merge 29 commits into
JoerivanEngelen wants to merge 29 commits into
Conversation
…undaryCondition interface.
… ibound is not active
… of mask for topsystem in clip_box.
…el module to their respective
JoerivanEngelen
requested review from
ClaireDons and
LuukBlom
and
a lite review from Copilot
September 24, 2026 13:23
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Unresolved critical and moderate findings remain in conversion, masking, and test integration.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 5
Open (6)
Avoid unconditional BND lookup for CAP-only inputs · New Update tests for renamed clipped-boundary helper · New Define ibound in the topsystem regrid method · New Default the optional purge flag to false · New Update tests referencing the removed boundary helper · New Purge all empty packages after boundary clipping · New
What changed in this PR
Adds IBOUND-based masking for topsystem and MetaSWAP packages, selective package masking, and clipped-boundary refactoring.
Changes:
- Regrids and applies IBOUND masks.
- Adds
mask_packagesand topsystem interfaces. - Updates conversion, clipping, tests, fixtures, and documentation.
| File | Summary |
|---|---|
imod/util/dims.py |
Handles BND layer dimensions. |
imod/typing/__init__.py |
Adds BND typing. |
imod/tests/test_msw/test_utilities/test_msw_mask_util.py |
Tests MetaSWAP masking. |
imod/tests/test_msw/test_grid_data.py |
Tests IBOUND-based activity. |
imod/tests/test_mf6/test_utilities/test_mf6_mask_util.py |
Tests topsystem masking. |
imod/tests/test_mf6/test_utilities/test_mf6_clipped_boundary_condition_creator.py |
Updates clipped-boundary tests. |
imod/tests/test_mf6/test_mf6_simulation.py |
Tests imported topsystem masking. |
imod/tests/test_mf6/test_mf6_model.py |
Updates clipping tests; critical finding (2 votes): references the removed helper. |
imod/tests/test_mf6/test_ex01_twri.py |
Tests clipping-related masking. |
imod/tests/fixtures/msw_imod5_cap_fixture.py |
Adds BND fixture data. |
imod/tests/fixtures/imod5_cap_data.py |
Adds BND fixture data. |
imod/msw/utilities/imod5_converter.py |
Applies IBOUND masking; nit (1 vote): incorrect BND annotation. |
imod/msw/regrid/regrid_schemes.py |
Adds IBOUND regridding. |
imod/msw/grid_data.py |
Uses BND data for active-cell determination. |
imod/mf6/utilities/mask.py |
Adds topsystem masking; critical finding (4 votes): optional purge flag lacks a default. |
imod/mf6/utilities/imod5_converter.py |
Masks imported topsystem packages; critical finding (1 vote): default regrid method lacks ibound. |
imod/mf6/utilities/clipped_bc_creator.py |
Refactors clipped-boundary creation. |
imod/mf6/topsystem.py |
Implements the topsystem interface. |
imod/mf6/regrid/regrid_schemes.py |
Adds BND regridding settings. |
imod/mf6/rch.py |
Incorporates BND data in recharge conversion. |
imod/mf6/model.py |
Adds selective masking and clipping integration; critical finding (1 vote) concerns the removed helper, and moderate findings (2 and 1 votes) concern incomplete purging and only evaluating time zero. |
imod/mf6/model_gwf.py |
Applies IBOUND masking during import. |
imod/common/utilities/regrid.py |
Regrids CAP and BND data; critical finding (3 votes): unconditional BND lookup breaks CAP-only inputs. |
imod/common/utilities/mask.py |
Supports package-specific masking. |
imod/common/interfaces/itopsystembc.py |
Adds the topsystem interface. |
imod/common/interfaces/imodel.py |
Extends the model interface. |
docs/api/mf6.rst |
Documents selective masking. |
docs/api/changelog.rst |
Documents behavior and API changes. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
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.





Fixes #1787
Description
Context
iMOD5 masked topsystem packages (Recharge, Drainage, River, and GeneralHeadBoundary) and MetaSWAP models, wherever the IBOUND array was < 0. In these cells, ConstantHead packages are added, which can lead to short-circuits if two of these boundary conditions are placed in the cell.
This PR:
.clip_boxmethod mask topsystem packages where constant head cells are placed, to prevent short-circuits there as well.Modflow6Model.mask_packagesto public API, which allows providing a list of packages to be maskedITopSystemBoundaryConditioninterface, to allow instance checks in utility functions without circular importsimod.mf6.modelmodule toimod.mf6.utilities.clipped_bc_creatormodule.Checklist
Issue #nr, e.g.Issue #737pixi run generate-sbomand committed changes