flood-adapt 0.3.0__py3-none-any.whl → 0.3.2__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.
Files changed (32) hide show
  1. flood_adapt/__init__.py +1 -1
  2. flood_adapt/config/fiat.py +7 -7
  3. flood_adapt/config/site.py +2 -2
  4. flood_adapt/database_builder/database_builder.py +14 -6
  5. flood_adapt/dbs_classes/database.py +24 -17
  6. flood_adapt/dbs_classes/dbs_event.py +0 -15
  7. flood_adapt/dbs_classes/dbs_measure.py +15 -7
  8. flood_adapt/dbs_classes/dbs_static.py +3 -5
  9. flood_adapt/dbs_classes/dbs_template.py +3 -4
  10. flood_adapt/flood_adapt.py +115 -260
  11. flood_adapt/objects/__init__.py +40 -17
  12. flood_adapt/objects/benefits/benefits.py +6 -6
  13. flood_adapt/objects/events/event_set.py +4 -4
  14. flood_adapt/objects/events/events.py +18 -5
  15. flood_adapt/objects/events/historical.py +11 -8
  16. flood_adapt/objects/events/hurricane.py +11 -8
  17. flood_adapt/objects/events/synthetic.py +9 -7
  18. flood_adapt/objects/forcing/forcing.py +9 -1
  19. flood_adapt/objects/forcing/plotting.py +1 -0
  20. flood_adapt/objects/forcing/tide_gauge.py +14 -14
  21. flood_adapt/objects/forcing/time_frame.py +13 -0
  22. flood_adapt/objects/forcing/timeseries.py +27 -15
  23. flood_adapt/objects/measures/measures.py +38 -15
  24. flood_adapt/objects/object_model.py +2 -2
  25. flood_adapt/objects/projections/projections.py +18 -18
  26. flood_adapt/objects/strategies/strategies.py +22 -1
  27. flood_adapt/workflows/benefit_runner.py +1 -1
  28. {flood_adapt-0.3.0.dist-info → flood_adapt-0.3.2.dist-info}/METADATA +1 -2
  29. {flood_adapt-0.3.0.dist-info → flood_adapt-0.3.2.dist-info}/RECORD +32 -32
  30. {flood_adapt-0.3.0.dist-info → flood_adapt-0.3.2.dist-info}/LICENSE +0 -0
  31. {flood_adapt-0.3.0.dist-info → flood_adapt-0.3.2.dist-info}/WHEEL +0 -0
  32. {flood_adapt-0.3.0.dist-info → flood_adapt-0.3.2.dist-info}/top_level.txt +0 -0
@@ -1,6 +1,5 @@
1
- import os
2
1
  from pathlib import Path
3
- from typing import Any, List, Optional, Type, Union
2
+ from typing import Any, List, Optional, Union
4
3
 
5
4
  import geopandas as gpd
6
5
  import numpy as np
@@ -10,7 +9,6 @@ from fiat_toolbox.infographics.infographics_factory import InforgraphicFactory
10
9
  from fiat_toolbox.metrics_writer.fiat_read_metrics_file import MetricsFileReader
11
10
  from hydromt_sfincs.quadtree import QuadtreeGrid
12
11
 
13
- from flood_adapt.config.site import Site
14
12
  from flood_adapt.dbs_classes.database import Database
15
13
  from flood_adapt.misc.log import FloodAdaptLogging
16
14
  from flood_adapt.objects.benefits.benefits import Benefit
