flood-adapt 0.3.7__tar.gz → 0.3.9__tar.gz
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-0.3.7 → flood_adapt-0.3.9}/PKG-INFO +10 -5
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/README.md +7 -4
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/__init__.py +1 -1
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/adapter/fiat_adapter.py +51 -46
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/adapter/sfincs_adapter.py +23 -26
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/config/config.py +28 -70
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/config/fiat.py +1 -1
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/database_builder/database_builder.py +2 -2
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/dbs_classes/database.py +1 -9
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/dbs_classes/dbs_scenario.py +1 -1
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/dbs_classes/dbs_static.py +3 -2
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/objects/projections/projections.py +22 -8
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/workflows/benefit_runner.py +14 -4
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/workflows/impacts_integrator.py +6 -3
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt.egg-info/PKG-INFO +10 -5
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt.egg-info/requires.txt +2 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/pyproject.toml +2 -12
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/LICENSE +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/adapter/__init__.py +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/adapter/interface/__init__.py +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/adapter/interface/hazard_adapter.py +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/adapter/interface/impact_adapter.py +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/adapter/interface/model_adapter.py +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/adapter/interface/offshore.py +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/adapter/sfincs_offshore.py +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/config/__init__.py +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/config/gui.py +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/config/sfincs.py +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/config/site.py +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/database_builder/__init__.py +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/database_builder/templates/default_units/imperial.toml +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/database_builder/templates/default_units/metric.toml +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/database_builder/templates/green_infra_table/green_infra_lookup_table.csv +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/database_builder/templates/icons/black_down_48x48.png +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/database_builder/templates/icons/black_left_48x48.png +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/database_builder/templates/icons/black_right_48x48.png +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/database_builder/templates/icons/black_up_48x48.png +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/database_builder/templates/icons/icons8-triangle-arrow-16_white_down.png +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/database_builder/templates/icons/icons8-triangle-arrow-16_white_left.png +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/database_builder/templates/icons/icons8-triangle-arrow-16_white_right.png +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/database_builder/templates/icons/icons8-triangle-arrow-16_white_up.png +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/database_builder/templates/icons/icons8-triangle-arrow-24_black_down.png +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/database_builder/templates/icons/icons8-triangle-arrow-24_black_left.png +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/database_builder/templates/icons/icons8-triangle-arrow-24_black_right.png +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/database_builder/templates/icons/icons8-triangle-arrow-24_black_up.png +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/database_builder/templates/icons/icons8-triangle-arrow-24_white_left.png +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/database_builder/templates/icons/icons8-triangle-arrow-24_white_right.png +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/database_builder/templates/icons/white_down_48x48.png +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/database_builder/templates/icons/white_left_48x48.png +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/database_builder/templates/icons/white_right_48x48.png +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/database_builder/templates/icons/white_up_48x48.png +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/database_builder/templates/infographics/OSM/config_charts.toml +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/database_builder/templates/infographics/OSM/config_people.toml +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/database_builder/templates/infographics/OSM/config_risk_charts.toml +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/database_builder/templates/infographics/OSM/config_roads.toml +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/database_builder/templates/infographics/OSM/styles.css +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/database_builder/templates/infographics/US_NSI/config_charts.toml +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/database_builder/templates/infographics/US_NSI/config_people.toml +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/database_builder/templates/infographics/US_NSI/config_risk_charts.toml +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/database_builder/templates/infographics/US_NSI/config_roads.toml +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/database_builder/templates/infographics/US_NSI/styles.css +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/database_builder/templates/infographics/images/ambulance.png +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/database_builder/templates/infographics/images/car.png +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/database_builder/templates/infographics/images/cart.png +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/database_builder/templates/infographics/images/firetruck.png +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/database_builder/templates/infographics/images/hospital.png +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/database_builder/templates/infographics/images/house.png +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/database_builder/templates/infographics/images/info.png +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/database_builder/templates/infographics/images/money.png +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/database_builder/templates/infographics/images/person.png +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/database_builder/templates/infographics/images/school.png +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/database_builder/templates/infographics/images/truck.png +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/database_builder/templates/infographics/images/walking_person.png +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/database_builder/templates/infometrics/OSM/metrics_additional_risk_configs.toml +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/database_builder/templates/infometrics/OSM/with_SVI/infographic_metrics_config.toml +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/database_builder/templates/infometrics/OSM/with_SVI/infographic_metrics_config_risk.toml +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/database_builder/templates/infometrics/OSM/without_SVI/infographic_metrics_config.toml +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/database_builder/templates/infometrics/OSM/without_SVI/infographic_metrics_config_risk.toml +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/database_builder/templates/infometrics/US_NSI/metrics_additional_risk_configs.toml +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/database_builder/templates/infometrics/US_NSI/with_SVI/infographic_metrics_config.toml +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/database_builder/templates/infometrics/US_NSI/with_SVI/infographic_metrics_config_risk.toml +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/database_builder/templates/infometrics/US_NSI/without_SVI/infographic_metrics_config.toml +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/database_builder/templates/infometrics/US_NSI/without_SVI/infographic_metrics_config_risk.toml +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/database_builder/templates/infometrics/mandatory_metrics_config.toml +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/database_builder/templates/infometrics/mandatory_metrics_config_risk.toml +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/database_builder/templates/output_layers/bin_colors.toml +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/database_builder.py +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/dbs_classes/__init__.py +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/dbs_classes/dbs_benefit.py +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/dbs_classes/dbs_event.py +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/dbs_classes/dbs_measure.py +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/dbs_classes/dbs_projection.py +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/dbs_classes/dbs_strategy.py +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/dbs_classes/dbs_template.py +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/dbs_classes/interface/database.py +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/dbs_classes/interface/element.py +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/dbs_classes/interface/static.py +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/flood_adapt.py +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/misc/__init__.py +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/misc/database_user.py +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/misc/log.py +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/misc/path_builder.py +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/misc/utils.py +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/objects/__init__.py +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/objects/benefits/__init__.py +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/objects/benefits/benefits.py +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/objects/events/__init__.py +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/objects/events/event_factory.py +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/objects/events/event_set.py +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/objects/events/events.py +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/objects/events/historical.py +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/objects/events/hurricane.py +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/objects/events/synthetic.py +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/objects/forcing/__init__.py +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/objects/forcing/csv.py +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/objects/forcing/discharge.py +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/objects/forcing/forcing.py +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/objects/forcing/forcing_factory.py +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/objects/forcing/meteo_handler.py +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/objects/forcing/netcdf.py +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/objects/forcing/plotting.py +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/objects/forcing/rainfall.py +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/objects/forcing/tide_gauge.py +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/objects/forcing/time_frame.py +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/objects/forcing/timeseries.py +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/objects/forcing/unit_system.py +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/objects/forcing/waterlevels.py +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/objects/forcing/wind.py +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/objects/measures/__init__.py +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/objects/measures/measure_factory.py +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/objects/measures/measures.py +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/objects/object_model.py +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/objects/projections/__init__.py +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/objects/scenarios/__init__.py +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/objects/scenarios/scenarios.py +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/objects/strategies/__init__.py +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/objects/strategies/strategies.py +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/workflows/__init__.py +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/workflows/floodmap.py +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt/workflows/scenario_runner.py +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt.egg-info/SOURCES.txt +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt.egg-info/dependency_links.txt +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt.egg-info/not-zip-safe +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/flood_adapt.egg-info/top_level.txt +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/setup.cfg +0 -0
- {flood_adapt-0.3.7 → flood_adapt-0.3.9}/tests/test_flood_adapt.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: flood-adapt
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.9
|
|
4
4
|
Summary: A software package support system which can be used to assess the benefits and costs of flood resilience measures
|
|
5
5
|
Author-email: Gundula Winter <Gundula.Winter@deltares.nl>, Panos Athanasiou <Panos.Athanasiou@deltares.nl>, Frederique de Groen <Frederique.deGroen@deltares.nl>, Tim de Wilde <Tim.deWilde@deltares.nl>, Julian Hofer <Julian.Hofer@deltares.nl>, Daley Adrichem <Daley.Adrichem@deltares.nl>, Luuk Blom <Luuk.Blom@deltares.nl>
|
|
6
6
|
License: GNU GENERAL PUBLIC LICENSE
|
|
@@ -728,6 +728,8 @@ Requires-Dist: sphinx-rtd-theme<4.0,>=3.0; extra == "docs"
|
|
|
728
728
|
Requires-Dist: regex<2025.0,>=2024.11; extra == "docs"
|
|
729
729
|
Requires-Dist: minio<8,>=7.2.15; extra == "docs"
|
|
730
730
|
Requires-Dist: python-dotenv<2.0,>=1.0; extra == "docs"
|
|
731
|
+
Requires-Dist: folium<1.0,>=0.19.0; extra == "docs"
|
|
732
|
+
Requires-Dist: mapclassify<3.0,>=2.8.0; extra == "docs"
|
|
731
733
|
Provides-Extra: all
|
|
732
734
|
Requires-Dist: flood-adapt[build,dev,docs]; extra == "all"
|
|
733
735
|
|
|
@@ -773,7 +775,7 @@ FloodAdapt uses a database to store, handle and organize input files, output fil
|
|
|
773
775
|
To initialize FloodAdapt and configure the database, add the following lines to the top of your script / initialize function to validate and set the environment variables:
|
|
774
776
|
```python
|
|
775
777
|
from pathlib import Path
|
|
776
|
-
from flood_adapt
|
|
778
|
+
from flood_adapt import Settings
|
|
777
779
|
|
|
778
780
|
# Usually ends in `Database` and can contain multiple sites
|
|
779
781
|
root = Path("path/to/your/database/root")
|
|
@@ -781,14 +783,17 @@ root = Path("path/to/your/database/root")
|
|
|
781
783
|
# Specifies which site to use
|
|
782
784
|
name = "database_name"
|
|
783
785
|
|
|
784
|
-
#
|
|
785
|
-
|
|
786
|
+
# Define the paths to the model kernel binaries
|
|
787
|
+
sfincs_bin = Path("path/to/your/sfincs/bin.exe")
|
|
788
|
+
fiat_bin = Path("path/to/your/fiat/bin.exe")
|
|
786
789
|
|
|
787
790
|
# Validate and set environment variables
|
|
788
791
|
Settings(
|
|
789
792
|
DATABASE_ROOT=root,
|
|
790
793
|
DATABASE_NAME=name,
|
|
791
|
-
|
|
794
|
+
SFINCS_BIN_PATH=sfincs_bin,
|
|
795
|
+
FIAT_BIN_PATH=fiat_path,
|
|
796
|
+
VALIDATE_BINARIES=True,
|
|
792
797
|
)
|
|
793
798
|
```
|
|
794
799
|
|
|
@@ -40,7 +40,7 @@ FloodAdapt uses a database to store, handle and organize input files, output fil
|
|
|
40
40
|
To initialize FloodAdapt and configure the database, add the following lines to the top of your script / initialize function to validate and set the environment variables:
|
|
41
41
|
```python
|
|
42
42
|
from pathlib import Path
|
|
43
|
-
from flood_adapt
|
|
43
|
+
from flood_adapt import Settings
|
|
44
44
|
|
|
45
45
|
# Usually ends in `Database` and can contain multiple sites
|
|
46
46
|
root = Path("path/to/your/database/root")
|
|
@@ -48,14 +48,17 @@ root = Path("path/to/your/database/root")
|
|
|
48
48
|
# Specifies which site to use
|
|
49
49
|
name = "database_name"
|
|
50
50
|
|
|
51
|
-
#
|
|
52
|
-
|
|
51
|
+
# Define the paths to the model kernel binaries
|
|
52
|
+
sfincs_bin = Path("path/to/your/sfincs/bin.exe")
|
|
53
|
+
fiat_bin = Path("path/to/your/fiat/bin.exe")
|
|
53
54
|
|
|
54
55
|
# Validate and set environment variables
|
|
55
56
|
Settings(
|
|
56
57
|
DATABASE_ROOT=root,
|
|
57
58
|
DATABASE_NAME=name,
|
|
58
|
-
|
|
59
|
+
SFINCS_BIN_PATH=sfincs_bin,
|
|
60
|
+
FIAT_BIN_PATH=fiat_path,
|
|
61
|
+
VALIDATE_BINARIES=True,
|
|
59
62
|
)
|
|
60
63
|
```
|
|
61
64
|
|
|
@@ -85,7 +85,7 @@ class FiatAdapter(IImpactAdapter):
|
|
|
85
85
|
# TODO deal with all the relative paths for the files used
|
|
86
86
|
# TODO IImpactAdapter and general Adapter class should NOT use the database
|
|
87
87
|
|
|
88
|
-
_model: FiatModel
|
|
88
|
+
_model: Optional[FiatModel] = None
|
|
89
89
|
config: Optional[FiatConfigModel] = None
|
|
90
90
|
exe_path: Optional[os.PathLike] = None
|
|
91
91
|
fiat_columns: FiatColumns
|
|
@@ -106,20 +106,27 @@ class FiatAdapter(IImpactAdapter):
|
|
|
106
106
|
self.config_base_path = config_base_path
|
|
107
107
|
self.exe_path = exe_path
|
|
108
108
|
self.delete_crashed_runs = delete_crashed_runs
|
|
109
|
-
self.
|
|
110
|
-
self._model.read()
|
|
109
|
+
self._model_root = str(model_root.resolve())
|
|
111
110
|
self.fiat_columns = _FIAT_COLUMNS
|
|
112
111
|
self.impact_columns = _IMPACT_COLUMNS # columns of FA impact output
|
|
113
112
|
|
|
113
|
+
@property
|
|
114
|
+
def model(self) -> FiatModel:
|
|
115
|
+
"""Lazily load and cache the FiatModel."""
|
|
116
|
+
if self._model is None:
|
|
117
|
+
self._model = FiatModel(root=self._model_root, mode="r")
|
|
118
|
+
self._model.read()
|
|
119
|
+
return self._model
|
|
120
|
+
|
|
114
121
|
@property
|
|
115
122
|
def model_root(self):
|
|
116
|
-
return Path(self.
|
|
123
|
+
return Path(self.model.root)
|
|
117
124
|
|
|
118
125
|
@property
|
|
119
126
|
def damage_types(self):
|
|
120
127
|
"""Get the damage types that are present in the exposure."""
|
|
121
128
|
types = []
|
|
122
|
-
for col in self.
|
|
129
|
+
for col in self.model.exposure.exposure_db.columns:
|
|
123
130
|
if matches_pattern(col, self.fiat_columns.damage_function):
|
|
124
131
|
name = extract_variables(col, self.fiat_columns.damage_function)["name"]
|
|
125
132
|
types.append(name)
|
|
@@ -127,9 +134,9 @@ class FiatAdapter(IImpactAdapter):
|
|
|
127
134
|
|
|
128
135
|
def read(self, path: Path) -> None:
|
|
129
136
|
"""Read the fiat model from the current model root."""
|
|
130
|
-
if Path(self.
|
|
131
|
-
self.
|
|
132
|
-
self.
|
|
137
|
+
if Path(self.model.root).resolve() != Path(path).resolve():
|
|
138
|
+
self.model.set_root(root=str(path), mode="r")
|
|
139
|
+
self.model.read()
|
|
133
140
|
|
|
134
141
|
def write(self, path_out: Union[str, os.PathLike], overwrite: bool = True) -> None:
|
|
135
142
|
"""Write the fiat model configuration to a directory."""
|
|
@@ -141,8 +148,8 @@ class FiatAdapter(IImpactAdapter):
|
|
|
141
148
|
|
|
142
149
|
write_mode = "w+" if overwrite else "w"
|
|
143
150
|
with cd(path_out):
|
|
144
|
-
self.
|
|
145
|
-
self.
|
|
151
|
+
self.model.set_root(root=str(path_out), mode=write_mode)
|
|
152
|
+
self.model.write()
|
|
146
153
|
|
|
147
154
|
def close_files(self):
|
|
148
155
|
"""Close all open files and clean up file handles."""
|
|
@@ -206,7 +213,7 @@ class FiatAdapter(IImpactAdapter):
|
|
|
206
213
|
True if fiat has run, False if something went wrong
|
|
207
214
|
"""
|
|
208
215
|
log_file = self.model_root.joinpath(
|
|
209
|
-
self.
|
|
216
|
+
self.model.config["output"]["path"], "fiat.log"
|
|
210
217
|
)
|
|
211
218
|
if not log_file.exists():
|
|
212
219
|
return False
|
|
@@ -365,13 +372,13 @@ class FiatAdapter(IImpactAdapter):
|
|
|
365
372
|
The contents of the output CSV file.
|
|
366
373
|
"""
|
|
367
374
|
# Get output path
|
|
368
|
-
outputs_path = self.model_root.joinpath(self.
|
|
375
|
+
outputs_path = self.model_root.joinpath(self.model.config["output"]["path"])
|
|
369
376
|
|
|
370
377
|
# Get all csvs and concatenate them in a single table
|
|
371
378
|
csv_outputs_df = []
|
|
372
|
-
for output_csv in self.
|
|
379
|
+
for output_csv in self.model.config["output"]["csv"]:
|
|
373
380
|
csv_path = outputs_path.joinpath(
|
|
374
|
-
self.
|
|
381
|
+
self.model.config["output"]["csv"][output_csv]
|
|
375
382
|
)
|
|
376
383
|
output_csv_df = pd.read_csv(csv_path)
|
|
377
384
|
csv_outputs_df.append(output_csv_df)
|
|
@@ -700,9 +707,9 @@ class FiatAdapter(IImpactAdapter):
|
|
|
700
707
|
self.logger.info(f"Setting hazard to the {map_type} map {map_fn}")
|
|
701
708
|
# Add the floodmap data to a data catalog with the unit conversion
|
|
702
709
|
wl_current_units = us.UnitfulLength(value=1.0, units=units)
|
|
703
|
-
conversion_factor = wl_current_units.convert(self.
|
|
710
|
+
conversion_factor = wl_current_units.convert(self.model.exposure.unit)
|
|
704
711
|
|
|
705
|
-
self.
|
|
712
|
+
self.model.setup_hazard(
|
|
706
713
|
map_fn=map_fn,
|
|
707
714
|
map_type=map_type,
|
|
708
715
|
rp=None,
|
|
@@ -737,29 +744,29 @@ class FiatAdapter(IImpactAdapter):
|
|
|
737
744
|
# Get columns that include max damage
|
|
738
745
|
damage_cols = [
|
|
739
746
|
c
|
|
740
|
-
for c in self.
|
|
747
|
+
for c in self.model.exposure.exposure_db.columns
|
|
741
748
|
if matches_pattern(c, self.fiat_columns.max_potential_damage)
|
|
742
749
|
]
|
|
743
750
|
|
|
744
751
|
# Get objects that are buildings (using site info)
|
|
745
|
-
buildings_rows = ~self.
|
|
752
|
+
buildings_rows = ~self.model.exposure.exposure_db[
|
|
746
753
|
self.fiat_columns.primary_object_type
|
|
747
754
|
].isin(self.config.non_building_names)
|
|
748
755
|
|
|
749
756
|
# If ids are given use that as an additional filter
|
|
750
757
|
if ids:
|
|
751
|
-
buildings_rows = buildings_rows & self.
|
|
758
|
+
buildings_rows = buildings_rows & self.model.exposure.exposure_db[
|
|
752
759
|
self.fiat_columns.object_id
|
|
753
760
|
].isin(ids)
|
|
754
761
|
|
|
755
762
|
# Update columns using economic growth value
|
|
756
|
-
updated_max_pot_damage = self.
|
|
763
|
+
updated_max_pot_damage = self.model.exposure.exposure_db.copy()
|
|
757
764
|
updated_max_pot_damage.loc[buildings_rows, damage_cols] *= (
|
|
758
765
|
1.0 + economic_growth / 100.0
|
|
759
766
|
)
|
|
760
767
|
|
|
761
768
|
# update fiat model
|
|
762
|
-
self.
|
|
769
|
+
self.model.exposure.update_max_potential_damage(
|
|
763
770
|
updated_max_potential_damages=updated_max_pot_damage
|
|
764
771
|
)
|
|
765
772
|
|
|
@@ -784,29 +791,29 @@ class FiatAdapter(IImpactAdapter):
|
|
|
784
791
|
# Get columns that include max damage
|
|
785
792
|
damage_cols = [
|
|
786
793
|
c
|
|
787
|
-
for c in self.
|
|
794
|
+
for c in self.model.exposure.exposure_db.columns
|
|
788
795
|
if matches_pattern(c, self.fiat_columns.max_potential_damage)
|
|
789
796
|
]
|
|
790
797
|
|
|
791
798
|
# Get objects that are buildings (using site info)
|
|
792
|
-
buildings_rows = ~self.
|
|
799
|
+
buildings_rows = ~self.model.exposure.exposure_db[
|
|
793
800
|
self.fiat_columns.primary_object_type
|
|
794
801
|
].isin(self.config.non_building_names)
|
|
795
802
|
|
|
796
803
|
# If ids are given use that as an additional filter
|
|
797
804
|
if ids:
|
|
798
|
-
buildings_rows = buildings_rows & self.
|
|
805
|
+
buildings_rows = buildings_rows & self.model.exposure.exposure_db[
|
|
799
806
|
self.fiat_columns.object_id
|
|
800
807
|
].isin(ids)
|
|
801
808
|
|
|
802
809
|
# Update columns using economic growth value
|
|
803
|
-
updated_max_pot_damage = self.
|
|
810
|
+
updated_max_pot_damage = self.model.exposure.exposure_db.copy()
|
|
804
811
|
updated_max_pot_damage.loc[buildings_rows, damage_cols] *= (
|
|
805
812
|
1.0 + population_growth / 100.0
|
|
806
813
|
)
|
|
807
814
|
|
|
808
815
|
# update fiat model
|
|
809
|
-
self.
|
|
816
|
+
self.model.exposure.update_max_potential_damage(
|
|
810
817
|
updated_max_potential_damages=updated_max_pot_damage
|
|
811
818
|
)
|
|
812
819
|
|
|
@@ -841,7 +848,7 @@ class FiatAdapter(IImpactAdapter):
|
|
|
841
848
|
If `elevation_type` is not 'floodmap' or 'datum'.
|
|
842
849
|
"""
|
|
843
850
|
self.logger.info(
|
|
844
|
-
f"Applying population growth of {population_growth} %, by creating a new development area using the geometries from {area_path} and a ground floor height of {ground_floor_height} {self.
|
|
851
|
+
f"Applying population growth of {population_growth} %, by creating a new development area using the geometries from {area_path} and a ground floor height of {ground_floor_height} {self.model.exposure.unit} above '{elevation_type}'."
|
|
845
852
|
)
|
|
846
853
|
# Get reference type to align with hydromt
|
|
847
854
|
if elevation_type == "floodmap":
|
|
@@ -870,12 +877,12 @@ class FiatAdapter(IImpactAdapter):
|
|
|
870
877
|
]
|
|
871
878
|
new_dev_geom_name = Path(self.config.new_development_file_name).stem
|
|
872
879
|
# Use hydromt function
|
|
873
|
-
self.
|
|
880
|
+
self.model.exposure.setup_new_composite_areas(
|
|
874
881
|
percent_growth=population_growth,
|
|
875
882
|
geom_file=Path(area_path),
|
|
876
883
|
ground_floor_height=ground_floor_height,
|
|
877
884
|
damage_types=self.damage_types,
|
|
878
|
-
vulnerability=self.
|
|
885
|
+
vulnerability=self.model.vulnerability,
|
|
879
886
|
ground_elevation=ground_elevation,
|
|
880
887
|
aggregation_area_fn=aggregation_areas,
|
|
881
888
|
attribute_names=attribute_names,
|
|
@@ -944,7 +951,7 @@ class FiatAdapter(IImpactAdapter):
|
|
|
944
951
|
path_ref = self.config_base_path.joinpath(self.config.bfe.geom)
|
|
945
952
|
height_reference = "geom"
|
|
946
953
|
# Use hydromt function
|
|
947
|
-
self.
|
|
954
|
+
self.model.exposure.raise_ground_floor_height(
|
|
948
955
|
raise_by=elevate.elevation.value,
|
|
949
956
|
objectids=objectids,
|
|
950
957
|
height_reference=height_reference,
|
|
@@ -954,7 +961,7 @@ class FiatAdapter(IImpactAdapter):
|
|
|
954
961
|
|
|
955
962
|
elif elevate.elevation.type == "datum":
|
|
956
963
|
# Use hydromt function
|
|
957
|
-
self.
|
|
964
|
+
self.model.exposure.raise_ground_floor_height(
|
|
958
965
|
raise_by=elevate.elevation.value,
|
|
959
966
|
objectids=objectids,
|
|
960
967
|
height_reference="datum",
|
|
@@ -979,30 +986,28 @@ class FiatAdapter(IImpactAdapter):
|
|
|
979
986
|
# Get columns that include max damage
|
|
980
987
|
damage_cols = [
|
|
981
988
|
c
|
|
982
|
-
for c in self.
|
|
989
|
+
for c in self.model.exposure.exposure_db.columns
|
|
983
990
|
if matches_pattern(c, self.fiat_columns.max_potential_damage)
|
|
984
991
|
]
|
|
985
992
|
|
|
986
993
|
# Get objects that are buildings (using site info)
|
|
987
|
-
buildings_rows = ~self.
|
|
994
|
+
buildings_rows = ~self.model.exposure.exposure_db[
|
|
988
995
|
self.fiat_columns.primary_object_type
|
|
989
996
|
].isin(self.config.non_building_names)
|
|
990
997
|
|
|
991
998
|
# Get rows that are affected
|
|
992
999
|
objectids = self.get_object_ids(buyout)
|
|
993
1000
|
rows = (
|
|
994
|
-
self.
|
|
995
|
-
objectids
|
|
996
|
-
)
|
|
1001
|
+
self.model.exposure.exposure_db[self.fiat_columns.object_id].isin(objectids)
|
|
997
1002
|
& buildings_rows
|
|
998
1003
|
)
|
|
999
1004
|
|
|
1000
1005
|
# Update columns
|
|
1001
|
-
updated_max_pot_damage = self.
|
|
1006
|
+
updated_max_pot_damage = self.model.exposure.exposure_db.copy()
|
|
1002
1007
|
updated_max_pot_damage.loc[rows, damage_cols] *= 0
|
|
1003
1008
|
|
|
1004
1009
|
# update fiat model
|
|
1005
|
-
self.
|
|
1010
|
+
self.model.exposure.update_max_potential_damage(
|
|
1006
1011
|
updated_max_potential_damages=updated_max_pot_damage
|
|
1007
1012
|
)
|
|
1008
1013
|
|
|
@@ -1023,11 +1028,11 @@ class FiatAdapter(IImpactAdapter):
|
|
|
1023
1028
|
objectids = self.get_object_ids(floodproof)
|
|
1024
1029
|
|
|
1025
1030
|
# Use hydromt function
|
|
1026
|
-
self.
|
|
1031
|
+
self.model.exposure.truncate_damage_function(
|
|
1027
1032
|
objectids=objectids,
|
|
1028
1033
|
floodproof_to=floodproof.elevation.value,
|
|
1029
1034
|
damage_function_types=self.damage_types,
|
|
1030
|
-
vulnerability=self.
|
|
1035
|
+
vulnerability=self.model.vulnerability,
|
|
1031
1036
|
)
|
|
1032
1037
|
|
|
1033
1038
|
# STATIC METHODS
|
|
@@ -1046,11 +1051,11 @@ class FiatAdapter(IImpactAdapter):
|
|
|
1046
1051
|
ValueError
|
|
1047
1052
|
If the FIAT model does not have an exposure database initialized.
|
|
1048
1053
|
"""
|
|
1049
|
-
if self.
|
|
1054
|
+
if self.model.exposure is None:
|
|
1050
1055
|
raise ValueError(
|
|
1051
1056
|
"FIAT model does not have exposure, make sure your model has been initialized."
|
|
1052
1057
|
)
|
|
1053
|
-
gdf_0 = self.
|
|
1058
|
+
gdf_0 = self.model.exposure.select_objects(
|
|
1054
1059
|
primary_object_type="ALL",
|
|
1055
1060
|
non_building_names=self.config.non_building_names,
|
|
1056
1061
|
return_gdf=True,
|
|
@@ -1081,7 +1086,7 @@ class FiatAdapter(IImpactAdapter):
|
|
|
1081
1086
|
ValueError
|
|
1082
1087
|
If no property types are found in the FIAT model.
|
|
1083
1088
|
"""
|
|
1084
|
-
types = self.
|
|
1089
|
+
types = self.model.exposure.get_primary_object_type()
|
|
1085
1090
|
if types is None:
|
|
1086
1091
|
raise ValueError("No property types found in the FIAT model.")
|
|
1087
1092
|
types.append("all") # Add "all" type for using as identifier
|
|
@@ -1104,7 +1109,7 @@ class FiatAdapter(IImpactAdapter):
|
|
|
1104
1109
|
A list of IDs for all buildings in the FIAT model.
|
|
1105
1110
|
"""
|
|
1106
1111
|
# Get ids of existing buildings
|
|
1107
|
-
ids = self.
|
|
1112
|
+
ids = self.model.exposure.get_object_ids(
|
|
1108
1113
|
"all", non_building_names=self.config.non_building_names
|
|
1109
1114
|
)
|
|
1110
1115
|
return ids
|
|
@@ -1145,7 +1150,7 @@ class FiatAdapter(IImpactAdapter):
|
|
|
1145
1150
|
polygon_file = None
|
|
1146
1151
|
|
|
1147
1152
|
# use the hydromt-fiat method to the ids
|
|
1148
|
-
ids = self.
|
|
1153
|
+
ids = self.model.exposure.get_object_ids(
|
|
1149
1154
|
selection_type=measure.selection_type,
|
|
1150
1155
|
property_type=measure.property_type,
|
|
1151
1156
|
non_building_names=self.config.non_building_names,
|
|
@@ -1407,7 +1412,7 @@ class FiatAdapter(IImpactAdapter):
|
|
|
1407
1412
|
self.logger.info("Calculating impacts at a building footprint scale")
|
|
1408
1413
|
|
|
1409
1414
|
# Read the existing building points
|
|
1410
|
-
buildings = self.
|
|
1415
|
+
buildings = self.model.exposure.select_objects(
|
|
1411
1416
|
primary_object_type="ALL",
|
|
1412
1417
|
non_building_names=self.config.non_building_names,
|
|
1413
1418
|
return_gdf=True,
|
|
@@ -12,7 +12,6 @@ import hydromt_sfincs.utils as utils
|
|
|
12
12
|
import numpy as np
|
|
13
13
|
import pandas as pd
|
|
14
14
|
import plotly.express as px
|
|
15
|
-
import plotly.graph_objects as go
|
|
16
15
|
import pyproj
|
|
17
16
|
import shapely
|
|
18
17
|
import xarray as xr
|
|
@@ -201,7 +200,7 @@ class SfincsAdapter(IHazardAdapter):
|
|
|
201
200
|
with cd(path):
|
|
202
201
|
self.logger.info(f"Running SFINCS in {path}")
|
|
203
202
|
process = subprocess.run(
|
|
204
|
-
str(Settings().
|
|
203
|
+
str(Settings().sfincs_bin_path),
|
|
205
204
|
stdout=subprocess.PIPE,
|
|
206
205
|
stderr=subprocess.PIPE,
|
|
207
206
|
text=True,
|
|
@@ -677,7 +676,8 @@ class SfincsAdapter(IHazardAdapter):
|
|
|
677
676
|
)
|
|
678
677
|
|
|
679
678
|
event = self.database.events.get(scenario.event)
|
|
680
|
-
self.
|
|
679
|
+
if self.settings.obs_point[ii].name == self.settings.tide_gauge.name:
|
|
680
|
+
self._add_tide_gauge_plot(fig, event, units=gui_units)
|
|
681
681
|
|
|
682
682
|
# write html to results folder
|
|
683
683
|
station_name = gdf.iloc[ii]["Name"]
|
|
@@ -686,26 +686,27 @@ class SfincsAdapter(IHazardAdapter):
|
|
|
686
686
|
|
|
687
687
|
def add_obs_points(self):
|
|
688
688
|
"""Add observation points provided in the site toml to SFINCS model."""
|
|
689
|
-
if self.settings.obs_point is
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
obs_points = self.settings.obs_point
|
|
693
|
-
names = []
|
|
694
|
-
lat = []
|
|
695
|
-
lon = []
|
|
696
|
-
for pt in obs_points:
|
|
697
|
-
names.append(pt.name)
|
|
698
|
-
lat.append(pt.lat)
|
|
699
|
-
lon.append(pt.lon)
|
|
689
|
+
if self.settings.obs_point is None:
|
|
690
|
+
return
|
|
691
|
+
self.logger.info("Adding observation points to the overland flood model")
|
|
700
692
|
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
693
|
+
obs_points = self.settings.obs_point
|
|
694
|
+
names = []
|
|
695
|
+
lat = []
|
|
696
|
+
lon = []
|
|
697
|
+
for pt in obs_points:
|
|
698
|
+
names.append(pt.name)
|
|
699
|
+
lat.append(pt.lat)
|
|
700
|
+
lon.append(pt.lon)
|
|
701
|
+
|
|
702
|
+
# create GeoDataFrame from obs_points in site file
|
|
703
|
+
df = pd.DataFrame({"name": names})
|
|
704
|
+
gdf = gpd.GeoDataFrame(
|
|
705
|
+
df, geometry=gpd.points_from_xy(lon, lat), crs="EPSG:4326"
|
|
706
|
+
)
|
|
706
707
|
|
|
707
|
-
|
|
708
|
-
|
|
708
|
+
# Add locations to SFINCS file
|
|
709
|
+
self._model.setup_observation_points(locations=gdf, merge=False)
|
|
709
710
|
|
|
710
711
|
def get_wl_df_from_offshore_his_results(self) -> pd.DataFrame:
|
|
711
712
|
"""Create a pd.Dataframe with waterlevels from the offshore model at the bnd locations of the overland model.
|
|
@@ -1840,11 +1841,7 @@ class SfincsAdapter(IHazardAdapter):
|
|
|
1840
1841
|
|
|
1841
1842
|
# If data is available, add to plot
|
|
1842
1843
|
fig.add_trace(
|
|
1843
|
-
|
|
1844
|
-
x=pd.DatetimeIndex(df_gauge.index),
|
|
1845
|
-
y=waterlevel,
|
|
1846
|
-
line_color="#ea6404",
|
|
1847
|
-
)
|
|
1844
|
+
px.line(waterlevel, color_discrete_sequence=["#ea6404"]).data[0]
|
|
1848
1845
|
)
|
|
1849
1846
|
fig["data"][0]["name"] = "model"
|
|
1850
1847
|
fig["data"][1]["name"] = "measurement"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
from os import environ, listdir
|
|
2
2
|
from pathlib import Path
|
|
3
|
-
from
|
|
3
|
+
from typing import Optional
|
|
4
4
|
|
|
5
5
|
import tomli
|
|
6
6
|
import tomli_w
|
|
@@ -12,48 +12,6 @@ from pydantic import (
|
|
|
12
12
|
)
|
|
13
13
|
from pydantic_settings import BaseSettings, SettingsConfigDict
|
|
14
14
|
|
|
15
|
-
DEFAULT_SYSTEM_FOLDER = Path(__file__).parents[1] / "system"
|
|
16
|
-
DEFAULT_EXE_PATHS: dict[str, dict[str, Path]] = {
|
|
17
|
-
"windows": {
|
|
18
|
-
"sfincs": DEFAULT_SYSTEM_FOLDER / "win-64" / "sfincs" / "sfincs.exe",
|
|
19
|
-
"fiat": DEFAULT_SYSTEM_FOLDER / "win-64" / "fiat" / "fiat.exe",
|
|
20
|
-
},
|
|
21
|
-
"linux": {
|
|
22
|
-
"sfincs": DEFAULT_SYSTEM_FOLDER / "linux-64" / "sfincs" / "bin" / "sfincs",
|
|
23
|
-
"fiat": DEFAULT_SYSTEM_FOLDER / "linux-64" / "fiat" / "fiat",
|
|
24
|
-
},
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
def _default_exe_path(exe_name: str) -> Path:
|
|
29
|
-
"""
|
|
30
|
-
Get the default path for the given executable name based on the system type.
|
|
31
|
-
|
|
32
|
-
Parameters
|
|
33
|
-
----------
|
|
34
|
-
exe_name : str
|
|
35
|
-
The name of the executable (e.g., "sfincs", "fiat").
|
|
36
|
-
|
|
37
|
-
Returns
|
|
38
|
-
-------
|
|
39
|
-
Path
|
|
40
|
-
The default path to the executable.
|
|
41
|
-
|
|
42
|
-
Raises
|
|
43
|
-
------
|
|
44
|
-
ValueError
|
|
45
|
-
If the system type is not recognized.
|
|
46
|
-
"""
|
|
47
|
-
if system().lower() not in DEFAULT_EXE_PATHS:
|
|
48
|
-
raise ValueError(
|
|
49
|
-
f"System type '{system()}' is not recognized. Supported types are: {', '.join(DEFAULT_EXE_PATHS.keys())}."
|
|
50
|
-
)
|
|
51
|
-
if exe_name not in DEFAULT_EXE_PATHS[system().lower()]:
|
|
52
|
-
raise ValueError(
|
|
53
|
-
f"Executable name '{exe_name}' is not recognized. Supported names are: {', '.join(DEFAULT_EXE_PATHS[system().lower()].keys())}."
|
|
54
|
-
)
|
|
55
|
-
return DEFAULT_EXE_PATHS[system().lower()][exe_name]
|
|
56
|
-
|
|
57
15
|
|
|
58
16
|
class Settings(BaseSettings):
|
|
59
17
|
"""
|
|
@@ -82,19 +40,19 @@ class Settings(BaseSettings):
|
|
|
82
40
|
Attributes
|
|
83
41
|
----------
|
|
84
42
|
database_name : str
|
|
85
|
-
The name of the database.
|
|
43
|
+
The name of the database. Alias: `DATABASE_NAME` (environment variable).
|
|
86
44
|
database_root : Path
|
|
87
|
-
The root directory of the database.
|
|
45
|
+
The root directory of the database. Alias: `DATABASE_ROOT` (environment variable).
|
|
88
46
|
delete_crashed_runs : bool
|
|
89
|
-
Whether to delete crashed/corrupted runs immediately after they are detected.
|
|
90
|
-
sfincs_path : Path
|
|
91
|
-
The path to the SFINCS binary.
|
|
92
|
-
fiat_path : Path
|
|
93
|
-
The path to the FIAT binary.
|
|
47
|
+
Whether to delete crashed/corrupted runs immediately after they are detected. Alias: `DELETE_CRASHED_RUNS` (environment variable).
|
|
94
48
|
validate_allowed_forcings : bool
|
|
95
|
-
Whether to validate the forcing types and sources against the allowed forcings in the event model.
|
|
96
|
-
|
|
97
|
-
Whether to validate the existence of the paths to the SFINCS and FIAT binaries.
|
|
49
|
+
Whether to validate the forcing types and sources against the allowed forcings in the event model. Alias: `VALIDATE_ALLOWED_FORCINGS` (environment variable).
|
|
50
|
+
validate_binaries : bool
|
|
51
|
+
Whether to validate the existence of the paths to the SFINCS and FIAT binaries. Alias: `VALIDATE_BINARIES` (environment variable).
|
|
52
|
+
sfincs_bin_path : Path
|
|
53
|
+
The path to the SFINCS binary. Alias: `SFINCS_BIN_PATH` (environment variable).
|
|
54
|
+
fiat_bin_path : Path
|
|
55
|
+
The path to the FIAT binary. Alias: `FIAT_BIN_PATH` (environment variable).
|
|
98
56
|
|
|
99
57
|
Properties
|
|
100
58
|
----------
|
|
@@ -133,22 +91,22 @@ class Settings(BaseSettings):
|
|
|
133
91
|
description="Whether to validate the forcing types and sources against the allowed forcings in the event model.",
|
|
134
92
|
exclude=True,
|
|
135
93
|
)
|
|
136
|
-
|
|
94
|
+
validate_binaries: bool = Field(
|
|
137
95
|
alias="VALIDATE_BINARIES", # environment variable: VALIDATE_BINARIES
|
|
138
96
|
default=False,
|
|
139
97
|
description="Whether to validate the existence of the paths to the SFINCS and FIAT binaries.",
|
|
140
98
|
exclude=True,
|
|
141
99
|
)
|
|
142
100
|
|
|
143
|
-
|
|
144
|
-
default=
|
|
101
|
+
sfincs_bin_path: Optional[Path] = Field(
|
|
102
|
+
default=None,
|
|
145
103
|
alias="SFINCS_BIN_PATH", # environment variable: SFINCS_BIN_PATH
|
|
146
104
|
description="The path of the sfincs binary.",
|
|
147
105
|
exclude=True,
|
|
148
106
|
)
|
|
149
107
|
|
|
150
|
-
|
|
151
|
-
default=
|
|
108
|
+
fiat_bin_path: Optional[Path] = Field(
|
|
109
|
+
default=None,
|
|
152
110
|
alias="FIAT_BIN_PATH", # environment variable: FIAT_BIN_PATH
|
|
153
111
|
description="The path of the fiat binary.",
|
|
154
112
|
exclude=True,
|
|
@@ -162,7 +120,7 @@ class Settings(BaseSettings):
|
|
|
162
120
|
@model_validator(mode="after")
|
|
163
121
|
def validate_settings(self):
|
|
164
122
|
self._validate_database_path()
|
|
165
|
-
if self.
|
|
123
|
+
if self.validate_binaries:
|
|
166
124
|
self._validate_fiat_path()
|
|
167
125
|
self._validate_sfincs_path()
|
|
168
126
|
self._update_environment_variables()
|
|
@@ -171,21 +129,21 @@ class Settings(BaseSettings):
|
|
|
171
129
|
def _update_environment_variables(self):
|
|
172
130
|
environ["DATABASE_ROOT"] = str(self.database_root)
|
|
173
131
|
environ["DATABASE_NAME"] = self.database_name
|
|
174
|
-
environ["SFINCS_BIN_PATH"] = str(self.sfincs_path)
|
|
175
|
-
environ["FIAT_BIN_PATH"] = str(self.fiat_path)
|
|
176
|
-
environ["SFINCS_PATH"] = str(self.sfincs_path)
|
|
177
|
-
environ["FIAT_PATH"] = str(self.fiat_path)
|
|
178
132
|
|
|
179
133
|
if self.delete_crashed_runs:
|
|
180
134
|
environ["DELETE_CRASHED_RUNS"] = str(self.delete_crashed_runs)
|
|
181
135
|
else:
|
|
182
136
|
environ.pop("DELETE_CRASHED_RUNS", None)
|
|
137
|
+
|
|
183
138
|
if self.validate_allowed_forcings:
|
|
184
139
|
environ["VALIDATE_ALLOWED_FORCINGS"] = str(self.validate_allowed_forcings)
|
|
185
140
|
else:
|
|
186
141
|
environ.pop("VALIDATE_ALLOWED_FORCINGS", None)
|
|
187
|
-
|
|
188
|
-
|
|
142
|
+
|
|
143
|
+
if self.validate_binaries:
|
|
144
|
+
environ["VALIDATE_BINARIES"] = str(self.validate_binaries)
|
|
145
|
+
environ["SFINCS_BIN_PATH"] = str(self.sfincs_bin_path)
|
|
146
|
+
environ["FIAT_BIN_PATH"] = str(self.fiat_bin_path)
|
|
189
147
|
else:
|
|
190
148
|
environ.pop("VALIDATE_BINARIES", None)
|
|
191
149
|
|
|
@@ -224,13 +182,13 @@ class Settings(BaseSettings):
|
|
|
224
182
|
return self
|
|
225
183
|
|
|
226
184
|
def _validate_sfincs_path(self):
|
|
227
|
-
if not self.
|
|
228
|
-
raise ValueError(f"SFINCS binary {self.
|
|
185
|
+
if not self.sfincs_bin_path.exists():
|
|
186
|
+
raise ValueError(f"SFINCS binary {self.sfincs_bin_path} does not exist.")
|
|
229
187
|
return self
|
|
230
188
|
|
|
231
189
|
def _validate_fiat_path(self):
|
|
232
|
-
if not self.
|
|
233
|
-
raise ValueError(f"FIAT binary {self.
|
|
190
|
+
if not self.fiat_bin_path.exists():
|
|
191
|
+
raise ValueError(f"FIAT binary {self.fiat_bin_path} does not exist.")
|
|
234
192
|
return self
|
|
235
193
|
|
|
236
194
|
@field_serializer("database_root", "database_path")
|
|
@@ -284,7 +242,7 @@ class Settings(BaseSettings):
|
|
|
284
242
|
tomli_w.dump(
|
|
285
243
|
self.model_dump(
|
|
286
244
|
by_alias=True,
|
|
287
|
-
exclude={"
|
|
245
|
+
exclude={"sfincs_bin_path", "fiat_bin_path", "database_path"},
|
|
288
246
|
),
|
|
289
247
|
f,
|
|
290
248
|
)
|
|
@@ -209,7 +209,7 @@ class FiatModel(BaseModel):
|
|
|
209
209
|
config: FiatConfigModel
|
|
210
210
|
|
|
211
211
|
benefits: Optional[BenefitsModel] = None
|
|
212
|
-
risk: Optional[RiskModel] =
|
|
212
|
+
risk: Optional[RiskModel] = RiskModel()
|
|
213
213
|
|
|
214
214
|
@staticmethod
|
|
215
215
|
def read_toml(path: Path) -> "FiatModel":
|