FloodAdapt

FloodAdapt(self, database_path: Path)

Methods

Name Description
check_benefit_scenarios Return a dataframe with the scenarios needed for this benefit assessment run.
copy_event Copy an event in the database.
copy_measure Copy a measure in the database.
copy_projection Copy a projection in the database.
copy_strategy Copy a strategy in the database.
create_benefit Create a new benefit object.
create_benefit_scenarios Create the benefit scenarios.
create_event Create a event object from a dictionary of attributes.
create_event_set Create a event set object from a dictionary of attributes.
create_measure Create a measure from a dictionary of attributes and a type string.
create_projection Create a new projection object.
create_scenario Create a new scenario object.
create_strategy Create a new strategy object.
delete_benefit Delete a benefit object from the database.
delete_event Delete an event from the database.
delete_measure Delete an measure from the database.
delete_projection Delete a projection from the database.
delete_scenario Delete a scenario from the database.
delete_strategy Delete a strategy from the database.
get_aggregated_benefits Get the aggregation benefits for a benefit assessment.
get_aggregated_impacts Return a dictionary with the aggregated impacts as geodataframes.
get_aggregation_areas Get a list of the aggregation areas that are provided in the site configuration.
get_benefit Get a benefit from the database by name.
get_benefits Get all benefits from the database.
get_building_footprint_impacts Return a geodataframe of the impacts at the footprint level.
get_building_geometries Get the buildings exposure that are used in Fiat.
get_building_types Get the building types/categories that are used in the exposure.
get_completed_scenarios Get all completed scenarios from the database.
get_cyclone_track_by_index Get a cyclone track from the database by index.
get_depth_conversion Return the flood depth conversion that is need in the gui to plot the flood map.
get_event Get an event from the database by name.
get_events Get all events from the database.
get_green_infra_table Return a table with different types of green infrastructure measures and their infiltration depths.
get_index_path Return the path of the index tiles which are used to connect each water level cell with the topobathy tiles.
get_infographic Return the HTML string of the infographic for the given scenario.
get_infometrics Return the metrics for the given scenario.
get_max_water_level_map Return the maximum water level for the given scenario.
get_measure Get a measure from the database by name.
get_measures Get all measures from the database.
get_model_boundary Get the model boundary that is used in SFINCS.
get_model_grid Get the model grid that is used in SFINCS.
get_obs_point_timeseries Return the HTML strings of the water level timeseries for the given scenario.
get_obs_points Get the observation points specified in the site.toml.
get_projection Get a projection from the database by name.
get_projections Get all projections from the database.
get_road_impacts Return a geodataframe of the impacts at roads.
get_scenario Get a scenario from the database by name.
get_scenarios Get all scenarios from the database.
get_slr_scn_names Get all sea level rise scenario names from the database.
get_static_map Get a static map from the database.
get_strategies Get all strategies from the database.
get_strategy Get a strategy from the database by name.
get_svi_map Get the SVI map that are used in Fiat.
get_topobathy_path Return the path of the topobathy tiles in order to create flood maps with water level maps.
interp_slr Interpolate sea level rise for a given scenario and year.
plot_event_forcing Plot forcing data for an event.
plot_slr_scenarios Plot sea level rise scenarios.
run_benefit Run the benefit assessment.
run_scenario Run a scenario hazard and impacts.
save_benefit Save a benefit object to the database.
save_event Save an event object to the database.
save_measure Save a measure object to the database.
save_projection Save a projection object to the database.
save_scenario Save the scenario to the database.
save_strategy Save a strategy object to the database.

check_benefit_scenarios

FloodAdapt.check_benefit_scenarios(benefit: Benefit)

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

Parameters

benefit : Benefit

The benefit object to check.

Returns

scenarios : pd.DataFrame

A dataframe with the scenarios needed for this benefit assessment run.

copy_event

FloodAdapt.copy_event(old_name: str, new_name: str, new_description: str)

Copy an event in the database.

Parameters

old_name : str

The name of the event to copy.

new_name : str

The name of the new event.

new_description : str

The description of the new event

copy_measure

FloodAdapt.copy_measure(old_name: str, new_name: str, new_description: str)

Copy a measure in the database.

Parameters

old_name : str

