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 ...@@ -12,6 +12,8 @@ from .results import SimStadtResults
from .runner import run_workflow_with_citygml from .runner import run_workflow_with_citygml
from .utils import remove_random_id, set_random_seed 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]: def _set_weather_file(meteonorm_filename: str) -> dict[str, str]:
"""Build the params.xml replacement for the weather file.""" """Build the params.xml replacement for the weather file."""
...@@ -39,6 +41,7 @@ def photovoltaic_simulation( ...@@ -39,6 +41,7 @@ def photovoltaic_simulation(
hourly_pv: bool = False, hourly_pv: bool = False,
with_shadows: bool = True, with_shadows: bool = True,
description: str = "Photovoltaic", description: str = "Photovoltaic",
project_path: Path | None = None,
) -> SimStadtResults: ) -> SimStadtResults:
"""Run a PhotovoltaicPotential workflow. """Run a PhotovoltaicPotential workflow.
...@@ -60,8 +63,8 @@ def photovoltaic_simulation( ...@@ -60,8 +63,8 @@ def photovoltaic_simulation(
"<int>MIN_ROOF_INSOLATION</int>": f"<int>{min_roof_insolation}</int>", "<int>MIN_ROOF_INSOLATION</int>": f"<int>{min_roof_insolation}</int>",
"<boolean>HOURLY_PV</boolean>": f"<boolean>{str(hourly_pv).lower()}</boolean>", "<boolean>HOURLY_PV</boolean>": f"<boolean>{str(hourly_pv).lower()}</boolean>",
} }
template = "105_PVWithShadow" if with_shadows else "103_PV" template = BUNDLED_TEMPLATES / ("105_PVWithShadow" if with_shadows else "103_PV")
pv_results = run_workflow_with_citygml(template, citygml_path, replaces=replaces, description=description) 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)) set_random_seed(remove_random_id(citygml_path.name))
pv_results._df = pv_results.dataframe.sample(frac=roof_percentage / 100.0) pv_results._df = pv_results.dataframe.sample(frac=roof_percentage / 100.0)
...@@ -75,6 +78,7 @@ def heatdemand_simulation( ...@@ -75,6 +78,7 @@ def heatdemand_simulation(
calculation_mode: str = "HEATING", calculation_mode: str = "HEATING",
refurbishment_ratio: float = 0.0, refurbishment_ratio: float = 0.0,
description: str = "Heat demand", description: str = "Heat demand",
project_path: Path | None = None,
) -> SimStadtResults: ) -> SimStadtResults:
"""Run a HeatDemand workflow. """Run a HeatDemand workflow.
...@@ -87,13 +91,13 @@ def heatdemand_simulation( ...@@ -87,13 +91,13 @@ def heatdemand_simulation(
description: Label stored on the result object. description: Label stored on the result object.
""" """
citygml_path = Path(citygml_path) 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 = ( replaces = (
_set_weather_file(meteonorm_filename) _set_weather_file(meteonorm_filename)
| _set_calculation_mode(calculation_mode) | _set_calculation_mode(calculation_mode)
| _set_refurbishment(refurbishment_ratio) | _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( def greenwater_simulation(
...@@ -101,6 +105,7 @@ def greenwater_simulation( ...@@ -101,6 +105,7 @@ def greenwater_simulation(
meteonorm_filename: str, meteonorm_filename: str,
irrigation_ratio: float, irrigation_ratio: float,
description: str = "Green water", description: str = "Green water",
project_path: Path | None = None,
) -> SimStadtResults: ) -> SimStadtResults:
"""Run a GreenWater workflow. """Run a GreenWater workflow.
...@@ -114,4 +119,4 @@ def greenwater_simulation( ...@@ -114,4 +119,4 @@ def greenwater_simulation(
replaces = _set_weather_file(meteonorm_filename) | { replaces = _set_weather_file(meteonorm_filename) | {
"<double>MAX_WATER_STRESS</double>": f"<double>{1 - irrigation_ratio}</double>", "<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