@@ -20,21 +18,13 @@ from flood_adapt.objects.events.event_factory import (
20
18
  from flood_adapt.objects.events.event_set import EventSet
21
19
  from flood_adapt.objects.events.events import (
22
20
  Event,
23
- Mode,
24
- Template,
25
21
  )
26
- from flood_adapt.objects.forcing import unit_system as us
27
- from flood_adapt.objects.forcing.csv import read_csv as _read_csv
28
22
  from flood_adapt.objects.forcing.forcing import (
29
23
  ForcingType,
30
- IForcing,
31
24
  )
32
- from flood_adapt.objects.forcing.forcing_factory import ForcingFactory
33
25
  from flood_adapt.objects.forcing.plotting import (
34
26
  plot_forcing as _plot_forcing,
35
27
  )
36
- from flood_adapt.objects.forcing.tide_gauge import TideGauge
37
- from flood_adapt.objects.forcing.time_frame import TimeFrame
38
28
  from flood_adapt.objects.measures.measures import (
39
29
  Buyout,
40
30
  Elevate,
@@ -73,7 +63,7 @@ class FloodAdapt:
73
63
 
74
64
  Returns
75
65
  -------
76
- dict[str, Any]
66
+ measures : dict[str, Any]
77
67
  A dictionary containing all measures.
78
68
  Includes keys: 'name', 'description', 'path', 'last_modification_date', 'objects'
79
69
  Each value is a list of the corresponding attribute for each measure.
@@ -91,7 +81,7 @@ class FloodAdapt:
91
81
 
92
82
  Returns
93
83
  -------
94
- Measure
84
+ measure : Measure
95
85
  The measure object with the given name.
96
86
 
97
87
  Raises
@@ -113,7 +103,7 @@ class FloodAdapt:
113
103
 
114
104
  Returns
115
105
  -------
116
- Measure
106
+ measure : Measure
117
107
  Measure object.
118
108
  """
119
109
  if type == "elevate_properties":
@@ -132,7 +122,7 @@ class FloodAdapt:
132
122
  raise ValueError(f"Invalid measure type: {type}")
133
123
 
134
124
  def save_measure(self, measure: Measure, overwrite: bool = False) -> None:
135
- """Save an event object to the database.
125
+ """Save a measure object to the database.
136
126
 
137
127
  Parameters
138
128
  ----------
@@ -142,101 +132,54 @@ class FloodAdapt:
142
132
  Raises
143
133
  ------
144
134
  ValueError
145
- If the event object is not valid.
135
+ If the measure object is not valid.
146
136
  """
147
137
  self.database.measures.save(measure, overwrite=overwrite)
148
138
 
149
139
  def edit_measure(self, measure: Measure) -> None:
150
- """Edit an event object in the database.
140
+ """Edit a measure object in the database.
151
141
 
152
142
  Parameters
153
143
  ----------
154
144
  measure : Measure
155
145
  The measure object to edit.
156
146
 
157
-
158
147
  Raises
159
148
  ------
160
149
  ValueError
161
- If the event object does not exist.
150
+ If the measure object does not exist.
162
151
  """
163
152
  self.database.measures.edit(measure)
164
153
 
165
154
  def delete_measure(self, name: str) -> None:
166
- """Delete an event from the database.
155
+ """Delete an measure from the database.
167
156
 
168
157
  Parameters
169
158
  ----------
170
159
  name : str
171
- The name of the event to delete.
160
+ The name of the measure to delete.
172
161
 
173
162
  Raises
174
163
  ------
175
164
  ValueError
176
- If the event does not exist.
165
+ If the measure does not exist.
177
166
  """
178
167
  self.database.measures.delete(name)
179
168
 
180
169
  def copy_measure(self, old_name: str, new_name: str, new_description: str) -> None:
181
- """Copy an event in the database.
170
+ """Copy a measure in the database.
182
171
 
183
172
  Parameters
184
173
  ----------
185
174
  old_name : str
186
- The name of the event to copy.
175
+ The name of the measure to copy.
187
176
  new_name : str
188
- The name of the new event.
177
+ The name of the new measure.
189
178
  new_description : str
190
- The description of the new event
179
+ The description of the new measure
191
180
  """
192
181
  self.database.measures.copy(old_name, new_name, new_description)
193
182
 
194
- def calculate_polygon_area(self, gdf: gpd.GeoDataFrame, site: Site) -> float:
195
- """
196
- Calculate the area of a polygon from a GeoDataFrame.
197
-
198
- Parameters
199
- ----------
200
- gdf : gpd.GeoDataFrame
201
- A GeoDataFrame containing the polygon geometry.
202
- site : Site
203
- An instance of Site representing the site information.
204
-
205
- Returns
206
- -------
207
- float: The area of the polygon in the specified units.
208
- """
209
- return GreenInfrastructure.calculate_polygon_area(gdf=gdf, site=site)
210
-
211
- def calculate_volume(
212
- self,
213
- area: us.UnitfulArea,
214
- height: us.UnitfulHeight = us.UnitfulHeight(
215
- value=0.0, units=us.UnitTypesLength.meters
216
- ),
217
- percent_area: float = 100.0,
218
- ) -> float:
219
- """
220
- Calculate the volume of green infrastructure based on the given area, height, and percent area.
221
-
222
- Parameters
223
- ----------
224
- area : float
225
- The area of the green infrastructure in square units.
226
- height : float
227
- The height of the green infrastructure in units. Defaults to 0.0.
228
- percent_area : float
229
- The percentage of the area to be considered. Defaults to 100.0.
230
-
231
-
232
- Returns
233
- -------
234
- float: The calculated volume of the green infrastructure.
235
- """
236
- return GreenInfrastructure.calculate_volume(
237
- area=area, height=height, percent_area=percent_area
238
- )
239
-
240
183
  def get_green_infra_table(self, measure_type: str) -> pd.DataFrame:
241
184
  """Return a table with different types of green infrastructure measures and their infiltration depths.
242
185
 
@@ -247,7 +190,7 @@ class FloodAdapt:
247
190
 
248
191
  Returns
249
192
  -------
250
- pd.DataFrame
193
+ table : pd.DataFrame
251
194
  A table with different types of green infrastructure measures and their infiltration depths.
252
195
 
253
196
  """
@@ -260,7 +203,7 @@ class FloodAdapt:
260
203
 
261
204
  Returns
262
205
  -------
263
- dict[str, Any]
206
+ strategies : dict[str, Any]
264
207
  A dictionary containing all strategies.
265
208
  Includes keys: 'name', 'description', 'path', 'last_modification_date', 'objects'
266
209
  Each value is a list of the corresponding attribute for each strategy.
@@ -278,7 +221,7 @@ class FloodAdapt:
278
221
 
279
222
  Returns
280
223
  -------
281
- Strategy
224
+ strategy : Strategy
282
225
  The strategy object with the given name.
283
226
 
284
227
  Raises
@@ -298,7 +241,7 @@ class FloodAdapt:
298
241
 
299
242
  Returns
300
243
  -------
301
- Strategy
244
+ strategy : Strategy
302
245
  The strategy object
303
246
 
304
247
  Raises
@@ -342,13 +285,27 @@ class FloodAdapt:
342
285
  """
343
286
  self.database.strategies.delete(name)
344
287
 
288
+ def copy_strategy(self, old_name: str, new_name: str, new_description: str) -> None:
289
+ """Copy a strategy in the database.
290
+
291
+ Parameters
292
+ ----------
293
+ old_name : str
294
+ The name of the strategy to copy.
295
+ new_name : str
296
+ The name of the new strategy.
297
+ new_description : str
298
+ The description of the new strategy
299
+ """
300
+ self.database.strategies.copy(old_name, new_name, new_description)
301
+
345
302
  # Events
346
303
  def get_events(self) -> dict[str, Any]:
347
304
  """Get all events from the database.
348
305
 
349
306
  Returns
350
307
  -------
351
- dict[str, Any]
308
+ events : dict[str, Any]
352
309
  A dictionary containing all events.
353
310
  Includes keys: 'name', 'description', 'path', 'last_modification_date', 'objects'
354
311
  Each value is a list of the corresponding attribute for each benefit.
@@ -365,7 +322,7 @@ class FloodAdapt:
365
322
 
366
323
  Returns
367
324
  -------
368
- Event | EventSet
325
+ event: Union[Event, EventSet]
369
326
  The event with the given name.
370
327
 
371
328
  Raises
@@ -375,20 +332,6 @@ class FloodAdapt:
375
332
  """
376
333
  return self.database.events.get(name)
377
334
 
378
- def get_event_mode(self, name: str) -> Mode:
379
- """Get the mode of an event from the database by name.
380
-
381
- Parameters
382
- ----------
383
- name : str
384
-
385
- Returns
386
- -------
387
- Mode
388
- The mode of the event with the given name, either `risk` or `single_event`.
389
- """
390
- return self.database.events.get(name).mode
391
-
392
335
  def create_event(self, attrs: dict[str, Any] | Event) -> Event:
393
336
  """Create a event object from a dictionary of attributes.
394
337
 
@@ -399,7 +342,7 @@ class FloodAdapt:
399
342
 
400
343
  Returns
401
344
  -------
402
- Event
345
+ event : Event
403
346
  Depending on attrs.template an event object.
404
347
  Can be of type: Synthetic, Historical, Hurricane.
405
348
  """
@@ -419,19 +362,11 @@ class FloodAdapt:
419
362
 
420
363
  Returns
421
364
  -------
422
- EventSet
365
+ event_set : EventSet
423
366
  EventSet object
424
367
  """
425
368
  return EventSet(**attrs, sub_events=sub_events)
426
369
 
427
- @staticmethod
428
- def list_forcings() -> list[Type[IForcing]]:
429
- return ForcingFactory.list_forcings()
430
-
431
- @staticmethod
432
- def get_allowed_forcings(template: Template) -> dict[str, List[str]]:
433
- return EventFactory.get_allowed_forcings(template)
434
-
435
370
  def save_event(self, event: Event) -> None:
436
371
  """Save an event object to the database.
437
372
 
@@ -447,20 +382,6 @@ class FloodAdapt:
447
382
  """
448
383
  self.database.events.save(event)
449
384
 
450
- def save_timeseries_csv(self, name: str, event: Event, df: pd.DataFrame) -> None:
451
- """Save timeseries data to a csv file.
452
-
453
- Parameters
454
- ----------
455
- name : str
456
- Name of the event
457
- event : Event
458
- Event object
459
- df : pd.DataFrame
460
- Dataframe of timeseries data
461
- """
462
- self.database.write_to_csv(name, event, df)
463
-
464
385
  def edit_event(self, event: Event) -> None:
465
386
  """Edit an event object in the database.
466
387
 
@@ -507,64 +428,7 @@ class FloodAdapt:
507
428
  """
508
429
  self.database.events.copy(old_name, new_name, new_description)
509
430
 
510
- def check_higher_level_usage(self, name: str) -> list[str]:
511
- """Check if an event is used in a scenario.
512
-
513
- Parameters
514
- ----------
515
- name : str
516
- name of the event to be checked
517
-
518
- Returns
519
- -------
520
- list[str]
521
- list of scenario names where the event is used
522
-
523
- """
524
- return self.database.events.check_higher_level_usage(name)
525
-
526
- def download_wl_data(
527
- self,
528
- tide_gauge: TideGauge,
529
- time: TimeFrame,
530
- units: us.UnitTypesLength,
531
- out_path: str,
532
- ) -> pd.DataFrame:
533
- """Download water level data from a station or tide gauge.
534
-
535
- Parameters
536
- ----------
537
- tide_gauge : TideGauge
538
- Tide gauge object to download data from
539
- time: TimeFrame
540
- Time model object containing start and end time
541
- units : UnitTypesLength
542
- Units that data the returned data will be converted to
543
- out_path : str
544
- Path to save the data to
545
- """
546
- return tide_gauge.get_waterlevels_in_time_frame(
547
- time=time,
548
- units=units,
549
- out_path=Path(out_path),
550
- )
551
-
552
- def read_csv(self, csvpath: Union[str, os.PathLike]) -> pd.DataFrame:
553
- """Read a csv file into a pandas DataFrame.
554
-
555
- Parameters
556
- ----------
557
- csvpath : Union[str, os.PathLike]
558
- Path to the csv file
559
-
560
- Returns
561
- -------
562
- pd.DataFrame
563
- DataFrame containing the data from the csv file
564
- """
565
- return _read_csv(csvpath)
566
-
567
- def plot_forcing(
431
+ def plot_event_forcing(
568
432
  self, event: Event, forcing_type: ForcingType
569
433
  ) -> tuple[str, Optional[List[Exception]]]:
570
434
  """Plot forcing data for an event.
@@ -578,19 +442,26 @@ class FloodAdapt:
578
442
  """
579
443
  return _plot_forcing(event, self.database.site, forcing_type)
580
444
 
581
- def save_cyclone_track(self, event: Event, track: TropicalCyclone):
582
- """Save cyclone track data to the event folder.
445
+ def get_cyclone_track_by_index(self, index: int) -> TropicalCyclone:
446
+ """
447
+ Get a cyclone track from the database by index.
583
448
 
584
449
  Parameters
585
450
  ----------
586
- event : Event
587
- The event object
588
- track : TropicalCyclone
589
- The cyclone track data
590
- """
591
- self.database.write_cyc(event, track)
451
+ index : int
452
+ The index of the cyclone track to retrieve.
592
453
 
593
- def get_cyclone_track_by_index(self, index: int) -> TropicalCyclone:
454
+ Returns
455
+ -------
456
+ cyclone : TropicalCyclone
457
+ The cyclone track object with the given index.
458
+
459
+ Raises
460
+ ------
461
+ ValueError
462
+ If the cyclone track database is not defined in the site configuration.
463
+ If the cyclone track with the given index does not exist.
464
+ """
594
465
  return self.database.static.get_cyclone_track_database().get_track(index)
595
466
 
596
467
  # Projections
@@ -600,7 +471,7 @@ class FloodAdapt:
600
471
 
601
472
  Returns
602
473
  -------
603
- dict[str, Any]
474
+ projections: dict[str, Any]
604
475
  A dictionary containing all projections.
605
476
  Includes keys: 'name', 'description', 'path', 'last_modification_date', 'objects'
606
477
  Each value is a list of the corresponding attribute for each projection.
@@ -617,7 +488,7 @@ class FloodAdapt:
617
488
 
618
489
  Returns
619
490
  -------
620
- Projection
491
+ projection : Projection
621
492
  The projection object with the given name.
622
493
 
623
494
  Raises
@@ -637,7 +508,7 @@ class FloodAdapt:
637
508
 
638
509
  Returns
639
510
  -------
640
- Projection
511
+ projection : Projection
641
512
  The projection object created from the attributes.
642
513
 
643
514
  Raises
@@ -717,7 +588,7 @@ class FloodAdapt:
717
588
 
718
589
  Returns
719
590
  -------
720
- list
591
+ names : List[str]
721
592
  List of scenario names
722
593
  """
723
594
  return self.database.static.get_slr_scn_names()
@@ -735,7 +606,7 @@ class FloodAdapt:
735
606
 
736
607
  Returns
737
608
  -------
738
- float
609
+ interpolated : float
739
610
  The interpolated sea level rise for the given scenario and year.
740
611
  """
741
612
  return self.database.interp_slr(slr_scenario, year)
@@ -746,7 +617,7 @@ class FloodAdapt:
746
617
 
747
618
  Returns
748
619
  -------
749
- str
620
+ html_path : str
750
621
  The path to the html plot of the sea level rise scenarios.
751
622
  """
752
623
  return self.database.plot_slr_scenarios()
@@ -757,7 +628,7 @@ class FloodAdapt:
757
628
 
758
629
  Returns
759
630
  -------
760
- dict[str, Any]
631
+ scenarios : dict[str, Any]
761
632
  A dictionary containing all scenarios.
762
633
  Includes keys: 'name', 'description', 'path', 'last_modification_date', 'objects'.
763
634
  Each value is a list of the corresponding attribute for each scenario.
@@ -774,7 +645,7 @@ class FloodAdapt:
774
645
 
775
646
  Returns
776
647
  -------
777
- Scenario
648
+ scenario : Scenario
778
649
  The scenario object with the given name.
779
650
 
780
651
  Raises
@@ -794,7 +665,7 @@ class FloodAdapt:
794
665
 
795
666
  Returns
796
667
  -------
797
- Scenario
668
+ scenario : Scenario
798
669
  The scenario object created from the attributes.
799
670
 
800
671
  Raises
@@ -814,9 +685,9 @@ class FloodAdapt:
814
685
 
815
686
  Returns
816
687
  -------
817
- bool
688
+ run_success : bool
818
689
  Whether the scenario was saved successfully.
819
- str
690
+ error_msg : str
820
691
  The error message if the scenario was not saved successfully.
821
692
  """
822
693
  try:
@@ -871,14 +742,14 @@ class FloodAdapt:
871
742
  self.database.run_scenario(name)
872
743
 
873
744
  # Outputs
874
- def get_outputs(
745
+ def get_completed_scenarios(
875
746
  self,
876
747
  ) -> dict[str, Any]:
877
748
  """Get all completed scenarios from the database.
878
749
 
879
750
  Returns
880
751
  -------
881
- dict[str, Any]
752
+ scenarios : dict[str, Any]
882
753
  A dictionary containing all scenarios.
883
754
  Includes keys: 'name', 'description', 'path', 'last_modification_date', 'objects'
884
755
  Each value is a list of the corresponding attribute for each output.
@@ -891,7 +762,7 @@ class FloodAdapt:
891
762
 
892
763
  Returns
893
764
  -------
894
- str
765
+ topo_path : str
895
766
  The path to the topobathy file.
896
767
 
897
768
  """
@@ -903,7 +774,7 @@ class FloodAdapt:
903
774
 
904
775
  Returns
905
776
  -------
906
- str
777
+ index_path : str
907
778
  The path to the index file.
908
779
  """
909
780
  return self.database.get_index_path()
@@ -914,12 +785,12 @@ class FloodAdapt:
914
785
 
915
786
  Returns
916
787
  -------
917
- float
788
+ fdc : float
918
789
  The flood depth conversion.
919
790
  """
920
791
  return self.database.get_depth_conversion()
921
792
 
922
- def get_max_water_level(self, name: str, rp: int = None) -> np.ndarray:
793
+ def get_max_water_level_map(self, name: str, rp: int = None) -> np.ndarray:
923
794
  """
924
795
  Return the maximum water level for the given scenario.
925
796
 
@@ -932,12 +803,12 @@ class FloodAdapt:
932
803
 
933
804
  Returns
934
805
  -------
935
- np.ndarray
806
+ water_level_map : np.ndarray
936
807
  2D gridded map with the maximum waterlevels for each cell.
937
808
  """
938
809
  return self.database.get_max_water_level(name, rp)
939
810
 
940
- def get_building_footprints(self, name: str) -> gpd.GeoDataFrame:
811
+ def get_building_footprint_impacts(self, name: str) -> gpd.GeoDataFrame:
941
812
  """
942
813
  Return a geodataframe of the impacts at the footprint level.
943
814
 
@@ -948,12 +819,12 @@ class FloodAdapt:
948
819
 
949
820
  Returns
950
821
  -------
951
- gpd.GeoDataFrame
822
+ footprints : gpd.GeoDataFrame
952
823
  The impact footprints for the scenario.
953
824
  """
954
825
  return self.database.get_building_footprints(name)
955
826
 
956
- def get_aggregation(self, name: str) -> dict[str, gpd.GeoDataFrame]:
827
+ def get_aggregated_impacts(self, name: str) -> dict[str, gpd.GeoDataFrame]:
957
828
  """
958
829
  Return a dictionary with the aggregated impacts as geodataframes.
959
830
 
@@ -964,12 +835,12 @@ class FloodAdapt:
964
835
 
965
836
  Returns
966
837
  -------
967
- dict[str, gpd.GeoDataFrame]
838
+ aggr_impacts : dict[str, gpd.GeoDataFrame]
968
839
  The aggregated impacts for the scenario.
969
840
  """
970
841
  return self.database.get_aggregation(name)
971
842
 
972
- def get_roads(self, name: str) -> gpd.GeoDataFrame:
843
+ def get_road_impacts(self, name: str) -> gpd.GeoDataFrame:
973
844
  """
974
845
  Return a geodataframe of the impacts at roads.
975
846
 
@@ -980,7 +851,7 @@ class FloodAdapt:
980
851
 
981
852
  Returns
982
853
  -------
983
- gpd.GeoDataFrame
854
+ roads : gpd.GeoDataFrame
984
855
  The impacted roads for the scenario.
985
856
  """
986
857
  return self.database.get_roads(name)
@@ -995,7 +866,7 @@ class FloodAdapt:
995
866
 
996
867
  Returns
997
868
  -------
998
- str
869
+ html_path : str
999
870
  The HTML strings of the water level timeseries
1000
871
  """
1001
872
  # Get the impacts objects from the scenario
@@ -1027,7 +898,7 @@ class FloodAdapt:
1027
898
 
1028
899
  Returns
1029
900
  -------
1030
- str
901
+ html: str
1031
902
  The HTML string of the infographic.
1032
903
  """
1033
904
  # Get the impacts objects from the scenario
@@ -1066,7 +937,8 @@ class FloodAdapt:
1066
937
 
1067
938
  Returns
1068
939
  -------
1069
- pd.DataFrame
940
+ metrics: pd.DataFrame
941
+ The metrics for the scenario.
1070
942
 
1071
943
  Raises
1072
944
  ------
@@ -1093,25 +965,6 @@ class FloodAdapt:
1093
965
  )
1094
966
 
1095
967
  # Static
1096
- @staticmethod
1097
- def read_database(
1098
- database_path: Union[str, os.PathLike], site_name: str
1099
- ) -> Database:
1100
- """Given a path and a site name returns a IDatabase object.
1101
-
1102
- Parameters
1103
- ----------
1104
- database_path : Union[str, os.PathLike]
1105
- path to database
1106
- site_name : str
1107
- name of the site
1108
-
1109
- Returns
1110
- -------
1111
- IDatabase
1112
- """
1113
- return Database(database_path, site_name)
1114
-
1115
968
  def get_aggregation_areas(
1116
969
  self,
1117
970
  ) -> dict[str, gpd.GeoDataFrame]:
@@ -1121,7 +974,7 @@ class FloodAdapt:
1121
974
 
1122
975
  Returns
1123
976
  -------
1124
- dict[str, GeoDataFrame]
977
+ aggregation_areas : dict[str, GeoDataFrame]
1125
978
  list of geodataframes with the polygons defining the aggregation areas
1126
979
  """
1127
980
  return self.database.static.get_aggregation_areas()
@@ -1135,7 +988,7 @@ class FloodAdapt:
1135
988
 
1136
989
  Returns
1137
990
  -------
1138
- gpd.GeoDataFrame
991
+ observation_points : gpd.GeoDataFrame
1139
992
  gpd.GeoDataFrame with observation points from the site.toml.
1140
993
  """
1141
994
  return self.database.static.get_obs_points()
@@ -1147,7 +1000,7 @@ class FloodAdapt:
1147
1000
 
1148
1001
  Returns
1149
1002
  -------
1150
- GeoDataFrame
1003
+ model_boundary : GeoDataFrame
1151
1004
  GeoDataFrame with the model boundary
1152
1005
  """
1153
1006
  return self.database.static.get_model_boundary()
@@ -1159,7 +1012,7 @@ class FloodAdapt:
1159
1012
 
1160
1013
  Returns
1161
1014
  -------
1162
- QuadtreeGrid
1015
+ grid : QuadtreeGrid
1163
1016
  QuadtreeGrid with the model grid
1164
1017
  """
1165
1018
  return self.database.static.get_model_grid()
@@ -1171,7 +1024,7 @@ class FloodAdapt:
1171
1024
 
1172
1025
  Returns
1173
1026
  -------
1174
- gpd.GeoDataFrame
1027
+ svi_map : gpd.GeoDataFrame
1175
1028
  gpd.GeoDataFrames with the SVI map, None if not available
1176
1029
  """
1177
1030
  if self.database.site.fiat.config.svi:
@@ -1191,53 +1044,45 @@ class FloodAdapt:
1191
1044
 
1192
1045
  Returns
1193
1046
  -------
1194
- gpd.gpd.GeoDataFrame
1195
- gpd.GeoDataFrame with the static map
1047
+ static_map : Union[gpd.GeoDataFrame, None]
1048
+ gpd.GeoDataFrame with the static map if available, None if not found
1196
1049
  """
1197
1050
  try:
1198
1051
  return self.database.static.get_static_map(path)
1199
- except Exception:
1052
+ except FileNotFoundError:
1053
+ self.logger.warning(f"Static map {path} not found.")
1200
1054
  return None
1201
1055
 
1202
- def get_buildings(self) -> gpd.GeoDataFrame:
1056
+ def get_building_geometries(self) -> gpd.GeoDataFrame:
1203
1057
  """Get the buildings exposure that are used in Fiat.
1204
1058
 
1205
1059
  Returns
1206
1060
  -------
1207
- gpd.GeoDataFrame
1061
+ buildings : gpd.GeoDataFrame
1208
1062
  gpd.GeoDataFrames with the buildings from FIAT exposure
1209
1063
  """
1210
1064
  return self.database.static.get_buildings()
1211
1065
 
1212
- def get_property_types(self) -> list:
1213
- """Get the property types that are used in the exposure.
1066
+ def get_building_types(self) -> list:
1067
+ """Get the building types/categories that are used in the exposure.
1068
+
1069
+ These are used to filter the buildings in the FIAT model, and can include types like:
1070
+ 'Residential', 'Commercial', 'Industrial', etc.
1214
1071
 
1215
1072
  Returns
1216
1073
  -------
1217
- list
1218
- list of property types
1074
+ building_types: list[str]
1075
+ list of building types
1219
1076
  """
1220
1077
  return self.database.static.get_property_types()
1221
1078
 
1222
- def get_hazard_measure_types(self):
1223
- """Get list of all implemented hazard measure types."""
1224
- raise NotImplementedError
1225
-
1226
- def get_impact_measure_types(self):
1227
- """Get list of all implemented impact measure types."""
1228
- raise NotImplementedError
1229
-
1230
- def get_event_templates(self):
1231
- """Get list of all implemented event templates."""
1232
- raise NotImplementedError
1233
-
1234
1079
  # Benefits
1235
1080
  def get_benefits(self) -> dict[str, Any]:
1236
1081
  """Get all benefits from the database.
1237
1082
 
1238
1083
  Returns
1239
1084
  -------
1240
- dict[str, Any]
1085
+ benefits : dict[str, Any]
1241
1086
  A dictionary containing all benefits.
1242
1087
  Includes keys: 'name', 'description', 'path', 'last_modification_date', 'objects'
1243
1088
  Each value is a list of the corresponding attribute for each benefit.
@@ -1255,7 +1100,7 @@ class FloodAdapt:
1255
1100
 
1256
1101
  Returns
1257
1102
  -------
1258
- Benefit
1103
+ benefit: Benefit
1259
1104
  The benefit object with the given name. See [Benefit](/api_ref/) for details.
1260
1105
 
1261
1106
  Raises
@@ -1272,6 +1117,16 @@ class FloodAdapt:
1272
1117
  ----------
1273
1118
  attrs : dict[str, Any]
1274
1119
  The attributes of the benefit object to create. Should adhere to the Benefit schema.
1120
+
1121
+ Returns
1122
+ -------
1123
+ benefit : Benefit
1124
+ The benefit object created from the attributes.
1125
+
1126
+ Raises
1127
+ ------
1128
+ ValueError
1129
+ If the attributes do not adhere to the Benefit schema.
1275
1130
  """
1276
1131
  return Benefit(**attrs)
1277
1132
 
@@ -1330,7 +1185,7 @@ class FloodAdapt:
1330
1185
 
1331
1186
  Returns
1332
1187
  -------
1333
- pd.DataFrame
1188
+ scenarios : pd.DataFrame
1334
1189
  A dataframe with the scenarios needed for this benefit assessment run.
1335
1190
  """
1336
1191
  return self.database.check_benefit_scenarios(benefit)
@@ -1355,7 +1210,7 @@ class FloodAdapt:
1355
1210
  """
1356
1211
  self.database.run_benefit(name)
1357
1212
 
1358
- def get_aggregation_benefits(self, name: str) -> dict[str, gpd.GeoDataFrame]:
1213
+ def get_aggregated_benefits(self, name: str) -> dict[str, gpd.GeoDataFrame]:
1359
1214
  """Get the aggregation benefits for a benefit assessment.
1360
1215
 
1361
1216
  Parameters
@@ -1365,7 +1220,7 @@ class FloodAdapt:
1365
1220
 
1366
1221
  Returns
1367
1222
  -------
1368
- gpd.GeoDataFrame
1223
+ aggregated_benefits : gpd.GeoDataFrame
1369
1224
  The aggregation benefits for the benefit assessment.
1370
1225
  """
1371
1226
  return self.database.get_aggregation_benefits(name)