The name of the measure to copy.

new_name : str

The name of the new measure.

new_description : str

The description of the new measure

copy_projection

FloodAdapt.copy_projection(old_name: str, new_name: str, new_description: str)

Copy a projection in the database.

Parameters

old_name : str

The name of the projection to copy.

new_name : str

The name of the new projection.

new_description : str

The description of the new projection

copy_strategy

FloodAdapt.copy_strategy(old_name: str, new_name: str, new_description: str)

Copy a strategy in the database.

Parameters

old_name : str

The name of the strategy to copy.

new_name : str

The name of the new strategy.

new_description : str

The description of the new strategy

create_benefit

FloodAdapt.create_benefit(attrs: dict[str, Any])

Create a new benefit object.

Parameters

attrs : dict[str, Any]

The attributes of the benefit object to create. Should adhere to the Benefit schema.

Returns

benefit : Benefit

The benefit object created from the attributes.

Raises

: ValueError

If the attributes do not adhere to the Benefit schema.

create_benefit_scenarios

FloodAdapt.create_benefit_scenarios(benefit: Benefit)

Create the benefit scenarios.

Parameters

benefit : Benefit

The benefit object to create scenarios for.

create_event

FloodAdapt.create_event(attrs: dict[str, Any] | Event)

Create a event object from a dictionary of attributes.

Parameters

attrs : Event[str, Any]

Dictionary of attributes

Returns

event : Event

Depending on attrs.template an event object. Can be of type: Synthetic, Historical, Hurricane.

create_event_set

FloodAdapt.create_event_set(
    attrs: dict[str, Any] | EventSet,
    sub_events: list[Event],
)

Create a event set object from a dictionary of attributes.

Parameters

attrs : EventSet[str, Any]

Dictionary of attributes

sub_events : list[Event]

List of events in the event set

Returns

event_set : EventSet

EventSet object

create_measure

FloodAdapt.create_measure(attrs: dict[str, Any], type: str = None)

Create a measure from a dictionary of attributes and a type string.

Parameters

attrs : dict[str, Any]

Dictionary of attributes for the measure.

type : str = None

Type of measure to create.

Returns

measure : Measure

Measure object.

create_projection

FloodAdapt.create_projection(attrs: dict[str, Any])

Create a new projection object.

Parameters

attrs : dict[str, Any]

The attributes of the projection object to create. Should adhere to the Projection schema.

Returns

projection : Projection

The projection object created from the attributes.

Raises

: ValueError

If the attributes do not adhere to the Projection schema.

create_scenario

FloodAdapt.create_scenario(attrs: dict[str, Any])

Create a new scenario object.

Parameters

attrs : dict[str, Any]

The attributes of the scenario object to create. Should adhere to the Scenario schema.

Returns

scenario : Scenario

The scenario object created from the attributes.

Raises

: ValueError

If the attributes do not adhere to the Scenario schema.

create_strategy

FloodAdapt.create_strategy(attrs: dict[str, Any])

Create a new strategy object.

Parameters

attrs : dict[str, Any]

The attributes of the strategy object to create. Should adhere to the Strategy schema.

Returns

strategy : Strategy

The strategy object

Raises

: ValueError

If the strategy with the given name does not exist. If attrs does not adhere to the Strategy schema.

delete_benefit

FloodAdapt.delete_benefit(name: str)

Delete a benefit object from the database.

Parameters

name : str

The name of the benefit object to delete.

Raises

: ValueError

If the benefit object does not exist.

delete_event

FloodAdapt.delete_event(name: str)

Delete an event from the database.

Parameters

name : str

The name of the event to delete.

Raises

: ValueError

If the event does not exist. If the event is used in a scenario.

delete_measure

FloodAdapt.delete_measure(name: str)

Delete an measure from the database.

Parameters

name : str

The name of the measure to delete.

Raises

: ValueError

If the measure does not exist.

delete_projection

FloodAdapt.delete_projection(name: str)

Delete a projection from the database.

Parameters

name : str

The name of the projection to delete.

Raises

: ValueError

If the projection does not exist. If the projection is used in a scenario.

delete_scenario

FloodAdapt.delete_scenario(name: str)

Delete a scenario from the database.

Parameters

name : str

