Skip to content

Commit

Permalink
TTim Well: slug default False
Browse files Browse the repository at this point in the history
Add StrictlyPositive schema
  • Loading branch information
Huite committed Oct 27, 2023
1 parent 32f1606 commit 2e3e807
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 21 deletions.
9 changes: 5 additions & 4 deletions plugin/qgistim/core/elements/aquifer.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
Required,
SemiConfined,
StrictlyDecreasing,
StrictlyPositive,
)


Expand All @@ -21,8 +22,8 @@ class AquiferSchema(TableSchema):
"layer": AllRequired(Range()),
"aquifer_top": AllRequired(StrictlyDecreasing()),
"aquifer_bottom": AllRequired(StrictlyDecreasing()),
"aquitard_c": OffsetAllRequired(Positive()),
"aquifer_k": AllRequired(Positive()),
"aquitard_c": OffsetAllRequired(StrictlyPositive()),
"aquifer_k": AllRequired(StrictlyPositive()),
"semiconf_top": OptionalFirstOnly(),
"semiconf_head": OptionalFirstOnly(),
}
Expand All @@ -38,8 +39,8 @@ class AquiferSchema(TableSchema):

class TemporalSettingsSchema(SingleRowSchema):
ttim_schemata = {
"time_min": Required(Positive()),
"laplace_inversion_M": Required(Positive()),
"time_min": Required(StrictlyPositive()),
"laplace_inversion_M": Required(StrictlyPositive()),
"reference_date": Required(),
}

Expand Down
5 changes: 3 additions & 2 deletions plugin/qgistim/core/elements/building_pit.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
Required,
SemiConfined,
StrictlyDecreasing,
StrictlyPositive
)


Expand All @@ -35,8 +36,8 @@ class AssociatedBuildingPitSchema(TableSchema):
"layer": AllRequired(Range()),
"aquifer_top": AllRequired(StrictlyDecreasing()),
"aquifer_bottom": AllRequired(StrictlyDecreasing()),
"aquitard_c": OffsetAllRequired(Positive()),
"aquifer_k": AllRequired(Positive()),
"aquitard_c": OffsetAllRequired(StrictlyPositive()),
"aquifer_k": AllRequired(StrictlyPositive()),
"semiconf_top": OptionalFirstOnly(),
"semiconf_head": OptionalFirstOnly(),
"wall_in_layer": AllRequired(AtleastOneTrue()),
Expand Down
3 changes: 2 additions & 1 deletion plugin/qgistim/core/elements/head_line_sink.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
Optional,
Positive,
Required,
StrictlyPositive,
)


Expand All @@ -19,7 +20,7 @@ class HeadLineSinkSchema(RowWiseSchema):
"geometry": Required(),
"head": Required(),
"resistance": Required(Positive()),
"width": Required(Positive()),
"width": Required(StrictlyPositive()),
"order": Required(Positive()),
"layer": Required(Membership("aquifer layers")),
}
Expand Down
3 changes: 2 additions & 1 deletion plugin/qgistim/core/elements/headwell.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,15 @@
Optional,
Positive,
Required,
StrictlyPositive,
)


class HeadWellSchema(RowWiseSchema):
timml_schemata = {
"geometry": Required(),
"head": Required(),
"radius": Required(Positive()),
"radius": Required(StrictlyPositive()),
"resistance": Required(Positive()),
"layer": Required(Membership("aquifer layers")),
}
Expand Down
7 changes: 4 additions & 3 deletions plugin/qgistim/core/elements/leaky_building_pit.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
RequiredFirstOnly,
SemiConfined,
StrictlyDecreasing,
StrictlyPositive,
)


