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
|
@@ -1,273 +1,274 @@
|
|
|
1
|
-
from pathlib import Path
|
|
2
|
-
from typing import Any, Callable, Tuple, Union
|
|
3
|
-
|
|
4
|
-
import geopandas as gpd
|
|
5
|
-
import pandas as pd
|
|
6
|
-
from cht_cyclones.cyclone_track_database import CycloneTrackDatabase
|
|
7
|
-
|
|
8
|
-
from flood_adapt.adapter.fiat_adapter import FiatAdapter
|
|
9
|
-
from flood_adapt.adapter.sfincs_adapter import SfincsAdapter
|
|
10
|
-
from flood_adapt.config.config import Settings
|
|
11
|
-
from flood_adapt.dbs_classes.interface.database import IDatabase
|
|
12
|
-
from flood_adapt.dbs_classes.interface.static import IDbsStatic
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
self.
|
|
49
|
-
self.
|
|
50
|
-
self.
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
self.
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
if
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
/
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
/
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
/
|
|
272
|
-
|
|
273
|
-
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
from typing import Any, Callable, Tuple, Union
|
|
3
|
+
|
|
4
|
+
import geopandas as gpd
|
|
5
|
+
import pandas as pd
|
|
6
|
+
from cht_cyclones.cyclone_track_database import CycloneTrackDatabase
|
|
7
|
+
|
|
8
|
+
from flood_adapt.adapter.fiat_adapter import FiatAdapter
|
|
9
|
+
from flood_adapt.adapter.sfincs_adapter import SfincsAdapter
|
|
10
|
+
from flood_adapt.config.config import Settings
|
|
11
|
+
from flood_adapt.dbs_classes.interface.database import IDatabase
|
|
12
|
+
from flood_adapt.dbs_classes.interface.static import IDbsStatic
|
|
13
|
+
from flood_adapt.misc.exceptions import DatabaseError
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def cache_method_wrapper(func: Callable) -> Callable:
|
|
17
|
+
def wrapper(self, *args: Tuple[Any], **kwargs: dict[str, Any]) -> Any:
|
|
18
|
+
if func.__name__ not in self._cached_data:
|
|
19
|
+
self._cached_data[func.__name__] = {}
|
|
20
|
+
|
|
21
|
+
args_key = (
|
|
22
|
+
str(args) + str(sorted(kwargs.items())) if args or kwargs else "no_args"
|
|
23
|
+
)
|
|
24
|
+
if args_key in self._cached_data[func.__name__]:
|
|
25
|
+
return self._cached_data[func.__name__][args_key]
|
|
26
|
+
|
|
27
|
+
result = func(self, *args, **kwargs)
|
|
28
|
+
self._cached_data[func.__name__][args_key] = result
|
|
29
|
+
|
|
30
|
+
return result
|
|
31
|
+
|
|
32
|
+
return wrapper
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
class DbsStatic(IDbsStatic):
|
|
36
|
+
_cached_data: dict[str, Any] = {}
|
|
37
|
+
_database: IDatabase
|
|
38
|
+
|
|
39
|
+
def __init__(self, database: IDatabase):
|
|
40
|
+
"""Initialize any necessary attributes."""
|
|
41
|
+
self._database = database
|
|
42
|
+
|
|
43
|
+
def load_static_data(self):
|
|
44
|
+
"""Read data into the cache.
|
|
45
|
+
|
|
46
|
+
This is used to read data from the database and store it in the cache.
|
|
47
|
+
"""
|
|
48
|
+
self.get_aggregation_areas()
|
|
49
|
+
self.get_model_boundary()
|
|
50
|
+
self.get_model_grid()
|
|
51
|
+
self.get_obs_points()
|
|
52
|
+
if self._database.site.sfincs.slr_scenarios is not None:
|
|
53
|
+
self.get_slr_scn_names()
|
|
54
|
+
self.get_buildings()
|
|
55
|
+
self.get_property_types()
|
|
56
|
+
|
|
57
|
+
@cache_method_wrapper
|
|
58
|
+
def get_aggregation_areas(self) -> dict[str, gpd.GeoDataFrame]:
|
|
59
|
+
"""Get a list of the aggregation areas that are provided in the site configuration.
|
|
60
|
+
|
|
61
|
+
These are expected to much the ones in the FIAT model.
|
|
62
|
+
|
|
63
|
+
Returns
|
|
64
|
+
-------
|
|
65
|
+
list[gpd.GeoDataFrame]
|
|
66
|
+
list of gpd.GeoDataFrames with the polygons defining the aggregation areas
|
|
67
|
+
"""
|
|
68
|
+
aggregation_areas = {}
|
|
69
|
+
for aggr_dict in self._database.site.fiat.config.aggregation:
|
|
70
|
+
aggregation_areas[aggr_dict.name] = gpd.read_file(
|
|
71
|
+
self._database.static_path / aggr_dict.file,
|
|
72
|
+
engine="pyogrio",
|
|
73
|
+
).to_crs(4326)
|
|
74
|
+
# Use always the same column name for name labels
|
|
75
|
+
aggregation_areas[aggr_dict.name] = aggregation_areas[
|
|
76
|
+
aggr_dict.name
|
|
77
|
+
].rename(columns={aggr_dict.field_name: "name"})
|
|
78
|
+
# Make sure they are ordered alphabetically
|
|
79
|
+
aggregation_areas[aggr_dict.name].sort_values(by="name").reset_index(
|
|
80
|
+
drop=True
|
|
81
|
+
)
|
|
82
|
+
return aggregation_areas
|
|
83
|
+
|
|
84
|
+
@cache_method_wrapper
|
|
85
|
+
def get_model_boundary(self) -> gpd.GeoDataFrame:
|
|
86
|
+
"""Get the model boundary from the SFINCS model."""
|
|
87
|
+
bnd = self.get_overland_sfincs_model().get_model_boundary()
|
|
88
|
+
return bnd
|
|
89
|
+
|
|
90
|
+
@cache_method_wrapper
|
|
91
|
+
def get_model_grid(self):
|
|
92
|
+
"""Get the model grid from the SFINCS model.
|
|
93
|
+
|
|
94
|
+
Returns
|
|
95
|
+
-------
|
|
96
|
+
QuadtreeGrid
|
|
97
|
+
The model grid
|
|
98
|
+
"""
|
|
99
|
+
grid = self.get_overland_sfincs_model().get_model_grid()
|
|
100
|
+
return grid
|
|
101
|
+
|
|
102
|
+
@cache_method_wrapper
|
|
103
|
+
def get_obs_points(self) -> gpd.GeoDataFrame:
|
|
104
|
+
"""Get the observation points from the flood hazard model."""
|
|
105
|
+
names = []
|
|
106
|
+
descriptions = []
|
|
107
|
+
lat = []
|
|
108
|
+
lon = []
|
|
109
|
+
if self._database.site.sfincs.obs_point is not None:
|
|
110
|
+
obs_points = self._database.site.sfincs.obs_point
|
|
111
|
+
for pt in obs_points:
|
|
112
|
+
names.append(pt.name)
|
|
113
|
+
descriptions.append(pt.description)
|
|
114
|
+
lat.append(pt.lat)
|
|
115
|
+
lon.append(pt.lon)
|
|
116
|
+
|
|
117
|
+
# create gpd.GeoDataFrame from obs_points in site file
|
|
118
|
+
df = pd.DataFrame({"name": names, "description": descriptions})
|
|
119
|
+
# TODO: make crs flexible and add this as a parameter to site.toml?
|
|
120
|
+
gdf = gpd.GeoDataFrame(
|
|
121
|
+
df, geometry=gpd.points_from_xy(lon, lat), crs="EPSG:4326"
|
|
122
|
+
)
|
|
123
|
+
return gdf
|
|
124
|
+
|
|
125
|
+
@cache_method_wrapper
|
|
126
|
+
def get_static_map(self, path: Union[str, Path]) -> gpd.GeoDataFrame:
|
|
127
|
+
"""Get a map from the static folder.
|
|
128
|
+
|
|
129
|
+
Parameters
|
|
130
|
+
----------
|
|
131
|
+
path : Union[str, Path]
|
|
132
|
+
Path to the map relative to the static folder
|
|
133
|
+
|
|
134
|
+
Returns
|
|
135
|
+
-------
|
|
136
|
+
gpd.GeoDataFrame
|
|
137
|
+
gpd.GeoDataFrame with the map in crs 4326
|
|
138
|
+
|
|
139
|
+
Raises
|
|
140
|
+
------
|
|
141
|
+
DatabaseError
|
|
142
|
+
If the file is not found
|
|
143
|
+
"""
|
|
144
|
+
# Read the map
|
|
145
|
+
full_path = self._database.static_path / path
|
|
146
|
+
if not full_path.is_file():
|
|
147
|
+
raise DatabaseError(f"File {full_path} not found")
|
|
148
|
+
return gpd.read_file(full_path, engine="pyogrio").to_crs(4326)
|
|
149
|
+
|
|
150
|
+
@cache_method_wrapper
|
|
151
|
+
def get_slr_scn_names(self) -> list:
|
|
152
|
+
"""Get the names of the sea level rise scenarios from the file provided.
|
|
153
|
+
|
|
154
|
+
Returns
|
|
155
|
+
-------
|
|
156
|
+
list
|
|
157
|
+
List of scenario names
|
|
158
|
+
"""
|
|
159
|
+
input_file = self._database.static_path.joinpath(
|
|
160
|
+
self._database.site.sfincs.slr_scenarios.file
|
|
161
|
+
)
|
|
162
|
+
df = pd.read_csv(input_file)
|
|
163
|
+
names = df.columns[2:].to_list()
|
|
164
|
+
return names
|
|
165
|
+
|
|
166
|
+
@cache_method_wrapper
|
|
167
|
+
def get_green_infra_table(self, measure_type: str) -> pd.DataFrame:
|
|
168
|
+
"""Return a table with different types of green infrastructure measures and their infiltration depths.
|
|
169
|
+
|
|
170
|
+
This is read by a csv file in the database.
|
|
171
|
+
|
|
172
|
+
Returns
|
|
173
|
+
-------
|
|
174
|
+
pd.DataFrame
|
|
175
|
+
Table with values
|
|
176
|
+
"""
|
|
177
|
+
# Read file from database
|
|
178
|
+
df = pd.read_csv(
|
|
179
|
+
self._database.static_path.joinpath(
|
|
180
|
+
"green_infra_table", "green_infra_lookup_table.csv"
|
|
181
|
+
)
|
|
182
|
+
)
|
|
183
|
+
|
|
184
|
+
# Get column with values
|
|
185
|
+
val_name = "Infiltration depth"
|
|
186
|
+
col_name = [name for name in df.columns if val_name in name][0]
|
|
187
|
+
if not col_name:
|
|
188
|
+
raise KeyError(f"A column with a name containing {val_name} was not found!")
|
|
189
|
+
|
|
190
|
+
# Get list of types per measure
|
|
191
|
+
df["types"] = [
|
|
192
|
+
[x.strip() for x in row["types"].split(",")] for i, row in df.iterrows()
|
|
193
|
+
]
|
|
194
|
+
|
|
195
|
+
# Show specific values based on measure type
|
|
196
|
+
inds = [i for i, row in df.iterrows() if measure_type in row["types"]]
|
|
197
|
+
df = df.drop(columns="types").iloc[inds, :]
|
|
198
|
+
|
|
199
|
+
return df
|
|
200
|
+
|
|
201
|
+
@cache_method_wrapper
|
|
202
|
+
def get_buildings(self) -> gpd.GeoDataFrame:
|
|
203
|
+
"""Get the building footprints from the FIAT model.
|
|
204
|
+
|
|
205
|
+
This should only be the buildings excluding any other types (e.g., roads)
|
|
206
|
+
The parameters non_building_names in the site config is used for that.
|
|
207
|
+
|
|
208
|
+
Returns
|
|
209
|
+
-------
|
|
210
|
+
gpd.GeoDataFrame
|
|
211
|
+
building footprints with all the FIAT columns
|
|
212
|
+
"""
|
|
213
|
+
return self.get_fiat_model().get_buildings()
|
|
214
|
+
|
|
215
|
+
@cache_method_wrapper
|
|
216
|
+
def get_property_types(self) -> list:
|
|
217
|
+
"""_summary_.
|
|
218
|
+
|
|
219
|
+
Returns
|
|
220
|
+
-------
|
|
221
|
+
list
|
|
222
|
+
_description_
|
|
223
|
+
"""
|
|
224
|
+
return self.get_fiat_model().get_property_types()
|
|
225
|
+
|
|
226
|
+
def get_overland_sfincs_model(self) -> SfincsAdapter:
|
|
227
|
+
"""Get the template offshore SFINCS model."""
|
|
228
|
+
overland_path = (
|
|
229
|
+
self._database.static_path
|
|
230
|
+
/ "templates"
|
|
231
|
+
/ self._database.site.sfincs.config.overland_model.name
|
|
232
|
+
)
|
|
233
|
+
with SfincsAdapter(model_root=overland_path) as overland_model:
|
|
234
|
+
return overland_model
|
|
235
|
+
|
|
236
|
+
def get_offshore_sfincs_model(self) -> SfincsAdapter:
|
|
237
|
+
"""Get the template overland Sfincs model."""
|
|
238
|
+
if self._database.site.sfincs.config.offshore_model is None:
|
|
239
|
+
raise DatabaseError("No offshore model defined in the site configuration.")
|
|
240
|
+
|
|
241
|
+
offshore_path = (
|
|
242
|
+
self._database.static_path
|
|
243
|
+
/ "templates"
|
|
244
|
+
/ self._database.site.sfincs.config.offshore_model.name
|
|
245
|
+
)
|
|
246
|
+
with SfincsAdapter(model_root=offshore_path) as offshore_model:
|
|
247
|
+
return offshore_model
|
|
248
|
+
|
|
249
|
+
def get_fiat_model(self) -> FiatAdapter:
|
|
250
|
+
"""Get the path to the FIAT model."""
|
|
251
|
+
if self._database.site.fiat is None:
|
|
252
|
+
raise DatabaseError("No FIAT model defined in the site configuration.")
|
|
253
|
+
template_path = self._database.static_path / "templates" / "fiat"
|
|
254
|
+
with FiatAdapter(
|
|
255
|
+
model_root=template_path,
|
|
256
|
+
config=self._database.site.fiat.config,
|
|
257
|
+
exe_path=Settings().fiat_bin_path,
|
|
258
|
+
delete_crashed_runs=Settings().delete_crashed_runs,
|
|
259
|
+
config_base_path=self._database.static_path,
|
|
260
|
+
) as fm:
|
|
261
|
+
return fm
|
|
262
|
+
|
|
263
|
+
@cache_method_wrapper
|
|
264
|
+
def get_cyclone_track_database(self) -> CycloneTrackDatabase:
|
|
265
|
+
if self._database.site.sfincs.cyclone_track_database is None:
|
|
266
|
+
raise DatabaseError(
|
|
267
|
+
"No cyclone track database defined in the site configuration."
|
|
268
|
+
)
|
|
269
|
+
database_file = str(
|
|
270
|
+
self._database.static_path
|
|
271
|
+
/ "cyclone_track_database"
|
|
272
|
+
/ self._database.site.sfincs.cyclone_track_database.file
|
|
273
|
+
)
|
|
274
|
+
return CycloneTrackDatabase("ibtracs", file_name=database_file)
|