flood-adapt 0.3.2__py3-none-any.whl → 0.3.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- flood_adapt/__init__.py +1 -1
- flood_adapt/adapter/fiat_adapter.py +35 -1
- flood_adapt/config/config.py +58 -36
- flood_adapt/config/gui.py +189 -82
- flood_adapt/database_builder/database_builder.py +86 -59
- flood_adapt/dbs_classes/database.py +16 -53
- flood_adapt/dbs_classes/dbs_event.py +4 -1
- flood_adapt/dbs_classes/dbs_measure.py +7 -7
- flood_adapt/dbs_classes/dbs_projection.py +4 -1
- flood_adapt/dbs_classes/dbs_scenario.py +17 -8
- flood_adapt/dbs_classes/dbs_strategy.py +7 -5
- flood_adapt/dbs_classes/dbs_template.py +21 -22
- flood_adapt/dbs_classes/interface/database.py +0 -8
- flood_adapt/dbs_classes/interface/element.py +1 -1
- flood_adapt/flood_adapt.py +20 -13
- flood_adapt/workflows/benefit_runner.py +4 -1
- flood_adapt/workflows/scenario_runner.py +8 -7
- flood_adapt-0.3.3.dist-info/LICENSE +674 -0
- flood_adapt-0.3.3.dist-info/METADATA +859 -0
- {flood_adapt-0.3.2.dist-info → flood_adapt-0.3.3.dist-info}/RECORD +23 -23
- flood_adapt-0.3.2.dist-info/LICENSE +0 -21
- flood_adapt-0.3.2.dist-info/METADATA +0 -182
- /flood_adapt/database_builder/templates/{mapbox_layers → output_layers}/bin_colors.toml +0 -0
- {flood_adapt-0.3.2.dist-info → flood_adapt-0.3.3.dist-info}/WHEEL +0 -0
- {flood_adapt-0.3.2.dist-info → flood_adapt-0.3.3.dist-info}/top_level.txt +0 -0
flood_adapt/flood_adapt.py
CHANGED
|
@@ -38,6 +38,7 @@ from flood_adapt.objects.projections.projections import Projection
|
|
|
38
38
|
from flood_adapt.objects.scenarios.scenarios import Scenario
|
|
39
39
|
from flood_adapt.objects.strategies.strategies import Strategy
|
|
40
40
|
from flood_adapt.workflows.impacts_integrator import Impacts
|
|
41
|
+
from flood_adapt.workflows.scenario_runner import ScenarioRunner
|
|
41
42
|
|
|
42
43
|
|
|
43
44
|
class FloodAdapt:
|
|
@@ -68,7 +69,7 @@ class FloodAdapt:
|
|
|
68
69
|
Includes keys: 'name', 'description', 'path', 'last_modification_date', 'objects'
|
|
69
70
|
Each value is a list of the corresponding attribute for each measure.
|
|
70
71
|
"""
|
|
71
|
-
return self.database.measures.
|
|
72
|
+
return self.database.measures.summarize_objects()
|
|
72
73
|
|
|
73
74
|
def get_measure(self, name: str) -> Measure:
|
|
74
75
|
"""
|
|
@@ -208,7 +209,7 @@ class FloodAdapt:
|
|
|
208
209
|
Includes keys: 'name', 'description', 'path', 'last_modification_date', 'objects'
|
|
209
210
|
Each value is a list of the corresponding attribute for each strategy.
|
|
210
211
|
"""
|
|
211
|
-
return self.database.strategies.
|
|
212
|
+
return self.database.strategies.summarize_objects()
|
|
212
213
|
|
|
213
214
|
def get_strategy(self, name: str) -> Strategy:
|
|
214
215
|
"""
|
|
@@ -310,7 +311,7 @@ class FloodAdapt:
|
|
|
310
311
|
Includes keys: 'name', 'description', 'path', 'last_modification_date', 'objects'
|
|
311
312
|
Each value is a list of the corresponding attribute for each benefit.
|
|
312
313
|
"""
|
|
313
|
-
return self.database.events.
|
|
314
|
+
return self.database.events.summarize_objects()
|
|
314
315
|
|
|
315
316
|
def get_event(self, name: str) -> Event | EventSet:
|
|
316
317
|
"""Get an event from the database by name.
|
|
@@ -476,7 +477,7 @@ class FloodAdapt:
|
|
|
476
477
|
Includes keys: 'name', 'description', 'path', 'last_modification_date', 'objects'
|
|
477
478
|
Each value is a list of the corresponding attribute for each projection.
|
|
478
479
|
"""
|
|
479
|
-
return self.database.projections.
|
|
480
|
+
return self.database.projections.summarize_objects()
|
|
480
481
|
|
|
481
482
|
def get_projection(self, name: str) -> Projection:
|
|
482
483
|
"""Get a projection from the database by name.
|
|
@@ -633,7 +634,7 @@ class FloodAdapt:
|
|
|
633
634
|
Includes keys: 'name', 'description', 'path', 'last_modification_date', 'objects'.
|
|
634
635
|
Each value is a list of the corresponding attribute for each scenario.
|
|
635
636
|
"""
|
|
636
|
-
return self.database.scenarios.
|
|
637
|
+
return self.database.scenarios.summarize_objects()
|
|
637
638
|
|
|
638
639
|
def get_scenario(self, name: str) -> Scenario:
|
|
639
640
|
"""Get a scenario from the database by name.
|
|
@@ -726,20 +727,26 @@ class FloodAdapt:
|
|
|
726
727
|
"""
|
|
727
728
|
self.database.scenarios.delete(name)
|
|
728
729
|
|
|
729
|
-
def run_scenario(self,
|
|
730
|
-
"""Run a scenario.
|
|
730
|
+
def run_scenario(self, scenario_name: Union[str, list[str]]) -> None:
|
|
731
|
+
"""Run a scenario hazard and impacts.
|
|
731
732
|
|
|
732
733
|
Parameters
|
|
733
734
|
----------
|
|
734
|
-
|
|
735
|
-
|
|
735
|
+
scenario_name : Union[str, list[str]]
|
|
736
|
+
name(s) of the scenarios to run.
|
|
736
737
|
|
|
737
738
|
Raises
|
|
738
739
|
------
|
|
739
|
-
|
|
740
|
-
If
|
|
740
|
+
RuntimeError
|
|
741
|
+
If an error occurs while running one of the scenarios
|
|
741
742
|
"""
|
|
742
|
-
|
|
743
|
+
if not isinstance(scenario_name, list):
|
|
744
|
+
scenario_name = [scenario_name]
|
|
745
|
+
|
|
746
|
+
for scn in scenario_name:
|
|
747
|
+
scenario = self.get_scenario(scn)
|
|
748
|
+
runner = ScenarioRunner(self.database, scenario=scenario)
|
|
749
|
+
runner.run()
|
|
743
750
|
|
|
744
751
|
# Outputs
|
|
745
752
|
def get_completed_scenarios(
|
|
@@ -1088,7 +1095,7 @@ class FloodAdapt:
|
|
|
1088
1095
|
Each value is a list of the corresponding attribute for each benefit.
|
|
1089
1096
|
"""
|
|
1090
1097
|
# sorting and filtering either with PyQt table or in the API
|
|
1091
|
-
return self.database.benefits.
|
|
1098
|
+
return self.database.benefits.summarize_objects()
|
|
1092
1099
|
|
|
1093
1100
|
def get_benefit(self, name: str) -> Benefit:
|
|
1094
1101
|
"""Get a benefit from the database by name.
|
|
@@ -117,7 +117,10 @@ class BenefitRunner:
|
|
|
117
117
|
scenarios_calc[scenario]["strategy"] = self.benefit.strategy
|
|
118
118
|
|
|
119
119
|
# Get the available scenarios
|
|
120
|
-
scenarios_avail =
|
|
120
|
+
scenarios_avail = [
|
|
121
|
+
self.database.scenarios.get(scn)
|
|
122
|
+
for scn in self.database.scenarios.summarize_objects()["name"]
|
|
123
|
+
]
|
|
121
124
|
|
|
122
125
|
# Check if any of the needed scenarios are already there
|
|
123
126
|
for scenario in scenarios_calc.keys():
|
|
@@ -30,16 +30,17 @@ class ScenarioRunner:
|
|
|
30
30
|
scenario=self._scenario,
|
|
31
31
|
)
|
|
32
32
|
|
|
33
|
-
def run(self
|
|
33
|
+
def run(self) -> None:
|
|
34
34
|
"""Run hazard and impact models for the scenario."""
|
|
35
|
-
self.
|
|
35
|
+
self._database.has_run_hazard(self._scenario.name)
|
|
36
|
+
self._load_objects(self._scenario)
|
|
36
37
|
self.results_path.mkdir(parents=True, exist_ok=True)
|
|
37
38
|
|
|
38
39
|
# Initiate the logger for all the integrator scripts.
|
|
39
|
-
log_file = self.results_path.joinpath(f"logfile_{
|
|
40
|
+
log_file = self.results_path.joinpath(f"logfile_{self._scenario.name}.log")
|
|
40
41
|
with FloodAdaptLogging.to_file(file_path=log_file):
|
|
41
42
|
self.logger.info(f"FloodAdapt version `{__version__}`")
|
|
42
|
-
self.logger.info(f"Started evaluation of `{
|
|
43
|
+
self.logger.info(f"Started evaluation of `{self._scenario.name}`")
|
|
43
44
|
|
|
44
45
|
hazard_models = [
|
|
45
46
|
self._database.static.get_overland_sfincs_model(),
|
|
@@ -49,17 +50,17 @@ class ScenarioRunner:
|
|
|
49
50
|
hazard.run(self._scenario)
|
|
50
51
|
else:
|
|
51
52
|
self.logger.info(
|
|
52
|
-
f"Hazard for scenario '{
|
|
53
|
+
f"Hazard for scenario '{self._scenario.name}' has already been run."
|
|
53
54
|
)
|
|
54
55
|
|
|
55
56
|
if not self.impacts.has_run:
|
|
56
57
|
self.impacts.run()
|
|
57
58
|
else:
|
|
58
59
|
self.logger.info(
|
|
59
|
-
f"Impacts for scenario `{
|
|
60
|
+
f"Impacts for scenario `{self._scenario.name}` has already been run."
|
|
60
61
|
)
|
|
61
62
|
|
|
62
|
-
self.logger.info(f"Finished evaluation of `{
|
|
63
|
+
self.logger.info(f"Finished evaluation of `{self._scenario.name}`")
|
|
63
64
|
|
|
64
65
|
# write finished file to indicate that the scenario has been run
|
|
65
66
|
write_finished_file(self.results_path)
|