The name of the scenario to delete.

Raises

: ValueError

If the scenario does not exist.

delete_strategy

FloodAdapt.delete_strategy(name: str)

Delete a strategy from the database.

Parameters

name : str

The name of the strategy to delete.

Raises

: ValueError

If the strategy does not exist.

get_aggregated_benefits

FloodAdapt.get_aggregated_benefits(name: str)

Get the aggregation benefits for a benefit assessment.

Parameters

name : str

The name of the benefit assessment.

Returns

aggregated_benefits : gpd.GeoDataFrame

The aggregation benefits for the benefit assessment.

get_aggregated_impacts

FloodAdapt.get_aggregated_impacts(name: str)

Return a dictionary with the aggregated impacts as geodataframes.

Parameters

name : str

The name of the scenario.

Returns

aggr_impacts : dict[str, gpd.GeoDataFrame]

The aggregated impacts for the scenario.

get_aggregation_areas

FloodAdapt.get_aggregation_areas()

Get a list of the aggregation areas that are provided in the site configuration.

These are expected to much the ones in the FIAT model.

Returns

aggregation_areas : dict[str, GeoDataFrame]

list of geodataframes with the polygons defining the aggregation areas

get_benefit

FloodAdapt.get_benefit(name: str)

Get a benefit from the database by name.

Parameters

name : str

The name of the benefit to retrieve.

Returns

benefit : Benefit

The benefit object with the given name. See Benefit for details.

Raises

: ValueError

If the benefit with the given name does not exist.

get_benefits

FloodAdapt.get_benefits()

Get all benefits from the database.

Returns

benefits : dict[str, Any]

A dictionary containing all benefits. Includes keys: ‘name’, ‘description’, ‘path’, ‘last_modification_date’, ‘objects’ Each value is a list of the corresponding attribute for each benefit.

get_building_footprint_impacts

FloodAdapt.get_building_footprint_impacts(name: str)

Return a geodataframe of the impacts at the footprint level.

Parameters

name : str

The name of the scenario.

Returns

footprints : gpd.GeoDataFrame

The impact footprints for the scenario.

get_building_geometries

FloodAdapt.get_building_geometries()

Get the buildings exposure that are used in Fiat.

Returns

buildings : gpd.GeoDataFrame

gpd.GeoDataFrames with the buildings from FIAT exposure

get_building_types

FloodAdapt.get_building_types()

Get the building types/categories that are used in the exposure.

These are used to filter the buildings in the FIAT model, and can include types like: ‘Residential’, ‘Commercial’, ‘Industrial’, etc.

Returns

building_types : list[str]

list of building types

get_completed_scenarios

FloodAdapt.get_completed_scenarios()

Get all completed scenarios from the database.

Returns

scenarios : dict[str, Any]

A dictionary containing all scenarios. Includes keys: ‘name’, ‘description’, ‘path’, ‘last_modification_date’, ‘objects’ Each value is a list of the corresponding attribute for each output.

get_cyclone_track_by_index

FloodAdapt.get_cyclone_track_by_index(index: int)

Get a cyclone track from the database by index.

Parameters

index : int

The index of the cyclone track to retrieve.

Returns

cyclone : TropicalCyclone

The cyclone track object with the given index.

Raises

: ValueError

If the cyclone track database is not defined in the site configuration. If the cyclone track with the given index does not exist.

get_depth_conversion

FloodAdapt.get_depth_conversion()

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

Returns

fdc : float

The flood depth conversion.

get_event

FloodAdapt.get_event(name: str)

Get an event from the database by name.

Parameters

name : str

The name of the event to retrieve.

Returns

event : Union[Event, EventSet]

The event with the given name.

Raises

: ValueError

If the event with the given name does not exist.

get_events

FloodAdapt.get_events()

Get all events from the database.

Returns

events : dict[str, Any]

A dictionary containing all events. Includes keys: ‘name’, ‘description’, ‘path’, ‘last_modification_date’, ‘objects’ Each value is a list of the corresponding attribute for each benefit.

get_green_infra_table

FloodAdapt.get_green_infra_table(measure_type: str)

Return a table with different types of green infrastructure measures and their infiltration depths.

Parameters

measure_type : str

The type of green infrastructure measure.

