flood-adapt 0.3.9__py3-none-any.whl → 0.3.11__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 +1853 -1848
  9. flood_adapt/adapter/sfincs_offshore.py +187 -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 +533 -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 +1229 -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 +236 -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 +551 -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.11.dist-info}/LICENSE +674 -674
  96. {flood_adapt-0.3.9.dist-info → flood_adapt-0.3.11.dist-info}/METADATA +867 -865
  97. flood_adapt-0.3.11.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.11.dist-info}/WHEEL +0 -0
  100. {flood_adapt-0.3.9.dist-info → flood_adapt-0.3.11.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): ...