Expand All @@ -36,11 +37,11 @@ class AssociatedLeakyBuildingPitchema(TableSchema):
"layer": AllRequired(Range()),
"aquifer_top": AllRequired(StrictlyDecreasing()),
"aquifer_bottom": AllRequired(StrictlyDecreasing()),
"aquitard_c": OffsetAllRequired(Positive()),
"aquifer_k": AllRequired(Positive()),
"aquitard_c": OffsetAllRequired(StrictlyPositive()),
"aquifer_k": AllRequired(StrictlyPositive()),
"semiconf_top": OptionalFirstOnly(),
"semiconf_head": OptionalFirstOnly(),
"resistance": RequiredFirstOnly(),
"resistance": RequiredFirstOnly(StrictlyPositive()),
"wall_in_layer": AllRequired(AtleastOneTrue()),
}
timml_consistency_schemata = (
Expand Down
4 changes: 2 additions & 2 deletions plugin/qgistim/core/elements/leaky_line_doublet.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
from qgistim.core.elements.colors import RED
from qgistim.core.elements.element import Element
from qgistim.core.elements.schemata import RowWiseSchema
from qgistim.core.schemata import Membership, Positive, Required
from qgistim.core.schemata import Membership, Positive, Required, StrictlyPositive


class LeakyLineDoubletSchema(RowWiseSchema):
timml_schemata = {
"geometry": Required(),
"resistance": Required(Positive()),
"resistance": Required(StrictlyPositive()),
"order": Required(Positive()),
"layer": Required(Membership("aquifer layers")),
}
Expand Down
3 changes: 2 additions & 1 deletion plugin/qgistim/core/elements/line_sink_ditch.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
Optional,
Positive,
Required,
StrictlyPositive,
)


Expand All @@ -19,7 +20,7 @@ class LineSinkDitchSchema(RowWiseSchema):
"geometry": Required(),
"discharge": Required(),
"resistance": Required(Positive()),
"width": Required(Positive()),
"width": Required(StrictlyPositive()),
"order": Required(Positive()),
"layer": Required(Membership("aquifer layers")),
}
Expand Down
4 changes: 2 additions & 2 deletions plugin/qgistim/core/elements/polygon_semi_confined_top.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
from qgistim.core.elements.colors import BLUE, TRANSPARENT_BLUE
from qgistim.core.elements.element import Element
from qgistim.core.elements.schemata import RowWiseSchema
from qgistim.core.schemata import Positive, Required
from qgistim.core.schemata import Positive, Required, StrictlyPositive


class PolygonSemiConfinedTopSchema(RowWiseSchema):
timml_schemata = {
"geometry": Required(),
"aquitard_c": Required(Positive()),
"aquitard_c": Required(StrictlyPositive()),
"semiconf_top": Required(),
"semiconf_head": Required(),
"order": Required(Positive()),
Expand Down
9 changes: 5 additions & 4 deletions plugin/qgistim/core/elements/well.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,20 @@
Optional,
Positive,
Required,
StrictlyPositive,
)


class WellSchema(RowWiseSchema):
timml_schemata = {
"geometry": Required(),
"discharge": Required(),
"radius": Required(Positive()),
"radius": Required(StrictlyPositive()),
"resistance": Required(Positive()),
"layer": Required(Membership("aquifer layers")),
}
ttim_schemata = {
"caisson_radius": Required(Positive),
"caisson_radius": Required(StrictlyPositive),
"slug": Required(),
"time_start": Optional(Positive()),
"time_end": Optional(Positive()),
Expand Down Expand Up @@ -66,8 +67,8 @@ class Well(TransientElement):
timml_defaults = {
"radius": QgsDefaultValue("0.1"),
"resistance": QgsDefaultValue("0.0"),
"caisson_radius": QgsDefaultValue("0.0"),
"slug": QgsDefaultValue("True"),
"caisson_radius": QgsDefaultValue("0.1"),
"slug": QgsDefaultValue("False"),
}
transient_columns = (
"time_start",
Expand Down
9 changes: 8 additions & 1 deletion plugin/qgistim/core/schemata.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,14 @@ def validate(self, data, other=None) -> ErrorList:
class Positive(BaseSchema):
def validate(self, data, _=None) -> MaybeError:
if data < 0:
return f"Non-positive value: {data}"
return f"Number is not positive (>=0): {data}"
return None


class StrictlyPositive(BaseSchema):
def validate(self, data, _=None) -> MaybeError:
if data <= 0:
return f"Number is not strictly positive (>0): {data}"
return None


Expand Down

0 comments on commit 2e3e807

Please sign in to comment.