dbs_classes.database.Database

dbs_classes.database.Database(self, database_path=None, database_name=None)

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_depth_conversion Return the flood depth conversion that is need in the gui to plot the flood map.
get_fiat_footprints Return a geodataframe of the impacts at the footprint level.
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 database controller singleton and clear all data stored in its memory.

check_benefit_scenarios

dbs_classes.database.Database.check_benefit_scenarios(benefit)

Return a dataframe with the scenarios needed for this benefit assessment run.

Parameters

Name Type Description Default
benefit IBenefit required

cleanup

dbs_classes.database.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.Database.create_benefit_scenarios(benefit)

Create any scenarios that are needed for the (cost-)benefit assessment and are not there already.

Parameters

Name Type Description Default
benefit IBenefit required

get_aggregation

dbs_classes.database.Database.get_aggregation(scenario_name)

Return a dictionary with the aggregated impacts as geodataframes.

Parameters

Name Type Description Default
scenario_name str name of the scenario required

Returns

Name Type Description
dict[GeoDataFrame] dictionary with aggregated damages per aggregation type

get_aggregation_benefits

dbs_classes.database.Database.get_aggregation_benefits(benefit_name)

Get a dictionary with the aggregated benefits as geodataframes.

Parameters

Name Type Description Default
benefit_name str name of the benefit analysis required

Returns

Name Type Description
dict[GeoDataFrame] dictionary with aggregated benefits per aggregation type

get_depth_conversion

dbs_classes.database.Database.get_depth_conversion()

Return the flood depth conversion that is need in the gui to plot the flood map.

Returns

Name Type Description
float conversion factor

get_fiat_footprints

dbs_classes.database.Database.get_fiat_footprints(scenario_name)

Return a geodataframe of the impacts at the footprint level.

Parameters

Name Type Description Default
scenario_name str name of scenario required

Returns

Name Type Description
GeoDataFrame impacts at footprint level

get_index_path

dbs_classes.database.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

Name Type Description
str path to index tiles

get_max_water_level

dbs_classes.database.Database.get_max_water_level(
    scenario_name,
    return_period=None,
)

Return an array with the maximum water levels during an event.

Parameters

Name Type Description Default
scenario_name str name of scenario required
return_period int return period in years, by default None None

Returns

Name Type Description
np.array 2D map of maximum water levels

get_object_list

dbs_classes.database.Database.get_object_list(object_type)

Get a dictionary with all the toml paths and last modification dates that exist in the database that correspond to object_type.

Parameters

Name Type Description Default
object_type str Can be ‘projections’, ‘events’, ‘measures’, ‘strategies’ or ‘scenarios’ required

Returns

Name Type Description
dict[str, Any] Includes ‘path’ and ‘last_modification_date’ info

get_outputs

dbs_classes.database.Database.get_outputs()

Return a dictionary with info on the outputs that currently exist in the database.

Returns

Name Type Description
dict[str, Any] Includes ‘name’, ‘path’, ‘last_modification_date’ and “finished” info

get_roads

dbs_classes.database.Database.get_roads(scenario_name)

Return a geodataframe of the impacts at roads.

Parameters

Name Type Description Default
scenario_name str name of scenario required

Returns

Name Type Description
GeoDataFrame Impacts at roads

get_topobathy_path

dbs_classes.database.Database.get_topobathy_path()

Return the path of the topobathy tiles in order to create flood maps with water level maps.

Returns

Name Type Description
str path to topobathy tiles

has_run_hazard

dbs_classes.database.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

Name Type Description Default
scenario_name str name of the scenario to check if needs to be rerun for hazard required

interp_slr

dbs_classes.database.Database.interp_slr(slr_scenario, year)

Interpolate SLR value and reference it to the SLR reference year from the site toml.

Parameters

Name Type Description Default
slr_scenario str SLR scenario name from the coulmn names in static.csv required
year float year to evaluate required

Returns

Name Type Description
float description

Raises

Name Type Description
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

dbs_classes.database.Database.run_benefit(benefit_name)

Run a (cost-)benefit analysis.

Parameters

Name Type Description Default
benefit_name Union[str, list[str]] name(s) of the benefits to run. required

run_scenario

dbs_classes.database.Database.run_scenario(scenario_name)

Run a scenario hazard and impacts.

Parameters

Name Type Description Default
scenario_name Union[str, list[str]] name(s) of the scenarios to run. required

Raises

Name Type Description
RuntimeError If an error occurs while running one of the scenarios

shutdown

dbs_classes.database.Database.shutdown()

Explicitly shut down the database controller singleton and clear all data stored in its memory.

Back to top