Commit 14952505 authored by Eric Duminil's avatar Eric Duminil
Browse files

Adding bundled templates

parent e07fb2e3
......@@ -12,6 +12,8 @@ from .results import SimStadtResults
from .runner import run_workflow_with_citygml
from .utils import remove_random_id, set_random_seed
BUNDLED_TEMPLATES = Path(__file__).parent / "templates"
def _set_weather_file(meteonorm_filename: str) -> dict[str, str]:
"""Build the params.xml replacement for the weather file."""
......@@ -39,6 +41,7 @@ def photovoltaic_simulation(
hourly_pv: bool = False,
with_shadows: bool = True,
description: str = "Photovoltaic",
project_path: Path | None = None,
) -> SimStadtResults:
"""Run a PhotovoltaicPotential workflow.
......@@ -60,8 +63,8 @@ def photovoltaic_simulation(
"<int>MIN_ROOF_INSOLATION</int>": f"<int>{min_roof_insolation}</int>",
"<boolean>HOURLY_PV</boolean>": f"<boolean>{str(hourly_pv).lower()}</boolean>",
}
template = "105_PVWithShadow" if with_shadows else "103_PV"
pv_results = run_workflow_with_citygml(template, citygml_path, replaces=replaces, description=description)
template = BUNDLED_TEMPLATES / ("105_PVWithShadow" if with_shadows else "103_PV")
pv_results = run_workflow_with_citygml(template, citygml_path, replaces=replaces, description=description, project_path=project_path)
set_random_seed(remove_random_id(citygml_path.name))
pv_results._df = pv_results.dataframe.sample(frac=roof_percentage / 100.0)
......@@ -75,6 +78,7 @@ def heatdemand_simulation(
calculation_mode: str = "HEATING",
refurbishment_ratio: float = 0.0,
description: str = "Heat demand",
project_path: Path | None = None,
) -> SimStadtResults:
"""Run a HeatDemand workflow.
......@@ -87,13 +91,13 @@ def heatdemand_simulation(
description: Label stored on the result object.
"""
citygml_path = Path(citygml_path)
template = "104_HeatDemandWithShadow" if with_shadows else "101_HeatDemand"
template = BUNDLED_TEMPLATES / ("104_HeatDemandWithShadow" if with_shadows else "101_HeatDemand")
replaces = (
_set_weather_file(meteonorm_filename)
| _set_calculation_mode(calculation_mode)
| _set_refurbishment(refurbishment_ratio)
)
return run_workflow_with_citygml(template, citygml_path, replaces=replaces, description=description)
return run_workflow_with_citygml(template, citygml_path, replaces=replaces, description=description, project_path=project_path)
def greenwater_simulation(
......@@ -101,6 +105,7 @@ def greenwater_simulation(
meteonorm_filename: str,
irrigation_ratio: float,
description: str = "Green water",
project_path: Path | None = None,
) -> SimStadtResults:
"""Run a GreenWater workflow.
......@@ -114,4 +119,4 @@ def greenwater_simulation(
replaces = _set_weather_file(meteonorm_filename) | {
"<double>MAX_WATER_STRESS</double>": f"<double>{1 - irrigation_ratio}</double>",
}
return run_workflow_with_citygml("102_GreenWater", citygml_path, replaces=replaces, description=description)
return run_workflow_with_citygml(BUNDLED_TEMPLATES / "102_GreenWater", citygml_path, replaces=replaces, description=description, project_path=project_path)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment