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.
Files changed (100) hide show
  1. flood_adapt/__init__.py +26 -22
  2. flood_adapt/adapter/__init__.py +9 -9
  3. flood_adapt/adapter/fiat_adapter.py +1541 -1541
  4. flood_adapt/adapter/interface/hazard_adapter.py +70 -70
  5. flood_adapt/adapter/interface/impact_adapter.py +36 -36
  6. flood_adapt/adapter/interface/model_adapter.py +89 -89
  7. flood_adapt/adapter/interface/offshore.py +19 -19
  8. flood_adapt/adapter/sfincs_adapter.py +1848 -1848
  9. flood_adapt/adapter/sfincs_offshore.py +193 -193
  10. flood_adapt/config/config.py +248 -248
  11. flood_adapt/config/fiat.py +219 -219
  12. flood_adapt/config/gui.py +331 -331
  13. flood_adapt/config/sfincs.py +481 -336
  14. flood_adapt/config/site.py +129 -129
  15. flood_adapt/database_builder/database_builder.py +2210 -2210
  16. flood_adapt/database_builder/templates/default_units/imperial.toml +9 -9
  17. flood_adapt/database_builder/templates/default_units/metric.toml +9 -9
  18. flood_adapt/database_builder/templates/green_infra_table/green_infra_lookup_table.csv +10 -10
  19. flood_adapt/database_builder/templates/infographics/OSM/config_charts.toml +90 -90
  20. flood_adapt/database_builder/templates/infographics/OSM/config_people.toml +57 -57
  21. flood_adapt/database_builder/templates/infographics/OSM/config_risk_charts.toml +121 -121
  22. flood_adapt/database_builder/templates/infographics/OSM/config_roads.toml +65 -65
  23. flood_adapt/database_builder/templates/infographics/OSM/styles.css +45 -45
  24. flood_adapt/database_builder/templates/infographics/US_NSI/config_charts.toml +126 -126
  25. flood_adapt/database_builder/templates/infographics/US_NSI/config_people.toml +60 -60
  26. flood_adapt/database_builder/templates/infographics/US_NSI/config_risk_charts.toml +121 -121
  27. flood_adapt/database_builder/templates/infographics/US_NSI/config_roads.toml +65 -65
  28. flood_adapt/database_builder/templates/infographics/US_NSI/styles.css +45 -45
  29. flood_adapt/database_builder/templates/infometrics/OSM/metrics_additional_risk_configs.toml +4 -4
  30. flood_adapt/database_builder/templates/infometrics/OSM/with_SVI/infographic_metrics_config.toml +143 -143
  31. flood_adapt/database_builder/templates/infometrics/OSM/with_SVI/infographic_metrics_config_risk.toml +153 -153
  32. flood_adapt/database_builder/templates/infometrics/OSM/without_SVI/infographic_metrics_config.toml +127 -127
  33. flood_adapt/database_builder/templates/infometrics/OSM/without_SVI/infographic_metrics_config_risk.toml +57 -57
  34. flood_adapt/database_builder/templates/infometrics/US_NSI/metrics_additional_risk_configs.toml +4 -4
  35. flood_adapt/database_builder/templates/infometrics/US_NSI/with_SVI/infographic_metrics_config.toml +191 -191
  36. flood_adapt/database_builder/templates/infometrics/US_NSI/with_SVI/infographic_metrics_config_risk.toml +153 -153
  37. flood_adapt/database_builder/templates/infometrics/US_NSI/without_SVI/infographic_metrics_config.toml +178 -178
  38. flood_adapt/database_builder/templates/infometrics/US_NSI/without_SVI/infographic_metrics_config_risk.toml +57 -57
  39. flood_adapt/database_builder/templates/infometrics/mandatory_metrics_config.toml +9 -9
  40. flood_adapt/database_builder/templates/infometrics/mandatory_metrics_config_risk.toml +65 -65
  41. flood_adapt/database_builder/templates/output_layers/bin_colors.toml +5 -5
  42. flood_adapt/database_builder.py +16 -16
  43. flood_adapt/dbs_classes/__init__.py +21 -21
  44. flood_adapt/dbs_classes/database.py +495 -684
  45. flood_adapt/dbs_classes/dbs_benefit.py +77 -76
  46. flood_adapt/dbs_classes/dbs_event.py +61 -59
  47. flood_adapt/dbs_classes/dbs_measure.py +112 -111
  48. flood_adapt/dbs_classes/dbs_projection.py +34 -34
  49. flood_adapt/dbs_classes/dbs_scenario.py +137 -137
  50. flood_adapt/dbs_classes/dbs_static.py +274 -273
  51. flood_adapt/dbs_classes/dbs_strategy.py +130 -129
  52. flood_adapt/dbs_classes/dbs_template.py +279 -278
  53. flood_adapt/dbs_classes/interface/database.py +107 -139
  54. flood_adapt/dbs_classes/interface/element.py +121 -121
  55. flood_adapt/dbs_classes/interface/static.py +47 -47
  56. flood_adapt/flood_adapt.py +1207 -1178
  57. flood_adapt/misc/database_user.py +16 -16
  58. flood_adapt/misc/exceptions.py +22 -0
  59. flood_adapt/misc/log.py +183 -183
  60. flood_adapt/misc/path_builder.py +54 -54
  61. flood_adapt/misc/utils.py +185 -185
  62. flood_adapt/objects/__init__.py +82 -82
  63. flood_adapt/objects/benefits/benefits.py +61 -61
  64. flood_adapt/objects/events/event_factory.py +135 -135
  65. flood_adapt/objects/events/event_set.py +88 -84
  66. flood_adapt/objects/events/events.py +234 -234
  67. flood_adapt/objects/events/historical.py +58 -58
  68. flood_adapt/objects/events/hurricane.py +68 -67
  69. flood_adapt/objects/events/synthetic.py +46 -50
  70. flood_adapt/objects/forcing/__init__.py +92 -92
  71. flood_adapt/objects/forcing/csv.py +68 -68
  72. flood_adapt/objects/forcing/discharge.py +66 -66
  73. flood_adapt/objects/forcing/forcing.py +150 -150
  74. flood_adapt/objects/forcing/forcing_factory.py +182 -182
  75. flood_adapt/objects/forcing/meteo_handler.py +93 -93
  76. flood_adapt/objects/forcing/netcdf.py +40 -40
  77. flood_adapt/objects/forcing/plotting.py +453 -429
  78. flood_adapt/objects/forcing/rainfall.py +98 -98
  79. flood_adapt/objects/forcing/tide_gauge.py +191 -191
  80. flood_adapt/objects/forcing/time_frame.py +90 -90
  81. flood_adapt/objects/forcing/timeseries.py +564 -564
  82. flood_adapt/objects/forcing/unit_system.py +580 -580
  83. flood_adapt/objects/forcing/waterlevels.py +108 -108
  84. flood_adapt/objects/forcing/wind.py +124 -124
  85. flood_adapt/objects/measures/measure_factory.py +92 -92
  86. flood_adapt/objects/measures/measures.py +529 -529
  87. flood_adapt/objects/object_model.py +74 -68
  88. flood_adapt/objects/projections/projections.py +103 -103
  89. flood_adapt/objects/scenarios/scenarios.py +22 -22
  90. flood_adapt/objects/strategies/strategies.py +89 -89
  91. flood_adapt/workflows/benefit_runner.py +579 -554
  92. flood_adapt/workflows/floodmap.py +85 -85
  93. flood_adapt/workflows/impacts_integrator.py +85 -85
  94. flood_adapt/workflows/scenario_runner.py +70 -70
  95. {flood_adapt-0.3.9.dist-info → flood_adapt-0.3.10.dist-info}/LICENSE +674 -674
  96. {flood_adapt-0.3.9.dist-info → flood_adapt-0.3.10.dist-info}/METADATA +866 -865
  97. flood_adapt-0.3.10.dist-info/RECORD +140 -0
  98. flood_adapt-0.3.9.dist-info/RECORD +0 -139
  99. {flood_adapt-0.3.9.dist-info → flood_adapt-0.3.10.dist-info}/WHEEL +0 -0
  100. {flood_adapt-0.3.9.dist-info → flood_adapt-0.3.10.dist-info}/top_level.txt +0 -0
