Skip to content

Commit

Permalink
Fix integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
margrietpalm committed Mar 28, 2024
1 parent a9cdc43 commit 81b0f6c
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 9 deletions.
4 changes: 2 additions & 2 deletions threedigrid_builder/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ def _make_gridadmin(
progress_callback(0.7, "Constructing 2D computational grid...")
quadtree = QuadTree(
subgrid_meta,
grid_settings.kmax,
grid_settings.grid_space,
grid_settings.nr_grid_levels,
grid_settings.minimum_cell_size,
grid_settings.use_2d_flow,
refinements,
)
Expand Down
4 changes: 3 additions & 1 deletion threedigrid_builder/grid/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,9 @@ def from_meta(cls, **kwargs):
# set flags
s = meta.tables_settings # shorthand
meta.has_interception = s.interception_type is not None
meta.has_groundwater_flow = s.groundwater_hydraulic_conductivity_type is not None
meta.has_groundwater_flow = (
s.groundwater_hydraulic_conductivity_type is not None
)
meta.has_simple_infiltration = s.infiltration_rate_type is not None
meta.has_max_infiltration_capacity = (
s.max_infiltration_capacity_type is not None
Expand Down
30 changes: 24 additions & 6 deletions threedigrid_builder/interface/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,10 @@ def get_settings(self) -> dict:

with self.get_session() as session:
model_settings = session.query(models.ModelSettings).order_by("id").first()
if model_settings.use_groundwater_flow or model_settings.use_groundwater_storage:
if (
model_settings.use_groundwater_flow
or model_settings.use_groundwater_storage
):
groundwater = _object_as_dict(session.query(models.GroundWater).one())
else:
groundwater = {}
Expand All @@ -155,13 +158,17 @@ def get_settings(self) -> dict:
else:
interflow = {}
if model_settings.use_simple_infiltration:
infiltration = _object_as_dict(session.query(models.SimpleInfiltration).one())
infiltration = _object_as_dict(
session.query(models.SimpleInfiltration).one()
)
# older sqlites have no max_infiltration_capacity field
infiltration.setdefault("max_infiltration_capacity", None)
else:
infiltration = {}
if model_settings.use_vegetation_drag_2d:
vegetation_drag = _object_as_dict(session.query(models.VegetationDrag).one())
vegetation_drag = _object_as_dict(
session.query(models.VegetationDrag).one()
)
else:
vegetation_drag = {}
if model_settings.use_interception:
Expand All @@ -178,7 +185,9 @@ def get_settings(self) -> dict:
NO_AGG = InitializationType.NO_AGG
AVERAGE = InitializationType.AVERAGE
_set_initialization_type(
model_settings, "friction_coefficient", default=AVERAGE if model_settings["friction_averaging"] else NO_AGG
model_settings,
"friction_coefficient",
default=AVERAGE if model_settings["friction_averaging"] else NO_AGG,
)
_set_initialization_type(
interception,
Expand Down Expand Up @@ -220,13 +229,22 @@ def get_settings(self) -> dict:
vegetation_drag, "vegetation_drag_coefficient", default=NO_AGG
)
# Copy Simulation Template Settings to model_settings dict
template_settings = _object_as_dict(session.query(models.SimulationTemplateSettings).order_by("id").first())
template_settings = _object_as_dict(
session.query(models.SimulationTemplateSettings).order_by("id").first()
)
model_settings["name"] = template_settings["name"]
model_settings["use_0d_inflow"] = template_settings["use_0d_inflow"]

grid_settings = GridSettings.from_dict(model_settings)
tables_settings = TablesSettings.from_dict(
{**groundwater, **interflow, **infiltration, **vegetation_drag, **model_settings, **interception}
{
**groundwater,
**interflow,
**infiltration,
**vegetation_drag,
**model_settings,
**interception,
}
)
return {
"epsg_code": model_settings["epsg_code"],
Expand Down

0 comments on commit 81b0f6c

Please sign in to comment.