Database
dbs_classes.Database(self,
str, os.PathLike, None] = None,
database_path: Union[str] = None,
database_name: Optional[ )
Implementation of IDatabase class that holds the site information and has methods to get static data info, and all the input information.
Additionally it can manipulate (add, edit, copy and delete) any of the objects in the input.
Methods
Name | Description |
---|---|
check_benefit_scenarios | Return a dataframe with the scenarios needed for this benefit assessment run. |
cleanup | Remove corrupted scenario output. |
create_benefit_scenarios | Create any scenarios that are needed for the (cost-)benefit assessment and are not there already. |
get_aggregation | Return a dictionary with the aggregated impacts as geodataframes. |
get_aggregation_benefits | Get a dictionary with the aggregated benefits as geodataframes. |
get_building_footprints | Return a geodataframe of the impacts at the footprint level. |
get_depth_conversion | Return the flood depth conversion that is need in the gui to plot the flood map. |
get_index_path | Return the path of the index tiles which are used to connect each water level cell with the topobathy tiles. |
get_max_water_level | Return an array with the maximum water levels during an event. |
get_object_list | Get a dictionary with all the toml paths and last modification dates that exist in the database that correspond to object_type. |
get_outputs | Return a dictionary with info on the outputs that currently exist in the database. |
get_roads | Return a geodataframe of the impacts at roads. |
get_topobathy_path | Return the path of the topobathy tiles in order to create flood maps with water level maps. |
has_run_hazard | Check if there is already a simulation that has the exact same hazard component. |
interp_slr | Interpolate SLR value and reference it to the SLR reference year from the site toml. |
run_benefit | Run a (cost-)benefit analysis. |
run_scenario | Run a scenario hazard and impacts. |
shutdown | Explicitly shut down the singleton and clear all references. |
check_benefit_scenarios
dbs_classes.Database.check_benefit_scenarios(benefit: Benefit)
Return a dataframe with the scenarios needed for this benefit assessment run.
Parameters
benefit : Benefit
cleanup
dbs_classes.Database.cleanup()
Remove corrupted scenario output.
This method removes any scenario output that: - is corrupted due to unfinished runs - does not have a corresponding input
create_benefit_scenarios
dbs_classes.Database.create_benefit_scenarios(benefit: Benefit)
Create any scenarios that are needed for the (cost-)benefit assessment and are not there already.
Parameters
benefit : Benefit
get_aggregation
str) dbs_classes.Database.get_aggregation(scenario_name:
Return a dictionary with the aggregated impacts as geodataframes.
Parameters
scenario_name :
str
-
name of the scenario
Returns
:
dict
[GeoDataFrame
]-
dictionary with aggregated damages per aggregation type
get_aggregation_benefits
str) dbs_classes.Database.get_aggregation_benefits(benefit_name:
Get a dictionary with the aggregated benefits as geodataframes.
Parameters
benefit_name :
str
-
name of the benefit analysis
Returns
:
dict
[GeoDataFrame
]-
dictionary with aggregated benefits per aggregation type
get_building_footprints
str) dbs_classes.Database.get_building_footprints(scenario_name:
Return a geodataframe of the impacts at the footprint level.
Parameters
scenario_name :
str
-
name of scenario
Returns
:
GeoDataFrame
-
impacts at footprint level
get_depth_conversion
dbs_classes.Database.get_depth_conversion()
Return the flood depth conversion that is need in the gui to plot the flood map.
Returns
:
float
-
conversion factor
get_index_path
dbs_classes.Database.get_index_path()
Return the path of the index tiles which are used to connect each water level cell with the topobathy tiles.
Returns
:
str
-
path to index tiles
get_max_water_level
dbs_classes.Database.get_max_water_level(str,
scenario_name: int] = None,
return_period: Optional[ )
Return an array with the maximum water levels during an event.
Parameters
scenario_name :
str
-
name of scenario
return_period :
int
= None-
return period in years, by default None
Returns
:
np
.array
-
2D map of maximum water levels
get_object_list
dbs_classes.Database.get_object_list('projections', 'events', 'measures', 'strategies', 'scenarios', 'benefits'],
object_type: Literal[ )
Get a dictionary with all the toml paths and last modification dates that exist in the database that correspond to object_type.
Parameters
object_type :
str
-
Can be ‘projections’, ‘events’, ‘measures’, ‘strategies’ or ‘scenarios’
Returns
:
dict
[str
,Any
]-
Includes ‘path’ and ‘last_modification_date’ info
get_outputs
dbs_classes.Database.get_outputs()
Return a dictionary with info on the outputs that currently exist in the database.
Returns
:
dict
[str
,Any
]-
Includes ‘name’, ‘path’, ‘last_modification_date’ and “finished” info
get_roads
str) dbs_classes.Database.get_roads(scenario_name:
Return a geodataframe of the impacts at roads.
Parameters
scenario_name :
str
-
name of scenario
Returns
:
GeoDataFrame
-
Impacts at roads
get_topobathy_path
dbs_classes.Database.get_topobathy_path()
Return the path of the topobathy tiles in order to create flood maps with water level maps.
Returns
:
str
-
path to topobathy tiles
has_run_hazard
str) dbs_classes.Database.has_run_hazard(scenario_name:
Check if there is already a simulation that has the exact same hazard component.
If yes that is copied to avoid running the hazard model twice.
Parameters
scenario_name :
str
-
name of the scenario to check if needs to be rerun for hazard
interp_slr
str, year: float) dbs_classes.Database.interp_slr(slr_scenario:
Interpolate SLR value and reference it to the SLR reference year from the site toml.
Parameters
slr_scenario :
str
-
SLR scenario name from the coulmn names in static/slr/slr.csv
year :
float
-
year to evaluate
Returns
:
float
-
description
Raises
:
ValueError
-
if the reference year is outside of the time range in the slr.csv file
:
ValueError
-
if the year to evaluate is outside of the time range in the slr.csv file
run_benefit
str, list[str]]) dbs_classes.Database.run_benefit(benefit_name: Union[
Run a (cost-)benefit analysis.
Parameters
benefit_name :
Union
[str
,list
[str
]]-
name(s) of the benefits to run.
run_scenario
str, list[str]]) dbs_classes.Database.run_scenario(scenario_name: Union[
Run a scenario hazard and impacts.
Parameters
scenario_name :
Union
[str
,list
[str
]]-
name(s) of the scenarios to run.
Raises
:
RuntimeError
-
If an error occurs while running one of the scenarios
shutdown
dbs_classes.Database.shutdown()
Explicitly shut down the singleton and clear all references.