Returns

table : pd.DataFrame

A table with different types of green infrastructure measures and their infiltration depths.

get_index_path

FloodAdapt.get_index_path()

Return the path of the index tiles which are used to connect each water level cell with the topobathy tiles.

Returns

index_path : str

The path to the index file.

get_infographic

FloodAdapt.get_infographic(name: str)

Return the HTML string of the infographic for the given scenario.

Parameters

name : str

The name of the scenario.

Returns

html : str

The HTML string of the infographic.

get_infometrics

FloodAdapt.get_infometrics(name: str)

Return the metrics for the given scenario.

Parameters

name : str

The name of the scenario.

Returns

metrics : pd.DataFrame

The metrics for the scenario.

Raises

: FileNotFoundError

If the metrics file does not exist.

get_max_water_level_map

FloodAdapt.get_max_water_level_map(name: str, rp: int = None)

Return the maximum water level for the given scenario.

Parameters

name : str

The name of the scenario.

rp : int = None

The return period of the water level, by default None

Returns

water_level_map : np.ndarray

2D gridded map with the maximum waterlevels for each cell.

get_measure

FloodAdapt.get_measure(name: str)

Get a measure from the database by name.

Parameters

name : str

The name of the measure to retrieve.

Returns

measure : Measure

The measure object with the given name.

Raises

: ValueError

If the measure with the given name does not exist.

get_measures

FloodAdapt.get_measures()

Get all measures from the database.

Returns

measures : dict[str, Any]

A dictionary containing all measures. Includes keys: ‘name’, ‘description’, ‘path’, ‘last_modification_date’, ‘objects’ Each value is a list of the corresponding attribute for each measure.

get_model_boundary

FloodAdapt.get_model_boundary()

Get the model boundary that is used in SFINCS.

Returns

model_boundary : GeoDataFrame

GeoDataFrame with the model boundary

get_model_grid

FloodAdapt.get_model_grid()

Get the model grid that is used in SFINCS.

Returns

grid : QuadtreeGrid

QuadtreeGrid with the model grid

get_obs_point_timeseries

FloodAdapt.get_obs_point_timeseries(name: str)

Return the HTML strings of the water level timeseries for the given scenario.

Parameters

name : str

The name of the scenario.

Returns

html_path : str

The HTML strings of the water level timeseries

get_obs_points

FloodAdapt.get_obs_points()

Get the observation points specified in the site.toml.

These are also added to the flood hazard model. They are used as marker locations to plot water level time series in the output tab.

Returns

observation_points : gpd.GeoDataFrame

gpd.GeoDataFrame with observation points from the site.toml.

get_projection

FloodAdapt.get_projection(name: str)

Get a projection from the database by name.

Parameters

name : str

The name of the projection to retrieve.

Returns

projection : Projection

The projection object with the given name.

Raises

: ValueError

If the projection with the given name does not exist.

get_projections

FloodAdapt.get_projections()

Get all projections from the database.

Returns

projections : dict[str, Any]

A dictionary containing all projections. Includes keys: ‘name’, ‘description’, ‘path’, ‘last_modification_date’, ‘objects’ Each value is a list of the corresponding attribute for each projection.

get_road_impacts

FloodAdapt.get_road_impacts(name: str)

Return a geodataframe of the impacts at roads.

Parameters

name : str

The name of the scenario.

Returns

roads : gpd.GeoDataFrame

The impacted roads for the scenario.

get_scenario

FloodAdapt.get_scenario(name: str)

Get a scenario from the database by name.

Parameters

name : str

The name of the scenario to retrieve.

Returns

scenario : Scenario

The scenario object with the given name.

Raises

: ValueError

If the scenario with the given name does not exist.

get_scenarios

FloodAdapt.get_scenarios()

Get all scenarios from the database.

Returns

scenarios : dict[str, Any]

A dictionary containing all scenarios. Includes keys: ‘name’, ‘description’, ‘path’, ‘last_modification_date’, ‘objects’. Each value is a list of the corresponding attribute for each scenario.

get_slr_scn_names

FloodAdapt.get_slr_scn_names()

Get all sea level rise scenario names from the database.

Returns

names : List[str]

List of scenario names

get_static_map

