flood-adapt 0.3.9__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 -1541
- 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 -1848
- flood_adapt/adapter/sfincs_offshore.py +193 -193
- flood_adapt/config/config.py +248 -248
- 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 -684
- 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 -103
- flood_adapt/objects/scenarios/scenarios.py +22 -22
- flood_adapt/objects/strategies/strategies.py +89 -89
- flood_adapt/workflows/benefit_runner.py +579 -554
- flood_adapt/workflows/floodmap.py +85 -85
- flood_adapt/workflows/impacts_integrator.py +85 -85
- flood_adapt/workflows/scenario_runner.py +70 -70
- {flood_adapt-0.3.9.dist-info → flood_adapt-0.3.10.dist-info}/LICENSE +674 -674
- {flood_adapt-0.3.9.dist-info → flood_adapt-0.3.10.dist-info}/METADATA +866 -865
- flood_adapt-0.3.10.dist-info/RECORD +140 -0
- flood_adapt-0.3.9.dist-info/RECORD +0 -139
- {flood_adapt-0.3.9.dist-info → flood_adapt-0.3.10.dist-info}/WHEEL +0 -0
- {flood_adapt-0.3.9.dist-info → flood_adapt-0.3.10.dist-info}/top_level.txt +0 -0
flood_adapt/config/site.py
CHANGED
|
@@ -1,129 +1,129 @@
|
|
|
1
|
-
import os
|
|
2
|
-
from pathlib import Path
|
|
3
|
-
from typing import Literal, Union
|
|
4
|
-
|
|
5
|
-
import tomli
|
|
6
|
-
import tomli_w
|
|
7
|
-
from pydantic import BaseModel, Field
|
|
8
|
-
|
|
9
|
-
from flood_adapt.config.fiat import FiatModel
|
|
10
|
-
from flood_adapt.config.gui import GuiModel
|
|
11
|
-
from flood_adapt.config.sfincs import SfincsModel
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
class StandardObjectModel(BaseModel):
|
|
15
|
-
"""The accepted input for the variable standard_object in Site."""
|
|
16
|
-
|
|
17
|
-
events: list[str] = Field(default_factory=list)
|
|
18
|
-
projections: list[str] = Field(default_factory=list)
|
|
19
|
-
strategies: list[str] = Field(default_factory=list)
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
class Site(BaseModel):
|
|
23
|
-
"""The expected variables and data types of attributes of the Site class.
|
|
24
|
-
|
|
25
|
-
Attributes
|
|
26
|
-
----------
|
|
27
|
-
name : str
|
|
28
|
-
Name of the site.
|
|
29
|
-
description : str
|
|
30
|
-
Description of the site. Defaults to "".
|
|
31
|
-
lat : float
|
|
32
|
-
Latitude of the site.
|
|
33
|
-
lon : float
|
|
34
|
-
Longitude of the site.
|
|
35
|
-
standard_objects : StandardObjectModel, default=StandardObjectModel()
|
|
36
|
-
Standard objects of the site.
|
|
37
|
-
gui : GuiModel
|
|
38
|
-
GUI model of the site.
|
|
39
|
-
sfincs : SfincsModel
|
|
40
|
-
SFincs model of the site.
|
|
41
|
-
fiat : FiatModel
|
|
42
|
-
Fiat model of the site.
|
|
43
|
-
"""
|
|
44
|
-
|
|
45
|
-
name: str
|
|
46
|
-
description: str = ""
|
|
47
|
-
lat: float
|
|
48
|
-
lon: float
|
|
49
|
-
standard_objects: StandardObjectModel = StandardObjectModel()
|
|
50
|
-
|
|
51
|
-
gui: GuiModel
|
|
52
|
-
sfincs: SfincsModel
|
|
53
|
-
fiat: FiatModel
|
|
54
|
-
|
|
55
|
-
def save(
|
|
56
|
-
self,
|
|
57
|
-
filepath: Union[str, os.PathLike],
|
|
58
|
-
sfincs: str = "sfincs.toml",
|
|
59
|
-
fiat: str = "fiat.toml",
|
|
60
|
-
gui: str = "gui.toml",
|
|
61
|
-
) -> None:
|
|
62
|
-
"""Write toml file from model object."""
|
|
63
|
-
parent_folder = Path(filepath).parent
|
|
64
|
-
config_dict = {
|
|
65
|
-
"name": self.name,
|
|
66
|
-
"description": self.description,
|
|
67
|
-
"lat": self.lat,
|
|
68
|
-
"lon": self.lon,
|
|
69
|
-
"standard_objects": {
|
|
70
|
-
"events": self.standard_objects.events,
|
|
71
|
-
"projections": self.standard_objects.projections,
|
|
72
|
-
"strategies": self.standard_objects.strategies,
|
|
73
|
-
},
|
|
74
|
-
"components": {},
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
if self.sfincs is not None:
|
|
78
|
-
config_dict["components"]["sfincs"] = sfincs
|
|
79
|
-
with open(parent_folder / sfincs, "wb") as f:
|
|
80
|
-
tomli_w.dump(self.sfincs.model_dump(exclude_none=True), f)
|
|
81
|
-
|
|
82
|
-
if self.fiat is not None:
|
|
83
|
-
config_dict["components"]["fiat"] = fiat
|
|
84
|
-
with open(parent_folder / fiat, "wb") as f:
|
|
85
|
-
tomli_w.dump(self.fiat.model_dump(exclude_none=True), f)
|
|
86
|
-
|
|
87
|
-
if self.gui is not None:
|
|
88
|
-
config_dict["components"]["gui"] = gui
|
|
89
|
-
with open(parent_folder / gui, "wb") as f:
|
|
90
|
-
tomli_w.dump(self.gui.model_dump(exclude_none=True), f)
|
|
91
|
-
|
|
92
|
-
with open(filepath, "wb") as f:
|
|
93
|
-
tomli_w.dump(config_dict, f)
|
|
94
|
-
|
|
95
|
-
@staticmethod
|
|
96
|
-
def load_file(filepath: Union[str, os.PathLike]) -> "Site":
|
|
97
|
-
"""Create Site from toml file."""
|
|
98
|
-
return SiteBuilder.load_file(Path(filepath))
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
class SiteBuilder(BaseModel):
|
|
102
|
-
"""Pydantic model that reads the site configuration file and builds the site model.
|
|
103
|
-
|
|
104
|
-
Note that the components are not required, as the site may not have all of them.
|
|
105
|
-
Second, note that the components are assumed to be the file names of the component configs, located in the same directory as the site configuration file.
|
|
106
|
-
"""
|
|
107
|
-
|
|
108
|
-
name: str
|
|
109
|
-
description: str = ""
|
|
110
|
-
lat: float
|
|
111
|
-
lon: float
|
|
112
|
-
components: dict[Literal["sfincs", "fiat", "gui"], str]
|
|
113
|
-
|
|
114
|
-
@staticmethod
|
|
115
|
-
def load_file(file_path: Path) -> "Site":
|
|
116
|
-
with open(file_path, "rb") as f:
|
|
117
|
-
model_dict = tomli.load(f)
|
|
118
|
-
|
|
119
|
-
toml_dir = file_path.parent
|
|
120
|
-
if (sfincs_config := model_dict["components"].get("sfincs")) is not None:
|
|
121
|
-
model_dict["sfincs"] = SfincsModel.read_toml(toml_dir / sfincs_config)
|
|
122
|
-
|
|
123
|
-
if (gui_config := model_dict["components"].get("gui")) is not None:
|
|
124
|
-
model_dict["gui"] = GuiModel.read_toml(toml_dir / gui_config)
|
|
125
|
-
|
|
126
|
-
if (fiat_config := model_dict["components"].get("fiat")) is not None:
|
|
127
|
-
model_dict["fiat"] = FiatModel.read_toml(toml_dir / fiat_config)
|
|
128
|
-
|
|
129
|
-
return Site(**model_dict)
|
|
1
|
+
import os
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
from typing import Literal, Union
|
|
4
|
+
|
|
5
|
+
import tomli
|
|
6
|
+
import tomli_w
|
|
7
|
+
from pydantic import BaseModel, Field
|
|
8
|
+
|
|
9
|
+
from flood_adapt.config.fiat import FiatModel
|
|
10
|
+
from flood_adapt.config.gui import GuiModel
|
|
11
|
+
from flood_adapt.config.sfincs import SfincsModel
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class StandardObjectModel(BaseModel):
|
|
15
|
+
"""The accepted input for the variable standard_object in Site."""
|
|
16
|
+
|
|
17
|
+
events: list[str] = Field(default_factory=list)
|
|
18
|
+
projections: list[str] = Field(default_factory=list)
|
|
19
|
+
strategies: list[str] = Field(default_factory=list)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class Site(BaseModel):
|
|
23
|
+
"""The expected variables and data types of attributes of the Site class.
|
|
24
|
+
|
|
25
|
+
Attributes
|
|
26
|
+
----------
|
|
27
|
+
name : str
|
|
28
|
+
Name of the site.
|
|
29
|
+
description : str
|
|
30
|
+
Description of the site. Defaults to "".
|
|
31
|
+
lat : float
|
|
32
|
+
Latitude of the site.
|
|
33
|
+
lon : float
|
|
34
|
+
Longitude of the site.
|
|
35
|
+
standard_objects : StandardObjectModel, default=StandardObjectModel()
|
|
36
|
+
Standard objects of the site.
|
|
37
|
+
gui : GuiModel
|
|
38
|
+
GUI model of the site.
|
|
39
|
+
sfincs : SfincsModel
|
|
40
|
+
SFincs model of the site.
|
|
41
|
+
fiat : FiatModel
|
|
42
|
+
Fiat model of the site.
|
|
43
|
+
"""
|
|
44
|
+
|
|
45
|
+
name: str
|
|
46
|
+
description: str = ""
|
|
47
|
+
lat: float
|
|
48
|
+
lon: float
|
|
49
|
+
standard_objects: StandardObjectModel = StandardObjectModel()
|
|
50
|
+
|
|
51
|
+
gui: GuiModel
|
|
52
|
+
sfincs: SfincsModel
|
|
53
|
+
fiat: FiatModel
|
|
54
|
+
|
|
55
|
+
def save(
|
|
56
|
+
self,
|
|
57
|
+
filepath: Union[str, os.PathLike],
|
|
58
|
+
sfincs: str = "sfincs.toml",
|
|
59
|
+
fiat: str = "fiat.toml",
|
|
60
|
+
gui: str = "gui.toml",
|
|
61
|
+
) -> None:
|
|
62
|
+
"""Write toml file from model object."""
|
|
63
|
+
parent_folder = Path(filepath).parent
|
|
64
|
+
config_dict = {
|
|
65
|
+
"name": self.name,
|
|
66
|
+
"description": self.description,
|
|
67
|
+
"lat": self.lat,
|
|
68
|
+
"lon": self.lon,
|
|
69
|
+
"standard_objects": {
|
|
70
|
+
"events": self.standard_objects.events,
|
|
71
|
+
"projections": self.standard_objects.projections,
|
|
72
|
+
"strategies": self.standard_objects.strategies,
|
|
73
|
+
},
|
|
74
|
+
"components": {},
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if self.sfincs is not None:
|
|
78
|
+
config_dict["components"]["sfincs"] = sfincs
|
|
79
|
+
with open(parent_folder / sfincs, "wb") as f:
|
|
80
|
+
tomli_w.dump(self.sfincs.model_dump(exclude_none=True), f)
|
|
81
|
+
|
|
82
|
+
if self.fiat is not None:
|
|
83
|
+
config_dict["components"]["fiat"] = fiat
|
|
84
|
+
with open(parent_folder / fiat, "wb") as f:
|
|
85
|
+
tomli_w.dump(self.fiat.model_dump(exclude_none=True), f)
|
|
86
|
+
|
|
87
|
+
if self.gui is not None:
|
|
88
|
+
config_dict["components"]["gui"] = gui
|
|
89
|
+
with open(parent_folder / gui, "wb") as f:
|
|
90
|
+
tomli_w.dump(self.gui.model_dump(exclude_none=True), f)
|
|
91
|
+
|
|
92
|
+
with open(filepath, "wb") as f:
|
|
93
|
+
tomli_w.dump(config_dict, f)
|
|
94
|
+
|
|
95
|
+
@staticmethod
|
|
96
|
+
def load_file(filepath: Union[str, os.PathLike]) -> "Site":
|
|
97
|
+
"""Create Site from toml file."""
|
|
98
|
+
return SiteBuilder.load_file(Path(filepath))
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
class SiteBuilder(BaseModel):
|
|
102
|
+
"""Pydantic model that reads the site configuration file and builds the site model.
|
|
103
|
+
|
|
104
|
+
Note that the components are not required, as the site may not have all of them.
|
|
105
|
+
Second, note that the components are assumed to be the file names of the component configs, located in the same directory as the site configuration file.
|
|
106
|
+
"""
|
|
107
|
+
|
|
108
|
+
name: str
|
|
109
|
+
description: str = ""
|
|
110
|
+
lat: float
|
|
111
|
+
lon: float
|
|
112
|
+
components: dict[Literal["sfincs", "fiat", "gui"], str]
|
|
113
|
+
|
|
114
|
+
@staticmethod
|
|
115
|
+
def load_file(file_path: Path) -> "Site":
|
|
116
|
+
with open(file_path, "rb") as f:
|
|
117
|
+
model_dict = tomli.load(f)
|
|
118
|
+
|
|
119
|
+
toml_dir = file_path.parent
|
|
120
|
+
if (sfincs_config := model_dict["components"].get("sfincs")) is not None:
|
|
121
|
+
model_dict["sfincs"] = SfincsModel.read_toml(toml_dir / sfincs_config)
|
|
122
|
+
|
|
123
|
+
if (gui_config := model_dict["components"].get("gui")) is not None:
|
|
124
|
+
model_dict["gui"] = GuiModel.read_toml(toml_dir / gui_config)
|
|
125
|
+
|
|
126
|
+
if (fiat_config := model_dict["components"].get("fiat")) is not None:
|
|
127
|
+
model_dict["fiat"] = FiatModel.read_toml(toml_dir / fiat_config)
|
|
128
|
+
|
|
129
|
+
return Site(**model_dict)
|