Skip to content

Commit 56e233b

Browse files
Issue #1296 validation quick fixes (#1297)
Fixes #1296 # Description We ran into two edge cases with Validation giving false positive for the DIS, and false negative for the RCH. This PR: - Relaxes the validation of zero thicknesses, to also ignore cells where IDOMAIN = 0, instead only ignoring IDOMAIN = -1 - Fixes a bug in AllInsideNoData scheme, where not the right object was passed through, resulting in no validation error for the RCH package, where it should have. I added a test for the DRN package, where the same holds. # Checklist <!--- Before requesting review, please go through this checklist: --> - [x] Links to correct issue - [x] Update changelog, if changes affect users - [x] PR title starts with ``Issue #nr``, e.g. ``Issue #737`` - [x] Unit tests were added - [ ] **If feature added**: Added/extended example
1 parent 128665b commit 56e233b

5 files changed

Lines changed: 37 additions & 2 deletions

File tree

docs/api/changelog.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,19 @@ All notable changes to this project will be documented in this file.
66
The format is based on `Keep a Changelog`_, and this project adheres to
77
`Semantic Versioning`_.
88

9+
[Unreleased]
10+
------------
11+
12+
Fixed
13+
~~~~~
14+
15+
- Relaxed validation for `imod.mf6.StructuredDiscretization` to also support
16+
cells with zero thickness where IDOMAIN = 0. Before, only cells with a zero
17+
thickness and IDOMAIN = -1 were supported, else the software threw a ``not all
18+
values comply with criterion: > bottom``.
19+
- Fix bug where no ``ValidationError`` was thrown if there is an active RCH, DRN,
20+
GHB, or RIV cell where idomain = -1.
21+
922

1023
[0.18.0]
1124
--------

imod/mf6/dis.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ class StructuredDiscretization(Package, IRegridPackage, IMaskingSettings):
8585
AnyValueSchema(">", 0),
8686
),
8787
"top": (
88-
AllValueSchema(">", "bottom", ignore=("idomain", "==", -1)),
88+
AllValueSchema(">", "bottom", ignore=("idomain", "<=", 0)),
8989
IdentityNoDataSchema(other="idomain", is_other_notnull=(">", 0)),
9090
# No need to check coords: dataset ensures they align with idomain.
9191
),

imod/schemata.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,7 @@ def validate(self, obj: GridDataArray, **kwargs) -> None:
635635
valid = self.is_notnull(obj)
636636
other_valid = self.is_other_notnull(other_obj)
637637

638-
valid, other_valid = align_other_obj_with_coords(valid, other_obj)
638+
valid, other_valid = align_other_obj_with_coords(valid, other_valid)
639639

640640
if (valid & ~other_valid).any():
641641
raise ValidationError(f"data values found at nodata values of {self.other}")

imod/tests/test_mf6/test_mf6_dis.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,12 @@ def test_top_exceeding_bottom(idomain_and_bottom):
113113
errors = dis._validate(dis._write_schemata, idomain=idomain)
114114
assert len(errors) == 0
115115

116+
# Or inactive
117+
idomain[0:2, :, :] = 0
118+
dis = imod.mf6.StructuredDiscretization(top=-400.0, bottom=bottom, idomain=idomain)
119+
errors = dis._validate(dis._write_schemata, idomain=idomain)
120+
assert len(errors) == 0
121+
116122

117123
def test_overlaying_bottom_inactive(idomain_and_bottom):
118124
"""

imod/tests/test_mf6/test_mf6_drn.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,22 @@ def test_check_conductance_zero(drainage):
153153
assert var == "conductance"
154154

155155

156+
@pytest.mark.parametrize("nodata_idomain", [0, -1])
157+
def test_validate_inside_nodata(drainage, nodata_idomain):
158+
idomain = drainage["elevation"].astype(np.int16)
159+
top = 1.0
160+
bottom = top - idomain.coords["layer"]
161+
162+
idomain[:, 2, 2] = nodata_idomain
163+
164+
dis = imod.mf6.StructuredDiscretization(top=top, bottom=bottom, idomain=idomain)
165+
drn = imod.mf6.Drainage(**drainage)
166+
errors = drn._validate(drn._write_schemata, **dis.dataset)
167+
assert len(errors) == 1
168+
for var, error in errors.items():
169+
assert var == "elevation"
170+
171+
156172
def test_validate_concentration(transient_concentration_drainage):
157173
idomain = transient_concentration_drainage["elevation"].astype(np.int16)
158174
top = 1.0

0 commit comments

Comments
 (0)