FloodAdapt.get_static_map(path: Union[str, Path])

Get a static map from the database.

Parameters

path : Union[str, Path]

path to the static map

Returns

static_map : Union[gpd.GeoDataFrame, None]

gpd.GeoDataFrame with the static map if available, None if not found

get_strategies

FloodAdapt.get_strategies()

Get all strategies from the database.

Returns

strategies : dict[str, Any]

A dictionary containing all strategies. Includes keys: ‘name’, ‘description’, ‘path’, ‘last_modification_date’, ‘objects’ Each value is a list of the corresponding attribute for each strategy.

get_strategy

FloodAdapt.get_strategy(name: str)

Get a strategy from the database by name.

Parameters

name : str

The name of the strategy to retrieve.

Returns

strategy : Strategy

The strategy object with the given name.

Raises

: ValueError

If the strategy with the given name does not exist.

get_svi_map

FloodAdapt.get_svi_map()

Get the SVI map that are used in Fiat.

Returns

svi_map : gpd.GeoDataFrame

gpd.GeoDataFrames with the SVI map, None if not available

get_topobathy_path

FloodAdapt.get_topobathy_path()

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

Returns

topo_path : str

The path to the topobathy file.

interp_slr

FloodAdapt.interp_slr(slr_scenario: str, year: float)

Interpolate sea level rise for a given scenario and year.

Parameters

slr_scenario : str

The name of the sea level rise scenario.

year : float

The year to interpolate sea level rise for.

Returns

interpolated : float

The interpolated sea level rise for the given scenario and year.

plot_event_forcing

FloodAdapt.plot_event_forcing(event: Event, forcing_type: ForcingType)

Plot forcing data for an event.

Parameters

event : Event

The event object

forcing_type : ForcingType

The type of forcing data to plot

plot_slr_scenarios

FloodAdapt.plot_slr_scenarios()

Plot sea level rise scenarios.

Returns

html_path : str

The path to the html plot of the sea level rise scenarios.

run_benefit

FloodAdapt.run_benefit(name: Union[str, list[str]])

Run the benefit assessment.

Parameters

name : Union[str, list[str]]

The name of the benefit object to run.

run_scenario

FloodAdapt.run_scenario(scenario_name: Union[str, list[str]])

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

save_benefit

FloodAdapt.save_benefit(benefit: Benefit, overwrite: bool = False)

Save a benefit object to the database.

Parameters

benefit : Benefit

The benefit object to save.

overwrite : bool = False

Whether to overwrite an existing benefit with the same name (default is False).

Raises

: ValueError

If the benefit object is not valid.

save_event

FloodAdapt.save_event(event: Event, overwrite: bool = False)

Save an event object to the database.

Parameters

event : Event

The event object to save.

overwrite : bool = False

Whether to overwrite an existing event with the same name (default is False).

Raises

: ValueError

If the event object is not valid.

save_measure

FloodAdapt.save_measure(measure: Measure, overwrite: bool = False)

Save a measure object to the database.

Parameters

measure : Measure

The measure object to save.

overwrite : bool = False

Whether to overwrite an existing measure with the same name (default is False).

Raises

: ValueError

If the measure object is not valid.

save_projection

FloodAdapt.save_projection(projection: Projection, overwrite: bool = False)

Save a projection object to the database.

Parameters

projection : Projection

The projection object to save.

overwrite : bool = False

Whether to overwrite an existing projection with the same name (default is False).

Raises

: ValueError

If the projection object is not valid.

save_scenario

FloodAdapt.save_scenario(scenario: Scenario, overwrite: bool = False)

Save the scenario to the database.

Parameters

scenario : Scenario

The scenario to save.

overwrite : bool = False

Whether to overwrite an existing scenario with the same name (default is False).

Returns

run_success : bool

Whether the scenario was saved successfully.

error_msg : str

The error message if the scenario was not saved successfully.

save_strategy

FloodAdapt.save_strategy(strategy: Strategy, overwrite: bool = False)

Save a strategy object to the database.

Parameters

strategy : Strategy

The strategy object to save.

overwrite : bool = False

Whether to overwrite an existing strategy with the same name (default is False).

Raises

: ValueError

If the strategy object is not valid. If the strategy object already exists.

Back to top