flood-adapt 0.3.8__py3-none-any.whl → 0.3.10__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 +26 -22
- flood_adapt/adapter/__init__.py +9 -9
- flood_adapt/adapter/fiat_adapter.py +1541 -1536
- flood_adapt/adapter/interface/hazard_adapter.py +70 -70
- flood_adapt/adapter/interface/impact_adapter.py +36 -36
- flood_adapt/adapter/interface/model_adapter.py +89 -89
- flood_adapt/adapter/interface/offshore.py +19 -19
- flood_adapt/adapter/sfincs_adapter.py +1848 -1846
- flood_adapt/adapter/sfincs_offshore.py +193 -193
- flood_adapt/config/config.py +248 -290
- flood_adapt/config/fiat.py +219 -219
- flood_adapt/config/gui.py +331 -331
- flood_adapt/config/sfincs.py +481 -336
- flood_adapt/config/site.py +129 -129
- flood_adapt/database_builder/database_builder.py +2210 -2210
- flood_adapt/database_builder/templates/default_units/imperial.toml +9 -9
- flood_adapt/database_builder/templates/default_units/metric.toml +9 -9
- flood_adapt/database_builder/templates/green_infra_table/green_infra_lookup_table.csv +10 -10
- flood_adapt/database_builder/templates/infographics/OSM/config_charts.toml +90 -90
- flood_adapt/database_builder/templates/infographics/OSM/config_people.toml +57 -57
- flood_adapt/database_builder/templates/infographics/OSM/config_risk_charts.toml +121 -121
- flood_adapt/database_builder/templates/infographics/OSM/config_roads.toml +65 -65
- flood_adapt/database_builder/templates/infographics/OSM/styles.css +45 -45
- flood_adapt/database_builder/templates/infographics/US_NSI/config_charts.toml +126 -126
- flood_adapt/database_builder/templates/infographics/US_NSI/config_people.toml +60 -60
- flood_adapt/database_builder/templates/infographics/US_NSI/config_risk_charts.toml +121 -121
- flood_adapt/database_builder/templates/infographics/US_NSI/config_roads.toml +65 -65
- flood_adapt/database_builder/templates/infographics/US_NSI/styles.css +45 -45
- flood_adapt/database_builder/templates/infometrics/OSM/metrics_additional_risk_configs.toml +4 -4
- flood_adapt/database_builder/templates/infometrics/OSM/with_SVI/infographic_metrics_config.toml +143 -143
- flood_adapt/database_builder/templates/infometrics/OSM/with_SVI/infographic_metrics_config_risk.toml +153 -153
- flood_adapt/database_builder/templates/infometrics/OSM/without_SVI/infographic_metrics_config.toml +127 -127
- flood_adapt/database_builder/templates/infometrics/OSM/without_SVI/infographic_metrics_config_risk.toml +57 -57
- flood_adapt/database_builder/templates/infometrics/US_NSI/metrics_additional_risk_configs.toml +4 -4
- flood_adapt/database_builder/templates/infometrics/US_NSI/with_SVI/infographic_metrics_config.toml +191 -191
- flood_adapt/database_builder/templates/infometrics/US_NSI/with_SVI/infographic_metrics_config_risk.toml +153 -153
- flood_adapt/database_builder/templates/infometrics/US_NSI/without_SVI/infographic_metrics_config.toml +178 -178
- flood_adapt/database_builder/templates/infometrics/US_NSI/without_SVI/infographic_metrics_config_risk.toml +57 -57
- flood_adapt/database_builder/templates/infometrics/mandatory_metrics_config.toml +9 -9
- flood_adapt/database_builder/templates/infometrics/mandatory_metrics_config_risk.toml +65 -65
- flood_adapt/database_builder/templates/output_layers/bin_colors.toml +5 -5
- flood_adapt/database_builder.py +16 -16
- flood_adapt/dbs_classes/__init__.py +21 -21
- flood_adapt/dbs_classes/database.py +495 -688
- flood_adapt/dbs_classes/dbs_benefit.py +77 -76
- flood_adapt/dbs_classes/dbs_event.py +61 -59
- flood_adapt/dbs_classes/dbs_measure.py +112 -111
- flood_adapt/dbs_classes/dbs_projection.py +34 -34
- flood_adapt/dbs_classes/dbs_scenario.py +137 -137
- flood_adapt/dbs_classes/dbs_static.py +274 -273
- flood_adapt/dbs_classes/dbs_strategy.py +130 -129
- flood_adapt/dbs_classes/dbs_template.py +279 -278
- flood_adapt/dbs_classes/interface/database.py +107 -139
- flood_adapt/dbs_classes/interface/element.py +121 -121
- flood_adapt/dbs_classes/interface/static.py +47 -47
- flood_adapt/flood_adapt.py +1207 -1178
- flood_adapt/misc/database_user.py +16 -16
- flood_adapt/misc/exceptions.py +22 -0
- flood_adapt/misc/log.py +183 -183
- flood_adapt/misc/path_builder.py +54 -54
- flood_adapt/misc/utils.py +185 -185
- flood_adapt/objects/__init__.py +82 -82
- flood_adapt/objects/benefits/benefits.py +61 -61
- flood_adapt/objects/events/event_factory.py +135 -135
- flood_adapt/objects/events/event_set.py +88 -84
- flood_adapt/objects/events/events.py +234 -234
- flood_adapt/objects/events/historical.py +58 -58
- flood_adapt/objects/events/hurricane.py +68 -67
- flood_adapt/objects/events/synthetic.py +46 -50
- flood_adapt/objects/forcing/__init__.py +92 -92
- flood_adapt/objects/forcing/csv.py +68 -68
- flood_adapt/objects/forcing/discharge.py +66 -66
- flood_adapt/objects/forcing/forcing.py +150 -150
- flood_adapt/objects/forcing/forcing_factory.py +182 -182
- flood_adapt/objects/forcing/meteo_handler.py +93 -93
- flood_adapt/objects/forcing/netcdf.py +40 -40
- flood_adapt/objects/forcing/plotting.py +453 -429
- flood_adapt/objects/forcing/rainfall.py +98 -98
- flood_adapt/objects/forcing/tide_gauge.py +191 -191
- flood_adapt/objects/forcing/time_frame.py +90 -90
- flood_adapt/objects/forcing/timeseries.py +564 -564
- flood_adapt/objects/forcing/unit_system.py +580 -580
- flood_adapt/objects/forcing/waterlevels.py +108 -108
- flood_adapt/objects/forcing/wind.py +124 -124
- flood_adapt/objects/measures/measure_factory.py +92 -92
- flood_adapt/objects/measures/measures.py +529 -529
- flood_adapt/objects/object_model.py +74 -68
- flood_adapt/objects/projections/projections.py +103 -89
- flood_adapt/objects/scenarios/scenarios.py +22 -22
- flood_adapt/objects/strategies/strategies.py +89 -89
- flood_adapt/workflows/benefit_runner.py +579 -544
- flood_adapt/workflows/floodmap.py +85 -85
- flood_adapt/workflows/impacts_integrator.py +85 -82
- flood_adapt/workflows/scenario_runner.py +70 -70
- {flood_adapt-0.3.8.dist-info → flood_adapt-0.3.10.dist-info}/LICENSE +674 -674
- {flood_adapt-0.3.8.dist-info → flood_adapt-0.3.10.dist-info}/METADATA +866 -860
- flood_adapt-0.3.10.dist-info/RECORD +140 -0
- flood_adapt-0.3.8.dist-info/RECORD +0 -139
- {flood_adapt-0.3.8.dist-info → flood_adapt-0.3.10.dist-info}/WHEEL +0 -0
- {flood_adapt-0.3.8.dist-info → flood_adapt-0.3.10.dist-info}/top_level.txt +0 -0
|
@@ -1,70 +1,70 @@
|
|
|
1
|
-
from abc import abstractmethod
|
|
2
|
-
from typing import Any
|
|
3
|
-
|
|
4
|
-
import geopandas as gpd
|
|
5
|
-
|
|
6
|
-
from flood_adapt.adapter.interface.model_adapter import IAdapter
|
|
7
|
-
from flood_adapt.objects.forcing.forcing import IForcing
|
|
8
|
-
from flood_adapt.objects.forcing.time_frame import TimeFrame
|
|
9
|
-
from flood_adapt.objects.measures.measures import Measure
|
|
10
|
-
from flood_adapt.objects.projections.projections import Projection
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
class IHazardAdapter(IAdapter):
|
|
14
|
-
@abstractmethod
|
|
15
|
-
def set_timing(self, time: TimeFrame):
|
|
16
|
-
"""
|
|
17
|
-
Implement this to handle the timing of the event from the Event.
|
|
18
|
-
|
|
19
|
-
Access the events timing by `event.timing`, which contains the start and end time of the event, and the time step.
|
|
20
|
-
"""
|
|
21
|
-
pass
|
|
22
|
-
|
|
23
|
-
@abstractmethod
|
|
24
|
-
def add_forcing(self, forcing: IForcing):
|
|
25
|
-
"""
|
|
26
|
-
Implement this to handle each supported forcing type for this Hazard model.
|
|
27
|
-
|
|
28
|
-
A forcing is time series data, i.e. water levels, wind, rain, discharge, with optional time and space dimensions.
|
|
29
|
-
So this could be a single time series, or a collection of time series, or a time series associated with a spatial grid/gridpoint)
|
|
30
|
-
|
|
31
|
-
Forcings contain all information needed to implement the forcing in the hazard model. (geospatial files, parameters, etc.)
|
|
32
|
-
"""
|
|
33
|
-
pass
|
|
34
|
-
|
|
35
|
-
@abstractmethod
|
|
36
|
-
def add_measure(self, measure: Measure):
|
|
37
|
-
"""
|
|
38
|
-
Implement this to handle each supported measure type for this Hazard model.
|
|
39
|
-
|
|
40
|
-
A hazardmeasure is a measure that affects the hazard model, i.e. a measure that affects the water levels, wind, rain, discharge.
|
|
41
|
-
For example a measure could be a dike, a land use change, a change in the river channel, etc.
|
|
42
|
-
|
|
43
|
-
HazardMeasures contain all information needed to implement the measure in the hazard model. (geospatial files, parameters, etc.)
|
|
44
|
-
|
|
45
|
-
"""
|
|
46
|
-
pass
|
|
47
|
-
|
|
48
|
-
@abstractmethod
|
|
49
|
-
def add_projection(self, projection: Projection):
|
|
50
|
-
"""
|
|
51
|
-
Implement this to handle each supported projection type for this Hazard model.
|
|
52
|
-
|
|
53
|
-
A projection is a projection of the future, i.e. sea level rise, subsidence, rainfall multiplier, storm frequency increase, etc.
|
|
54
|
-
PhysicalProjections contains all information needed to implement the projection in the hazard model. (parameters, etc.)
|
|
55
|
-
"""
|
|
56
|
-
pass
|
|
57
|
-
|
|
58
|
-
@abstractmethod
|
|
59
|
-
def get_model_boundary(self) -> gpd.GeoDataFrame:
|
|
60
|
-
"""
|
|
61
|
-
Implement this to return the model boundary of the hazard model.
|
|
62
|
-
|
|
63
|
-
The model boundary is a geospatial file that defines the boundary of the hazard model.
|
|
64
|
-
"""
|
|
65
|
-
pass
|
|
66
|
-
|
|
67
|
-
@abstractmethod
|
|
68
|
-
def get_model_grid(self) -> Any:
|
|
69
|
-
"""Implement this to return the model grid of the hazard model."""
|
|
70
|
-
pass
|
|
1
|
+
from abc import abstractmethod
|
|
2
|
+
from typing import Any
|
|
3
|
+
|
|
4
|
+
import geopandas as gpd
|
|
5
|
+
|
|
6
|
+
from flood_adapt.adapter.interface.model_adapter import IAdapter
|
|
7
|
+
from flood_adapt.objects.forcing.forcing import IForcing
|
|
8
|
+
from flood_adapt.objects.forcing.time_frame import TimeFrame
|
|
9
|
+
from flood_adapt.objects.measures.measures import Measure
|
|
10
|
+
from flood_adapt.objects.projections.projections import Projection
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class IHazardAdapter(IAdapter):
|
|
14
|
+
@abstractmethod
|
|
15
|
+
def set_timing(self, time: TimeFrame):
|
|
16
|
+
"""
|
|
17
|
+
Implement this to handle the timing of the event from the Event.
|
|
18
|
+
|
|
19
|
+
Access the events timing by `event.timing`, which contains the start and end time of the event, and the time step.
|
|
20
|
+
"""
|
|
21
|
+
pass
|
|
22
|
+
|
|
23
|
+
@abstractmethod
|
|
24
|
+
def add_forcing(self, forcing: IForcing):
|
|
25
|
+
"""
|
|
26
|
+
Implement this to handle each supported forcing type for this Hazard model.
|
|
27
|
+
|
|
28
|
+
A forcing is time series data, i.e. water levels, wind, rain, discharge, with optional time and space dimensions.
|
|
29
|
+
So this could be a single time series, or a collection of time series, or a time series associated with a spatial grid/gridpoint)
|
|
30
|
+
|
|
31
|
+
Forcings contain all information needed to implement the forcing in the hazard model. (geospatial files, parameters, etc.)
|
|
32
|
+
"""
|
|
33
|
+
pass
|
|
34
|
+
|
|
35
|
+
@abstractmethod
|
|
36
|
+
def add_measure(self, measure: Measure):
|
|
37
|
+
"""
|
|
38
|
+
Implement this to handle each supported measure type for this Hazard model.
|
|
39
|
+
|
|
40
|
+
A hazardmeasure is a measure that affects the hazard model, i.e. a measure that affects the water levels, wind, rain, discharge.
|
|
41
|
+
For example a measure could be a dike, a land use change, a change in the river channel, etc.
|
|
42
|
+
|
|
43
|
+
HazardMeasures contain all information needed to implement the measure in the hazard model. (geospatial files, parameters, etc.)
|
|
44
|
+
|
|
45
|
+
"""
|
|
46
|
+
pass
|
|
47
|
+
|
|
48
|
+
@abstractmethod
|
|
49
|
+
def add_projection(self, projection: Projection):
|
|
50
|
+
"""
|
|
51
|
+
Implement this to handle each supported projection type for this Hazard model.
|
|
52
|
+
|
|
53
|
+
A projection is a projection of the future, i.e. sea level rise, subsidence, rainfall multiplier, storm frequency increase, etc.
|
|
54
|
+
PhysicalProjections contains all information needed to implement the projection in the hazard model. (parameters, etc.)
|
|
55
|
+
"""
|
|
56
|
+
pass
|
|
57
|
+
|
|
58
|
+
@abstractmethod
|
|
59
|
+
def get_model_boundary(self) -> gpd.GeoDataFrame:
|
|
60
|
+
"""
|
|
61
|
+
Implement this to return the model boundary of the hazard model.
|
|
62
|
+
|
|
63
|
+
The model boundary is a geospatial file that defines the boundary of the hazard model.
|
|
64
|
+
"""
|
|
65
|
+
pass
|
|
66
|
+
|
|
67
|
+
@abstractmethod
|
|
68
|
+
def get_model_grid(self) -> Any:
|
|
69
|
+
"""Implement this to return the model grid of the hazard model."""
|
|
70
|
+
pass
|
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
from abc import abstractmethod
|
|
2
|
-
|
|
3
|
-
from flood_adapt.adapter.interface.model_adapter import IAdapter
|
|
4
|
-
from flood_adapt.objects.measures.measures import Measure
|
|
5
|
-
from flood_adapt.objects.projections.projections import Projection
|
|
6
|
-
from flood_adapt.workflows.floodmap import FloodMap
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
class IImpactAdapter(IAdapter):
|
|
10
|
-
@abstractmethod
|
|
11
|
-
def add_measure(self, measure: Measure):
|
|
12
|
-
"""
|
|
13
|
-
Implement this to handle each supported measure type for this Impact model.
|
|
14
|
-
|
|
15
|
-
An impact measure is a measure that affects the impact model, i.e. a measure that affects the elevation of buildings.
|
|
16
|
-
For example a measure could be buyouts, floodproofing etc.
|
|
17
|
-
|
|
18
|
-
ImpactMeasures contain all information needed to implement the measure in the impact model. (geospatial files, parameters, etc.)
|
|
19
|
-
|
|
20
|
-
"""
|
|
21
|
-
pass
|
|
22
|
-
|
|
23
|
-
@abstractmethod
|
|
24
|
-
def add_projection(self, projection: Projection):
|
|
25
|
-
"""
|
|
26
|
-
Implement this to handle each supported projection type for this Impact model.
|
|
27
|
-
|
|
28
|
-
A projection is a projection of the future, i.e. economic growth, etc.
|
|
29
|
-
SocioEconomicChange contains all information needed to implement the projection in the impact model. (parameters, etc.)
|
|
30
|
-
"""
|
|
31
|
-
pass
|
|
32
|
-
|
|
33
|
-
@abstractmethod
|
|
34
|
-
def set_hazard(self, floodmap: FloodMap):
|
|
35
|
-
"""Implement this to handle setting up of a hazard flood map."""
|
|
36
|
-
pass
|
|
1
|
+
from abc import abstractmethod
|
|
2
|
+
|
|
3
|
+
from flood_adapt.adapter.interface.model_adapter import IAdapter
|
|
4
|
+
from flood_adapt.objects.measures.measures import Measure
|
|
5
|
+
from flood_adapt.objects.projections.projections import Projection
|
|
6
|
+
from flood_adapt.workflows.floodmap import FloodMap
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class IImpactAdapter(IAdapter):
|
|
10
|
+
@abstractmethod
|
|
11
|
+
def add_measure(self, measure: Measure):
|
|
12
|
+
"""
|
|
13
|
+
Implement this to handle each supported measure type for this Impact model.
|
|
14
|
+
|
|
15
|
+
An impact measure is a measure that affects the impact model, i.e. a measure that affects the elevation of buildings.
|
|
16
|
+
For example a measure could be buyouts, floodproofing etc.
|
|
17
|
+
|
|
18
|
+
ImpactMeasures contain all information needed to implement the measure in the impact model. (geospatial files, parameters, etc.)
|
|
19
|
+
|
|
20
|
+
"""
|
|
21
|
+
pass
|
|
22
|
+
|
|
23
|
+
@abstractmethod
|
|
24
|
+
def add_projection(self, projection: Projection):
|
|
25
|
+
"""
|
|
26
|
+
Implement this to handle each supported projection type for this Impact model.
|
|
27
|
+
|
|
28
|
+
A projection is a projection of the future, i.e. economic growth, etc.
|
|
29
|
+
SocioEconomicChange contains all information needed to implement the projection in the impact model. (parameters, etc.)
|
|
30
|
+
"""
|
|
31
|
+
pass
|
|
32
|
+
|
|
33
|
+
@abstractmethod
|
|
34
|
+
def set_hazard(self, floodmap: FloodMap):
|
|
35
|
+
"""Implement this to handle setting up of a hazard flood map."""
|
|
36
|
+
pass
|
|
@@ -1,89 +1,89 @@
|
|
|
1
|
-
from abc import abstractmethod
|
|
2
|
-
from pathlib import Path
|
|
3
|
-
|
|
4
|
-
from flood_adapt.misc.database_user import DatabaseUser
|
|
5
|
-
from flood_adapt.objects.scenarios.scenarios import Scenario
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
class IAdapter(DatabaseUser):
|
|
9
|
-
"""Adapter interface for all models run in FloodAdapt."""
|
|
10
|
-
|
|
11
|
-
@abstractmethod
|
|
12
|
-
def has_run(self, scenario: Scenario) -> bool:
|
|
13
|
-
"""Return True if the model has been run."""
|
|
14
|
-
pass
|
|
15
|
-
|
|
16
|
-
@abstractmethod
|
|
17
|
-
def __enter__(self) -> "IAdapter":
|
|
18
|
-
"""Use the adapter as a context manager to handle opening and closing of the model and attached resources like logfiles.
|
|
19
|
-
|
|
20
|
-
Returns
|
|
21
|
-
-------
|
|
22
|
-
self: the adapter object
|
|
23
|
-
|
|
24
|
-
Usage
|
|
25
|
-
-----
|
|
26
|
-
>>> with Adapter(...) as model:
|
|
27
|
-
>>> ...
|
|
28
|
-
>>> model.get_result(...)
|
|
29
|
-
>>> model.run(...)
|
|
30
|
-
|
|
31
|
-
Entering the with block will call adapter.__enter__() and
|
|
32
|
-
Exiting the with block (via regular execution or an error) will call adapter.__exit__()
|
|
33
|
-
"""
|
|
34
|
-
pass
|
|
35
|
-
|
|
36
|
-
@abstractmethod
|
|
37
|
-
def __exit__(self, exc_type, exc_value, traceback) -> bool:
|
|
38
|
-
"""Close the model and release any resources.
|
|
39
|
-
|
|
40
|
-
Usage
|
|
41
|
-
-----
|
|
42
|
-
>>> with Adapter as model:
|
|
43
|
-
>>> ...
|
|
44
|
-
>>> model.run()
|
|
45
|
-
|
|
46
|
-
Entering the `with` block will call adapter.__enter__()
|
|
47
|
-
Exiting the `with` block (via regular execution or an error) will call adapter.__exit__()
|
|
48
|
-
|
|
49
|
-
Returns
|
|
50
|
-
-------
|
|
51
|
-
False to propagate/reraise any exceptions that occurred in the with block
|
|
52
|
-
True to suppress any exceptions that occurred in the with block
|
|
53
|
-
"""
|
|
54
|
-
pass
|
|
55
|
-
|
|
56
|
-
@abstractmethod
|
|
57
|
-
def read(self, path: Path):
|
|
58
|
-
"""Read the model configuration from a path or other source."""
|
|
59
|
-
pass
|
|
60
|
-
|
|
61
|
-
@abstractmethod
|
|
62
|
-
def write(self, path_out: Path, overwrite: bool = True):
|
|
63
|
-
"""Write the current model configuration to a path or other destination."""
|
|
64
|
-
pass
|
|
65
|
-
|
|
66
|
-
@abstractmethod
|
|
67
|
-
def run(self, scenario: Scenario):
|
|
68
|
-
"""Perform the whole workflow (preprocess, execute and postprocess) of running the model."""
|
|
69
|
-
pass
|
|
70
|
-
|
|
71
|
-
@abstractmethod
|
|
72
|
-
def preprocess(self, scenario: Scenario):
|
|
73
|
-
"""Prepare the model for execution."""
|
|
74
|
-
pass
|
|
75
|
-
|
|
76
|
-
@abstractmethod
|
|
77
|
-
def execute(self, path: Path, strict: bool = True) -> bool:
|
|
78
|
-
"""Run the model kernel at the specified path.
|
|
79
|
-
|
|
80
|
-
Returns True if the model ran successfully, False otherwise.
|
|
81
|
-
|
|
82
|
-
If strict is True, raise an exception if the model fails to run.
|
|
83
|
-
"""
|
|
84
|
-
pass
|
|
85
|
-
|
|
86
|
-
@abstractmethod
|
|
87
|
-
def postprocess(self, scenario: Scenario):
|
|
88
|
-
"""Process the model output."""
|
|
89
|
-
pass
|
|
1
|
+
from abc import abstractmethod
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
|
|
4
|
+
from flood_adapt.misc.database_user import DatabaseUser
|
|
5
|
+
from flood_adapt.objects.scenarios.scenarios import Scenario
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class IAdapter(DatabaseUser):
|
|
9
|
+
"""Adapter interface for all models run in FloodAdapt."""
|
|
10
|
+
|
|
11
|
+
@abstractmethod
|
|
12
|
+
def has_run(self, scenario: Scenario) -> bool:
|
|
13
|
+
"""Return True if the model has been run."""
|
|
14
|
+
pass
|
|
15
|
+
|
|
16
|
+
@abstractmethod
|
|
17
|
+
def __enter__(self) -> "IAdapter":
|
|
18
|
+
"""Use the adapter as a context manager to handle opening and closing of the model and attached resources like logfiles.
|
|
19
|
+
|
|
20
|
+
Returns
|
|
21
|
+
-------
|
|
22
|
+
self: the adapter object
|
|
23
|
+
|
|
24
|
+
Usage
|
|
25
|
+
-----
|
|
26
|
+
>>> with Adapter(...) as model:
|
|
27
|
+
>>> ...
|
|
28
|
+
>>> model.get_result(...)
|
|
29
|
+
>>> model.run(...)
|
|
30
|
+
|
|
31
|
+
Entering the with block will call adapter.__enter__() and
|
|
32
|
+
Exiting the with block (via regular execution or an error) will call adapter.__exit__()
|
|
33
|
+
"""
|
|
34
|
+
pass
|
|
35
|
+
|
|
36
|
+
@abstractmethod
|
|
37
|
+
def __exit__(self, exc_type, exc_value, traceback) -> bool:
|
|
38
|
+
"""Close the model and release any resources.
|
|
39
|
+
|
|
40
|
+
Usage
|
|
41
|
+
-----
|
|
42
|
+
>>> with Adapter as model:
|
|
43
|
+
>>> ...
|
|
44
|
+
>>> model.run()
|
|
45
|
+
|
|
46
|
+
Entering the `with` block will call adapter.__enter__()
|
|
47
|
+
Exiting the `with` block (via regular execution or an error) will call adapter.__exit__()
|
|
48
|
+
|
|
49
|
+
Returns
|
|
50
|
+
-------
|
|
51
|
+
False to propagate/reraise any exceptions that occurred in the with block
|
|
52
|
+
True to suppress any exceptions that occurred in the with block
|
|
53
|
+
"""
|
|
54
|
+
pass
|
|
55
|
+
|
|
56
|
+
@abstractmethod
|
|
57
|
+
def read(self, path: Path):
|
|
58
|
+
"""Read the model configuration from a path or other source."""
|
|
59
|
+
pass
|
|
60
|
+
|
|
61
|
+
@abstractmethod
|
|
62
|
+
def write(self, path_out: Path, overwrite: bool = True):
|
|
63
|
+
"""Write the current model configuration to a path or other destination."""
|
|
64
|
+
pass
|
|
65
|
+
|
|
66
|
+
@abstractmethod
|
|
67
|
+
def run(self, scenario: Scenario):
|
|
68
|
+
"""Perform the whole workflow (preprocess, execute and postprocess) of running the model."""
|
|
69
|
+
pass
|
|
70
|
+
|
|
71
|
+
@abstractmethod
|
|
72
|
+
def preprocess(self, scenario: Scenario):
|
|
73
|
+
"""Prepare the model for execution."""
|
|
74
|
+
pass
|
|
75
|
+
|
|
76
|
+
@abstractmethod
|
|
77
|
+
def execute(self, path: Path, strict: bool = True) -> bool:
|
|
78
|
+
"""Run the model kernel at the specified path.
|
|
79
|
+
|
|
80
|
+
Returns True if the model ran successfully, False otherwise.
|
|
81
|
+
|
|
82
|
+
If strict is True, raise an exception if the model fails to run.
|
|
83
|
+
"""
|
|
84
|
+
pass
|
|
85
|
+
|
|
86
|
+
@abstractmethod
|
|
87
|
+
def postprocess(self, scenario: Scenario):
|
|
88
|
+
"""Process the model output."""
|
|
89
|
+
pass
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
from abc import ABC, abstractmethod
|
|
2
|
-
from pathlib import Path
|
|
3
|
-
|
|
4
|
-
import pandas as pd
|
|
5
|
-
|
|
6
|
-
from flood_adapt.objects.scenarios.scenarios import Scenario
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
class IOffshoreSfincsHandler(ABC):
|
|
10
|
-
template_path: Path
|
|
11
|
-
|
|
12
|
-
@abstractmethod
|
|
13
|
-
def get_resulting_waterlevels(self, scenario: Scenario) -> pd.DataFrame: ...
|
|
14
|
-
|
|
15
|
-
@staticmethod
|
|
16
|
-
def requires_offshore_run(scenario: Scenario) -> bool: ...
|
|
17
|
-
|
|
18
|
-
@abstractmethod
|
|
19
|
-
def run_offshore(self, scenario: Scenario): ...
|
|
1
|
+
from abc import ABC, abstractmethod
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
|
|
4
|
+
import pandas as pd
|
|
5
|
+
|
|
6
|
+
from flood_adapt.objects.scenarios.scenarios import Scenario
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class IOffshoreSfincsHandler(ABC):
|
|
10
|
+
template_path: Path
|
|
11
|
+
|
|
12
|
+
@abstractmethod
|
|
13
|
+
def get_resulting_waterlevels(self, scenario: Scenario) -> pd.DataFrame: ...
|
|
14
|
+
|
|
15
|
+
@staticmethod
|
|
16
|
+
def requires_offshore_run(scenario: Scenario) -> bool: ...
|
|
17
|
+
|
|
18
|
+
@abstractmethod
|
|
19
|
+
def run_offshore(self, scenario: Scenario): ...
|