@@ -1,137 +1,137 @@
1
- import shutil
2
- from typing import Any
3
-
4
- from flood_adapt.dbs_classes.dbs_template import DbsTemplate
5
- from flood_adapt.misc.utils import finished_file_exists
6
- from flood_adapt.objects.scenarios.scenarios import Scenario
7
- from flood_adapt.workflows.benefit_runner import BenefitRunner
8
-
9
-
10
- class DbsScenario(DbsTemplate[Scenario]):
11
- dir_name = "scenarios"
12
- display_name = "Scenario"
13
- _object_class = Scenario
14
-
15
- def summarize_objects(self) -> dict[str, list[Any]]:
16
- """Return a dictionary with info on the events that currently exist in the database.
17
-
18
- Returns
19
- -------
20
- dict[str, Any]
21
- Includes 'name', 'description', 'path' and 'last_modification_date' info
22
- """
23
- scenarios = super().summarize_objects()
24
- scenarios["Projection"] = [
25
- self._read_variable_in_toml("projection", path)
26
- for path in scenarios["path"]
27
- ]
28
- scenarios["Event"] = [
29
- self._read_variable_in_toml("event", path) for path in scenarios["path"]
30
- ]
31
- scenarios["Strategy"] = [
32
- self._read_variable_in_toml("strategy", path) for path in scenarios["path"]
33
- ]
34
- scenarios["finished"] = [self.has_run_check(scn) for scn in scenarios["name"]]
35
-
36
- return scenarios
37
-
38
- def delete(self, name: str, toml_only: bool = False):
39
- """Delete an already existing scenario in the database.
40
-
41
- Parameters
42
- ----------
43
- name : str
44
- name of the scenario to be deleted
45
- toml_only : bool, optional
46
- whether to only delete the toml file or the entire folder. If the folder is empty after deleting the toml,
47
- it will always be deleted. By default False
48
-
49
- Raises
50
- ------
51
- ValueError
52
- Raise error if scenario to be deleted is already in use.
53
- """
54
- # First delete the scenario
55
- super().delete(name, toml_only)
56
-
57
- # Then delete the results
58
- if (self.output_path / name).exists():
59
- shutil.rmtree(self.output_path / name, ignore_errors=False)
60
-
61
- def check_higher_level_usage(self, name: str) -> list[str]:
62
- """Check if a scenario is used in a benefit.
63
-
64
- Parameters
65
- ----------
66
- name : str
67
- name of the scenario to be checked
68
-
69
- Returns
70
- -------
71
- list[str]
72
- list of benefits that use the scenario
73
- """
74
- benefits = [
75
- self._database.benefits.get(benefit)
76
- for benefit in self._database.benefits.summarize_objects()["name"]
77
- ]
78
- used_in_benefit = []
79
- for benefit in benefits:
80
- runner = BenefitRunner(database=self._database, benefit=benefit)
81
- scenarios = runner.scenarios["scenario created"].to_list()
82
- for scenario in scenarios:
83
- if name == scenario:
84
- used_in_benefit.append(benefit.name)
85
-
86
- return used_in_benefit
87
-
88
- def equal_hazard_components(self, left: Scenario, right: Scenario) -> bool:
89
- """Check if two scenarios have the same hazard components.
90
-
91
- Parameters
92
- ----------
93
- left : Scenario
94
- first scenario to be compared
95
- right : Scenario
96
- second scenario to be compared
97
-
98
- Returns
99
- -------
100
- bool
101
- True if the scenarios have the same hazard components, False otherwise
102
- """
103
- event_left = self._database.events.get(left.event)
104
- event_right = self._database.events.get(right.event)
105
- equal_events = event_left == event_right
106
-
107
- left_projection = self._database.projections.get(left.projection)
108
- right_projection = self._database.projections.get(right.projection)
109
- equal_projection = (
110
- left_projection.physical_projection == right_projection.physical_projection
111
- )
112
-
113
- left_strategy = self._database.strategies.get(
114
- left.strategy
115
- ).get_hazard_strategy()
116
- right_strategy = self._database.strategies.get(
117
- right.strategy
118
- ).get_hazard_strategy()
119
- equal_strategy = left_strategy == right_strategy
120
-
121
- return equal_events and equal_projection and equal_strategy
122
-
123
- def has_run_check(self, name: str) -> bool:
124
- """Check if the scenario has been run.
125
-
126
- Parameters
127
- ----------
128
- name : str
129
- name of the scenario to be checked
130
-
131
- Returns
132
- -------
133
- bool
134
- True if the scenario has been run, False otherwise
135
- """
136
- results_path = self.output_path / name
137
- return finished_file_exists(results_path)
1
+ import shutil
2
+ from typing import Any
3
+
4
+ from flood_adapt.dbs_classes.dbs_template import DbsTemplate
5
+ from flood_adapt.misc.utils import finished_file_exists
6
+ from flood_adapt.objects.scenarios.scenarios import Scenario
7
+ from flood_adapt.workflows.benefit_runner import BenefitRunner
8
+
9
+
10
+ class DbsScenario(DbsTemplate[Scenario]):
11
+ dir_name = "scenarios"
12
+ display_name = "Scenario"
13
+ _object_class = Scenario
14
+
15
+ def summarize_objects(self) -> dict[str, list[Any]]:
16
+ """Return a dictionary with info on the events that currently exist in the database.
17
+
18
+ Returns
19
+ -------
20
+ dict[str, Any]
21
+ Includes 'name', 'description', 'path' and 'last_modification_date' info
22
+ """
23
+ scenarios = super().summarize_objects()
24
+ scenarios["Projection"] = [
25
+ self._read_variable_in_toml("projection", path)
26
+ for path in scenarios["path"]
27
+ ]
28
+ scenarios["Event"] = [
29
+ self._read_variable_in_toml("event", path) for path in scenarios["path"]
30
+ ]
31
+ scenarios["Strategy"] = [
32
+ self._read_variable_in_toml("strategy", path) for path in scenarios["path"]
33
+ ]
34
+ scenarios["finished"] = [self.has_run_check(scn) for scn in scenarios["name"]]
35
+
36
+ return scenarios
37
+
38
+ def delete(self, name: str, toml_only: bool = False):
39
+ """Delete an already existing scenario in the database.
40
+
41
+ Parameters
42
+ ----------
43
+ name : str
44
+ name of the scenario to be deleted
45
+ toml_only : bool, optional
46
+ whether to only delete the toml file or the entire folder. If the folder is empty after deleting the toml,
47
+ it will always be deleted. By default False
48
+
49
+ Raises
50
+ ------
51
+ DatabaseError
52
+ Raise error if scenario to be deleted is already in use.
53
+ """
54
+ # First delete the scenario
55
+ super().delete(name, toml_only)
56
+
57
+ # Then delete the results
58
+ if (self.output_path / name).exists():
59
+ shutil.rmtree(self.output_path / name, ignore_errors=False)
60
+
61
+ def check_higher_level_usage(self, name: str) -> list[str]:
62
+ """Check if a scenario is used in a benefit.
63
+
64
+ Parameters
65
+ ----------
66
+ name : str
67
+ name of the scenario to be checked
68
+
69
+ Returns
70
+ -------
71
+ list[str]
72
+ list of benefits that use the scenario
73
+ """
74
+ benefits = [
75
+ self._database.benefits.get(benefit)
76
+ for benefit in self._database.benefits.summarize_objects()["name"]
77
+ ]
78
+ used_in_benefit = []
79
+ for benefit in benefits:
80
+ runner = BenefitRunner(database=self._database, benefit=benefit)
81
+ scenarios = runner.scenarios["scenario created"].to_list()
82
+ for scenario in scenarios:
83
+ if name == scenario:
84
+ used_in_benefit.append(benefit.name)
85
+
86
+ return used_in_benefit
87
+
88
+ def equal_hazard_components(self, left: Scenario, right: Scenario) -> bool:
89
+ """Check if two scenarios have the same hazard components.
90
+
91
+ Parameters
92
+ ----------
93
+ left : Scenario
94
+ first scenario to be compared
95
+ right : Scenario
96
+ second scenario to be compared
97
+
98
+ Returns
99
+ -------
100
+ bool
101
+ True if the scenarios have the same hazard components, False otherwise
102
+ """
103
+ event_left = self._database.events.get(left.event)
104
+ event_right = self._database.events.get(right.event)
105
+ equal_events = event_left == event_right
106
+
107
+ left_projection = self._database.projections.get(left.projection)
108
+ right_projection = self._database.projections.get(right.projection)
109
+ equal_projection = (
110
+ left_projection.physical_projection == right_projection.physical_projection
111
+ )
112
+
113
+ left_strategy = self._database.strategies.get(
114
+ left.strategy
115
+ ).get_hazard_strategy()
116
+ right_strategy = self._database.strategies.get(
117
+ right.strategy
118
+ ).get_hazard_strategy()
119
+ equal_strategy = left_strategy == right_strategy
120
+
121
+ return equal_events and equal_projection and equal_strategy
122
+
123
+ def has_run_check(self, name: str) -> bool:
124
+ """Check if the scenario has been run.
125
+
126
+ Parameters
127
+ ----------
128
+ name : str
129
+ name of the scenario to be checked
130
+
131
+ Returns
132
+ -------
133
+ bool
134
+ True if the scenario has been run, False otherwise
135
+ """
136
+ results_path = self.output_path / name
137
+ return finished_file_exists(results_path)