diff --git a/flood_adapt/dbs_classes/dbs_scenario.py b/flood_adapt/dbs_classes/dbs_scenario.py index a02ed23ed..12b2cb501 100644 --- a/flood_adapt/dbs_classes/dbs_scenario.py +++ b/flood_adapt/dbs_classes/dbs_scenario.py @@ -2,7 +2,6 @@ from typing import Any from flood_adapt.dbs_classes.dbs_template import DbsTemplate -from flood_adapt.object_model.benefit import Benefit from flood_adapt.object_model.interface.scenarios import IScenario from flood_adapt.object_model.scenario import Scenario @@ -110,8 +109,8 @@ def check_higher_level_usage(self, name: str) -> list[str]: """ # Get all the benefits benefits = [ - Benefit.load_file(path) - for path in self._database.benefits.list_objects()["path"] + self._database.benefits.get(name) + for name in self._database.benefits.list_objects()["name"] ] # Check in which benefits this scenario is used diff --git a/flood_adapt/dbs_classes/dbs_static.py b/flood_adapt/dbs_classes/dbs_static.py index 6347d5d8a..6b2accbde 100644 --- a/flood_adapt/dbs_classes/dbs_static.py +++ b/flood_adapt/dbs_classes/dbs_static.py @@ -52,7 +52,7 @@ def get_aggregation_areas(self) -> dict: aggregation_areas = {} for aggr_dict in self._database.site.attrs.fiat.aggregation: aggregation_areas[aggr_dict.name] = gpd.read_file( - self._database.static_path / "site" / aggr_dict.file, + self._database.static_path / aggr_dict.file, engine="pyogrio", ).to_crs(4326) # Use always the same column name for name labels diff --git a/flood_adapt/integrator/fiat_adapter.py b/flood_adapt/integrator/fiat_adapter.py index 804c5bac4..079a875ee 100644 --- a/flood_adapt/integrator/fiat_adapter.py +++ b/flood_adapt/integrator/fiat_adapter.py @@ -40,16 +40,13 @@ def __init__(self, model_root: str, database_path: str) -> None: if self.site.attrs.fiat.bfe.table: self.bfe["mode"] = "table" self.bfe["table"] = ( - Path(database_path) - / "static" - / "site" - / self.site.attrs.fiat.bfe.table + Path(database_path) / "static" / self.site.attrs.fiat.bfe.table ) else: self.bfe["mode"] = "geom" # Map is always needed! self.bfe["geom"] = ( - Path(database_path) / "static" / "site" / self.site.attrs.fiat.bfe.geom + Path(database_path) / "static" / self.site.attrs.fiat.bfe.geom ) self.bfe["name"] = self.site.attrs.fiat.bfe.field_name diff --git a/flood_adapt/integrator/sfincs_adapter.py b/flood_adapt/integrator/sfincs_adapter.py index 5042e68d5..abbf7fc0e 100644 --- a/flood_adapt/integrator/sfincs_adapter.py +++ b/flood_adapt/integrator/sfincs_adapter.py @@ -342,7 +342,7 @@ def add_green_infrastructure( continue # load geodataframe aggr_areas = gpd.read_file( - measure_path.parents[2] / "static" / "site" / aggr_dict.file, + measure_path.parents[2] / "static" / aggr_dict.file, engine="pyogrio", ).to_crs(4326) # keep only aggregation area chosen diff --git a/flood_adapt/object_model/benefit.py b/flood_adapt/object_model/benefit.py index e4bc55ca5..0143ea0c2 100644 --- a/flood_adapt/object_model/benefit.py +++ b/flood_adapt/object_model/benefit.py @@ -372,8 +372,8 @@ def cba_aggregation(self): for i, n in enumerate(self.site_info.attrs.fiat.aggregation) if n.name == aggr_name ][0] - aggr_areas_path = self.site_toml_path.parent.joinpath( - self.site_info.attrs.fiat.aggregation[ind].file + aggr_areas_path = self.database_input_path.parent.joinpath( + "static", self.site_info.attrs.fiat.aggregation[ind].file ) aggr_areas = gpd.read_file(aggr_areas_path, engine="pyogrio") diff --git a/flood_adapt/object_model/direct_impacts.py b/flood_adapt/object_model/direct_impacts.py index 69dc5dda1..43dee4279 100644 --- a/flood_adapt/object_model/direct_impacts.py +++ b/flood_adapt/object_model/direct_impacts.py @@ -190,7 +190,7 @@ def preprocess_fiat(self): ) dem = self.database.static_path / "Dem" / self.site_info.attrs.dem.filename aggregation_areas = [ - self.database.static_path / "site" / aggr.file + self.database.static_path / aggr.file for aggr in self.site_info.attrs.fiat.aggregation ] attribute_names = [ @@ -357,7 +357,7 @@ def _create_equity(self, metrics_path): # Create Equity object equity = Equity( - census_table=self.site_toml_path.parent.joinpath( + census_table=self.database.static_path.joinpath( self.site_info.attrs.fiat.aggregation[ind].equity.census_data ), damages_table=fiat_data, @@ -420,7 +420,7 @@ def _create_aggregation(self, metrics_path): for i, n in enumerate(self.site_info.attrs.fiat.aggregation) if n.name == aggr_label ][0] - aggr_areas_path = self.site_toml_path.parent.joinpath( + aggr_areas_path = self.database.static_path.joinpath( self.site_info.attrs.fiat.aggregation[ind].file ) @@ -447,7 +447,7 @@ def _create_footprints(self, fiat_results_df): if not self.site_info.attrs.fiat.building_footprints: raise ValueError("No building footprints are provided.") # Get footprints file - footprints_path = self.site_toml_path.parent.joinpath( + footprints_path = self.database.static_path.joinpath( self.site_info.attrs.fiat.building_footprints ) # Define where footprint results are saved diff --git a/tests/test_object_model/test_site.py b/tests/test_object_model/test_site.py index 5e413b239..1f3ad9322 100644 --- a/tests/test_object_model/test_site.py +++ b/tests/test_object_model/test_site.py @@ -111,36 +111,36 @@ def test_dict(): "floodmap_type": "water_level", "non_building_names": ["road"], "damage_unit": "$", - "building_footprints": "../templates/fiat/footprints/Buildings.shp", + "building_footprints": "templates/fiat/footprints/Buildings.shp", "roads_file_name": "spatial2.gpkg", "new_development_file_name": "spatial3.gpkg", "save_simulation": "False", "svi": { - "geom": "../templates/fiat/svi/CDC_svi_2020.gpkg", + "geom": "templates/fiat/svi/CDC_svi_2020.gpkg", "field_name": "SVI", }, "bfe": { - "geom": "../bfe/bfe.geojson", - "table": "../bfe/bfe.csv", + "geom": "bfe/bfe.geojson", + "table": "bfe/bfe.csv", "field_name": "bfe", }, "aggregation": [ { "name": "aggr_lvl_1", - "file": "../templates/fiat/aggregation_areas/aggr_lvl_1.geojson", + "file": "templates/fiat/aggregation_areas/aggr_lvl_1.geojson", "field_name": "name", "equity": { - "census_data": "../templates/fiat/equity/census_data_aggr_lvl_1.csv", + "census_data": "templates/fiat/equity/census_data_aggr_lvl_1.csv", "percapitaincome_label": "PerCapitaIncome", "totalpopulation_label": "TotalPopulation", }, }, { "name": "aggr_lvl_2", - "file": "../templates/fiat/aggregation_areas/aggr_lvl_2.geojson", + "file": "templates/fiat/aggregation_areas/aggr_lvl_2.geojson", "field_name": "name", "equity": { - "census_data": "../templates/fiat/equity/census_data_aggr_lvl_2.csv", + "census_data": "templates/fiat/equity/census_data_aggr_lvl_2.csv", "percapitaincome_label": "PerCapitaIncome", "totalpopulation_label": "TotalPopulation", },