flood-adapt 1.0.2__py3-none-any.whl → 1.0.4__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/sfincs_adapter.py +5 -23
- flood_adapt/database_builder/database_builder.py +1 -23
- flood_adapt/flood_adapt.py +1 -1
- flood_adapt/misc/debug_timer.py +26 -0
- flood_adapt/workflows/scenario_runner.py +15 -2
- {flood_adapt-1.0.2.dist-info → flood_adapt-1.0.4.dist-info}/METADATA +1 -1
- {flood_adapt-1.0.2.dist-info → flood_adapt-1.0.4.dist-info}/RECORD +11 -10
- {flood_adapt-1.0.2.dist-info → flood_adapt-1.0.4.dist-info}/LICENSE +0 -0
- {flood_adapt-1.0.2.dist-info → flood_adapt-1.0.4.dist-info}/WHEEL +0 -0
- {flood_adapt-1.0.2.dist-info → flood_adapt-1.0.4.dist-info}/top_level.txt +0 -0
flood_adapt/__init__.py
CHANGED
|
@@ -168,24 +168,7 @@ class SfincsAdapter(IHazardAdapter):
|
|
|
168
168
|
|
|
169
169
|
def has_run(self, scenario: Scenario) -> bool:
|
|
170
170
|
"""Check if the model has been run."""
|
|
171
|
-
|
|
172
|
-
if event.mode == Mode.risk:
|
|
173
|
-
sim_paths = [
|
|
174
|
-
self._get_simulation_path(scenario, sub_event=sub_event)
|
|
175
|
-
for sub_event in event.sub_events
|
|
176
|
-
]
|
|
177
|
-
if not all(sim_path.exists() for sim_path in sim_paths):
|
|
178
|
-
# simpaths dont exist, so check if the output files are still there
|
|
179
|
-
return self.run_completed(scenario)
|
|
180
|
-
else:
|
|
181
|
-
return all(self.sfincs_completed(sim_path) for sim_path in sim_paths)
|
|
182
|
-
else:
|
|
183
|
-
if not self._get_simulation_path(scenario).exists():
|
|
184
|
-
# simpath doesnt exist, so check if the output files are still there
|
|
185
|
-
return self.run_completed(scenario)
|
|
186
|
-
else:
|
|
187
|
-
# Check if the simulation folder exists
|
|
188
|
-
return self.sfincs_completed(self._get_simulation_path(scenario))
|
|
171
|
+
return self.run_completed(scenario)
|
|
189
172
|
|
|
190
173
|
def execute(self, path: Path, strict: bool = True) -> bool:
|
|
191
174
|
"""
|
|
@@ -513,10 +496,9 @@ class SfincsAdapter(IHazardAdapter):
|
|
|
513
496
|
bool : True if all flood maps exist, False otherwise.
|
|
514
497
|
|
|
515
498
|
"""
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
)
|
|
499
|
+
paths = self._get_flood_map_paths(scenario)
|
|
500
|
+
any_floodmap = len(paths) > 0
|
|
501
|
+
all_exist = all(floodmap.exists() for floodmap in paths)
|
|
520
502
|
return any_floodmap and all_exist
|
|
521
503
|
|
|
522
504
|
def sfincs_completed(self, sim_path: Path) -> bool:
|
|
@@ -1796,7 +1778,7 @@ class SfincsAdapter(IHazardAdapter):
|
|
|
1796
1778
|
units=us.UnitTypesLength(units),
|
|
1797
1779
|
)
|
|
1798
1780
|
|
|
1799
|
-
if df_gauge is None:
|
|
1781
|
+
if df_gauge is None or df_gauge.empty:
|
|
1800
1782
|
logger.warning(
|
|
1801
1783
|
"No water level data available for the tide gauge. Could not add it to the plot."
|
|
1802
1784
|
)
|
|
@@ -5,10 +5,8 @@ import math
|
|
|
5
5
|
import os
|
|
6
6
|
import re
|
|
7
7
|
import shutil
|
|
8
|
-
import time
|
|
9
8
|
import warnings
|
|
10
9
|
from enum import Enum
|
|
11
|
-
from functools import wraps
|
|
12
10
|
from pathlib import Path
|
|
13
11
|
from typing import Optional, Union
|
|
14
12
|
from urllib.request import urlretrieve
|
|
@@ -74,6 +72,7 @@ from flood_adapt.config.site import (
|
|
|
74
72
|
StandardObjectModel,
|
|
75
73
|
)
|
|
76
74
|
from flood_adapt.dbs_classes.database import Database
|
|
75
|
+
from flood_adapt.misc.debug_timer import debug_timer
|
|
77
76
|
from flood_adapt.misc.log import FloodAdaptLogging
|
|
78
77
|
from flood_adapt.misc.utils import modified_environ
|
|
79
78
|
from flood_adapt.objects.events.event_set import EventSet
|
|
@@ -92,27 +91,6 @@ from flood_adapt.objects.strategies.strategies import Strategy
|
|
|
92
91
|
logger = FloodAdaptLogging.getLogger("DatabaseBuilder")
|
|
93
92
|
|
|
94
93
|
|
|
95
|
-
def debug_timer(func):
|
|
96
|
-
@wraps(func)
|
|
97
|
-
def wrapper(*args, **kwargs):
|
|
98
|
-
logger = FloodAdaptLogging.getLogger("DatabaseBuilder") # No forced log level
|
|
99
|
-
if logger.isEnabledFor(logging.DEBUG):
|
|
100
|
-
logger.debug(f"Started '{func.__name__}'")
|
|
101
|
-
start_time = time.perf_counter()
|
|
102
|
-
|
|
103
|
-
result = func(*args, **kwargs)
|
|
104
|
-
|
|
105
|
-
end_time = time.perf_counter()
|
|
106
|
-
elapsed = end_time - start_time
|
|
107
|
-
logger.debug(f"Finished '{func.__name__}' in {elapsed:.4f} seconds")
|
|
108
|
-
else:
|
|
109
|
-
result = func(*args, **kwargs)
|
|
110
|
-
|
|
111
|
-
return result
|
|
112
|
-
|
|
113
|
-
return wrapper
|
|
114
|
-
|
|
115
|
-
|
|
116
94
|
def path_check(str_path: str, config_path: Optional[Path] = None) -> str:
|
|
117
95
|
"""Check if the given path is absolute and return the absolute path.
|
|
118
96
|
|
flood_adapt/flood_adapt.py
CHANGED
|
@@ -883,7 +883,7 @@ class FloodAdapt:
|
|
|
883
883
|
scenario = self.database.scenarios.get(name)
|
|
884
884
|
|
|
885
885
|
# Check if the scenario has run
|
|
886
|
-
if not ScenarioRunner(self.database, scenario=scenario).
|
|
886
|
+
if not ScenarioRunner(self.database, scenario=scenario).has_run_check():
|
|
887
887
|
logger.info(
|
|
888
888
|
f"Cannot retrieve observation point timeseries as the scenario {name} has not been run yet."
|
|
889
889
|
)
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
import time
|
|
3
|
+
from functools import wraps
|
|
4
|
+
|
|
5
|
+
from flood_adapt.misc.log import FloodAdaptLogging
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def debug_timer(func):
|
|
9
|
+
@wraps(func)
|
|
10
|
+
def wrapper(*args, **kwargs):
|
|
11
|
+
_logger = FloodAdaptLogging.getLogger() # No forced log level
|
|
12
|
+
if _logger.isEnabledFor(logging.DEBUG):
|
|
13
|
+
_logger.debug(f"Started '{func.__name__}'")
|
|
14
|
+
start_time = time.perf_counter()
|
|
15
|
+
|
|
16
|
+
result = func(*args, **kwargs)
|
|
17
|
+
|
|
18
|
+
end_time = time.perf_counter()
|
|
19
|
+
elapsed = end_time - start_time
|
|
20
|
+
_logger.debug(f"Finished '{func.__name__}' in {elapsed:.4f} seconds")
|
|
21
|
+
else:
|
|
22
|
+
result = func(*args, **kwargs)
|
|
23
|
+
|
|
24
|
+
return result
|
|
25
|
+
|
|
26
|
+
return wrapper
|
|
@@ -17,15 +17,28 @@ class ScenarioRunner:
|
|
|
17
17
|
self.site_info = self._database.site
|
|
18
18
|
self.results_path = self._database.scenarios.output_path / self._scenario.name
|
|
19
19
|
|
|
20
|
+
self._event = None
|
|
21
|
+
self._projection = None
|
|
22
|
+
self._strategy = None
|
|
23
|
+
|
|
24
|
+
self._hazard_models = None
|
|
25
|
+
self._impact_models = None
|
|
26
|
+
|
|
20
27
|
@property
|
|
21
28
|
def impact_models(self):
|
|
22
29
|
"""Return the list of impact models."""
|
|
23
|
-
|
|
30
|
+
if self._impact_models is not None:
|
|
31
|
+
return self._impact_models
|
|
32
|
+
self._impact_models = self._database.static.get_impact_models()
|
|
33
|
+
return self._impact_models
|
|
24
34
|
|
|
25
35
|
@property
|
|
26
36
|
def hazard_models(self):
|
|
27
37
|
"""Return the list of hazard models."""
|
|
28
|
-
|
|
38
|
+
if self._hazard_models is not None:
|
|
39
|
+
return self._hazard_models
|
|
40
|
+
self._hazard_models = self._database.static.get_hazard_models()
|
|
41
|
+
return self._hazard_models
|
|
29
42
|
|
|
30
43
|
def _load_objects(self, scenario: Scenario) -> None:
|
|
31
44
|
"""Load objects from the database."""
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: flood-adapt
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.4
|
|
4
4
|
Summary: A software package support system which can be used to assess the benefits and costs of flood resilience measures
|
|
5
5
|
Author-email: Gundula Winter <Gundula.Winter@deltares.nl>, Panos Athanasiou <Panos.Athanasiou@deltares.nl>, Frederique de Groen <Frederique.deGroen@deltares.nl>, Tim de Wilde <Tim.deWilde@deltares.nl>, Julian Hofer <Julian.Hofer@deltares.nl>, Daley Adrichem <Daley.Adrichem@deltares.nl>, Luuk Blom <Luuk.Blom@deltares.nl>
|
|
6
6
|
License: ====================================================
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
flood_adapt/__init__.py,sha256=
|
|
2
|
-
flood_adapt/flood_adapt.py,sha256=
|
|
1
|
+
flood_adapt/__init__.py,sha256=ckRctoVnY8-iqM2cbEkPXTPdOKjZJNDKeBolOYFa81s,818
|
|
2
|
+
flood_adapt/flood_adapt.py,sha256=g-OpS0spvi-puwQFhvsfu_vvduozTPXk9DU2ay9ypgs,38698
|
|
3
3
|
flood_adapt/adapter/__init__.py,sha256=vnF8NCkEVX-N-gtGS-J_A1H1YYAjihWjJZFyYGwcp8Q,180
|
|
4
4
|
flood_adapt/adapter/fiat_adapter.py,sha256=kqZsAEo4YToLtaKTwATAGgmp5-FWQffZLbAItuLx104,60010
|
|
5
|
-
flood_adapt/adapter/sfincs_adapter.py,sha256=
|
|
5
|
+
flood_adapt/adapter/sfincs_adapter.py,sha256=mvW1cW8NNr2fnhZW0Ffzg9gDuheSrhTvYI0Y0AkLCNA,78499
|
|
6
6
|
flood_adapt/adapter/sfincs_offshore.py,sha256=MjSPTrFPuOI2VqHeaBobS_OCozgnJST05nR49lq7cPs,7639
|
|
7
7
|
flood_adapt/adapter/interface/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
8
8
|
flood_adapt/adapter/interface/hazard_adapter.py,sha256=S2NIUAMSRgxC_E-tZRJ2qIP06U1zEVdn-MnvMTrn86s,2828
|
|
@@ -18,7 +18,7 @@ flood_adapt/config/impacts.py,sha256=O7vE7jB3GSXnkqAvv7TqJiJ_j1uJ3mck_KQ-ScsB3bo
|
|
|
18
18
|
flood_adapt/config/sfincs.py,sha256=y8C3PzFwwgMB_sb8rBzgteaQ8fCxep6DnZxuk0q__bc,4825
|
|
19
19
|
flood_adapt/config/site.py,sha256=VR90jCHWcxgoQJptNyXy7LseGjXUDRtdOjNGCddFVzI,4328
|
|
20
20
|
flood_adapt/database_builder/__init__.py,sha256=YsI5bGcAKYmsmb5W-spp91hzsKSTRtkXBLNRxLOWml4,474
|
|
21
|
-
flood_adapt/database_builder/database_builder.py,sha256=
|
|
21
|
+
flood_adapt/database_builder/database_builder.py,sha256=yJH1OIrPIJiT18Ab97fSZu-30uVT5u0oQYidx-gSGsc,99653
|
|
22
22
|
flood_adapt/database_builder/templates/default_units/imperial.toml,sha256=zIjPlxIa2kWLUjSYisd8UolXGo5iKdFoDDz_JkKBXTM,295
|
|
23
23
|
flood_adapt/database_builder/templates/default_units/metric.toml,sha256=tc0XMKs7xGL9noB9lAb0gyQfjYxzokgHa3NqpccxWl0,302
|
|
24
24
|
flood_adapt/database_builder/templates/green_infra_table/green_infra_lookup_table.csv,sha256=ooQzNGQwAMSAphy5W2ZyR5boQlcwvPv9ToJx1MlZhVE,466
|
|
@@ -90,6 +90,7 @@ flood_adapt/dbs_classes/interface/element.py,sha256=XN3SjfEiAa4oZ61XJNnHkfKQu5Da
|
|
|
90
90
|
flood_adapt/dbs_classes/interface/static.py,sha256=amChHlParELA4vFMUn_kL1fx6z7fCFW-hJXBo7PGtbY,1588
|
|
91
91
|
flood_adapt/misc/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
92
92
|
flood_adapt/misc/database_user.py,sha256=4PnXMNA0poQWWGc9FbmYAfJh5PhTMI3xzlCaIuP5wn4,546
|
|
93
|
+
flood_adapt/misc/debug_timer.py,sha256=TUXsJSX62P66AQrf7rqpmd95EZECJVWGT7pHpuxNG0I,743
|
|
93
94
|
flood_adapt/misc/exceptions.py,sha256=xLT1QnbjClftzYaxX5XdvVAkoI0q1CAsWJX901GB9JM,513
|
|
94
95
|
flood_adapt/misc/log.py,sha256=aK5uJch8p3a4Js4f79tO5AM9yZvNlGPjHYPsY5EuWbc,6898
|
|
95
96
|
flood_adapt/misc/path_builder.py,sha256=sLhvk3tq-QzI3fFjdzckpBYYZeuGyHBbuI0R98Tqud8,1396
|
|
@@ -132,9 +133,9 @@ flood_adapt/objects/strategies/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5
|
|
|
132
133
|
flood_adapt/objects/strategies/strategies.py,sha256=Jw-WJDCamL9p_7VEir3AdmYPMVAiCVRU9n_whG6WcgE,2981
|
|
133
134
|
flood_adapt/workflows/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
134
135
|
flood_adapt/workflows/benefit_runner.py,sha256=VtYt0sHFymNyErpzOtuN55cKJGVm5hT2a_Qzprg6T88,21786
|
|
135
|
-
flood_adapt/workflows/scenario_runner.py,sha256=
|
|
136
|
-
flood_adapt-1.0.
|
|
137
|
-
flood_adapt-1.0.
|
|
138
|
-
flood_adapt-1.0.
|
|
139
|
-
flood_adapt-1.0.
|
|
140
|
-
flood_adapt-1.0.
|
|
136
|
+
flood_adapt/workflows/scenario_runner.py,sha256=9_Y6GmMYhYoTRkBUIlju0eBy6DosGf4Zl2tgu1QEubI,4119
|
|
137
|
+
flood_adapt-1.0.4.dist-info/LICENSE,sha256=Ui5E03pQ0EVKxvKA54lTPA1xrtgA2HMGLQai95eOzoE,36321
|
|
138
|
+
flood_adapt-1.0.4.dist-info/METADATA,sha256=Eb02xNPlDolOPVGRx6g8RvqI8CTiH2YS2KCbUK3_qvg,53259
|
|
139
|
+
flood_adapt-1.0.4.dist-info/WHEEL,sha256=jB7zZ3N9hIM9adW7qlTAyycLYW9npaWKLRzaoVcLKcM,91
|
|
140
|
+
flood_adapt-1.0.4.dist-info/top_level.txt,sha256=JvzMi6cTcQPEThCfpgMEeVny3ghI1urSH0CCgVIqSzw,12
|
|
141
|
+
flood_adapt-1.0.4.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|