Skip to content

Commit

Permalink
Merge branch 'master' into margriet_45_geopackage
Browse files Browse the repository at this point in the history
  • Loading branch information
margrietpalm committed Feb 22, 2024
2 parents aa8c9e6 + 600c14c commit 40a24f7
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 5 deletions.
9 changes: 8 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,19 @@ Changelog of threedi-modelchecker
=================================


2.6.1 (unreleased)
2.6.2 (unreleased)
------------------

- Nothing changed yet.


2.6.1 (2024-02-20)
------------------

- Add warning check (1500) to warn about a friction value <= 1 for Chezy friction
- Add warning check (1501) to warn about friction values <= 1 or Chezy friction


2.6.0 (2024-01-31)
------------------

Expand Down
2 changes: 1 addition & 1 deletion threedi_modelchecker/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from .model_checks import * # NOQA

# fmt: off
__version__ = '2.6.1.dev0'
__version__ = '2.6.2.dev0'
# fmt: on
7 changes: 6 additions & 1 deletion threedi_modelchecker/checks/cross_section_definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,7 @@ def __init__(
max_value=None,
left_inclusive=True,
right_inclusive=True,
message=None,
*args,
**kwargs,
):
Expand All @@ -641,6 +642,7 @@ def __init__(
)
str_parts.append(f"{'> ' if right_inclusive else '>= '}{max_value}")
self.range_str = " and/or ".join(str_parts)
self.message = message
super().__init__(*args, **kwargs)

def get_invalid(self, session):
Expand All @@ -661,7 +663,10 @@ def get_invalid(self, session):
return invalids

def description(self):
return f"some values in {self.column_name} are {self.range_str}"
if self.message is None:
return f"some values in {self.column_name} are {self.range_str}"
else:
return self.message


class CrossSectionVariableFrictionRangeCheck(CrossSectionVariableRangeCheck):
Expand Down
48 changes: 46 additions & 2 deletions threedi_modelchecker/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,6 @@ def is_none_or_empty(col):
)
]


## 003x: CALCULATION TYPE

CHECKS += [
Expand Down Expand Up @@ -3004,7 +3003,6 @@ def is_none_or_empty(col):
for col in vegetation_parameter_columns
+ [models.CrossSectionDefinition.friction_values]
]

## Friction values range
CHECKS += [
CrossSectionVariableFrictionRangeCheck(
Expand Down Expand Up @@ -3123,6 +3121,52 @@ def is_none_or_empty(col):
),
]

# Checks for nonsensical Chezy friction values
CHECKS += [
RangeCheck(
error_code=1500,
level=CheckLevel.WARNING,
column=table.friction_value,
filters=table.friction_type == constants.FrictionType.CHEZY.value,
min_value=1,
message=f"{table.__tablename__}.friction_value is less than 1 while CHEZY friction is selected. This may cause nonsensical results.",
)
for table in [
models.CrossSectionLocation,
models.Culvert,
models.Pipe,
]
]
CHECKS += [
RangeCheck(
error_code=1500,
level=CheckLevel.WARNING,
column=table.friction_value,
filters=(table.friction_type == constants.FrictionType.CHEZY.value)
& (table.crest_type == constants.CrestType.BROAD_CRESTED.value),
min_value=1,
message=f"{table.__tablename__}.friction_value is less than 1 while CHEZY friction is selected. This may cause nonsensical results.",
)
for table in [
models.Orifice,
models.Weir,
]
]
CHECKS += [
CrossSectionVariableFrictionRangeCheck(
min_value=1,
level=CheckLevel.WARNING,
error_code=1501,
column=models.CrossSectionDefinition.friction_values,
shapes=(constants.CrossSectionShape.TABULATED_YZ,),
friction_types=[
constants.FrictionType.CHEZY.value,
constants.FrictionType.CHEZY_CONVEYANCE.value,
],
message="Some values in CrossSectionDefinition.friction_values are less than 1 while CHEZY friction is selected. This may cause nonsensical results.",
)
]

# These checks are optional, depending on a command line argument
beta_features_check = []
beta_features_check += [
Expand Down

0 comments on commit 40a24f7

Please sign in to comment.