FloodAdapt

FloodAdapt(self, database_path: Path)

Methods

Name Description
calculate_polygon_area Calculate the area of a polygon from a GeoDataFrame.
calculate_volume Calculate the volume of green infrastructure based on the given area, height, and percent area.
check_benefit_scenarios Return a dataframe with the scenarios needed for this benefit assessment run.
check_higher_level_usage Check if an event is used in a scenario.
copy_event Copy an event in the database.
copy_measure Copy an event in the database.
copy_projection Copy a projection 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 event 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.
download_wl_data Download water level data from a station or tide gauge.
edit_benefit Edit a benefit object in the database.
edit_event Edit an event object in the database.
edit_measure Edit an event object in the database.
edit_projection Edit a projection object in the database.
edit_scenario Edit a scenario object in the database.
get_aggregation 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_aggregation_benefits Get the aggregation benefits for a benefit assessment.
get_benefit Get a benefit from the database by name.
get_benefits Get all benefits from the database.
get_building_footprints Return a geodataframe of the impacts at the footprint level.
get_buildings Get the buildings exposure that are used in Fiat.
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_event_mode Get the mode of an event from the database by name.
get_event_templates Get list of all implemented event templates.
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_hazard_measure_types Get list of all implemented hazard measure types.
get_impact_measure_types Get list of all implemented impact measure types.
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 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_outputs Get all completed scenarios from the database.
get_projection Get a projection from the database by name.
get_projections Get all projections from the database.
get_property_types Get the property types that are used in the exposure.
get_roads 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_forcing Plot forcing data for an event.
plot_slr_scenarios Plot sea level rise scenarios.
read_csv Read a csv file into a pandas DataFrame.
read_database Given a path and a site name returns a IDatabase object.
run_benefit Run the benefit assessment.
run_scenario Run a scenario.
save_benefit Save a benefit object to the database.
save_cyclone_track Save cyclone track data to the event folder.
save_event Save an event object to the database.
save_measure Save an event 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.
save_timeseries_csv Save timeseries data to a csv file.

calculate_polygon_area

FloodAdapt.calculate_polygon_area(gdf: gpd.GeoDataFrame, site: Site)

Calculate the area of a polygon from a GeoDataFrame.

Parameters

gdf : gpd.GeoDataFrame

A GeoDataFrame containing the polygon geometry.

site : Site

An instance of Site representing the site information.

Returns

: float: The area of the polygon in the specified units.

calculate_volume

FloodAdapt.calculate_volume(
    area: us.UnitfulArea,
    height: us.UnitfulHeight = us.UnitfulHeight(value=0.0, units=us.UnitTypesLength.meters),
    percent_area: float = 100.0,
)

Calculate the volume of green infrastructure based on the given area, height, and percent area.

Parameters

area : float

The area of the green infrastructure in square units.

height : float = us.UnitfulHeight(value=0.0, units=us.UnitTypesLength.meters)

The height of the green infrastructure in units. Defaults to 0.0.

percent_area : float = 100.0

The percentage of the area to be considered. Defaults to 100.0.

Returns

: float: The calculated volume of the green infrastructure.

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

: pd.DataFrame

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

check_higher_level_usage

FloodAdapt.check_higher_level_usage(name: str)

Check if an event is used in a scenario.

Parameters

name : str

name of the event to be checked

Returns

: list[str]

list of scenario names where the event is used

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 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_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

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.

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

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

: 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 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

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

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

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 event from the database.

Parameters

name : str

The name of the event to delete.

Raises

: ValueError

If the event 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.

download_wl_data

FloodAdapt.download_wl_data(
    tide_gauge: TideGauge,
    time: TimeFrame,
    units: us.UnitTypesLength,
    out_path: str,
)

Download water level data from a station or tide gauge.

Parameters

tide_gauge : TideGauge

Tide gauge object to download data from

time : TimeFrame

Time model object containing start and end time

units : UnitTypesLength

Units that data the returned data will be converted to

out_path : str

Path to save the data to

edit_benefit

FloodAdapt.edit_benefit(benefit: Benefit)

Edit a benefit object in the database.

Parameters

benefit : Benefit

The benefit object to edit.

Raises

: ValueError

If the benefit object does not exist.

edit_event

FloodAdapt.edit_event(event: Event)

Edit an event object in the database.

Parameters

event : Event

The event object to edit.

Raises

: ValueError

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

edit_measure

FloodAdapt.edit_measure(measure: Measure)

Edit an event object in the database.

Parameters

measure : Measure

The measure object to edit.

Raises

: ValueError

If the event object does not exist.

edit_projection

FloodAdapt.edit_projection(projection: Projection)

Edit a projection object in the database.

Parameters

projection : Projection

The projection object to edit.

Raises

: ValueError

If the projection object does not exist.

edit_scenario

FloodAdapt.edit_scenario(scenario: Scenario)

Edit a scenario object in the database.

Parameters

scenario : Scenario

The scenario object to edit.

Raises

: ValueError

If the scenario object does not exist.

get_aggregation

FloodAdapt.get_aggregation(name: str)

Return a dictionary with the aggregated impacts as geodataframes.

Parameters

name : str

The name of the scenario.

Returns

: 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

: dict[str, GeoDataFrame]

list of geodataframes with the polygons defining the aggregation areas

get_aggregation_benefits

FloodAdapt.get_aggregation_benefits(name: str)

Get the aggregation benefits for a benefit assessment.

Parameters

name : str

The name of the benefit assessment.

Returns

: gpd.GeoDataFrame

The aggregation benefits for the benefit assessment.

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

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

: 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_footprints

FloodAdapt.get_building_footprints(name: str)

Return a geodataframe of the impacts at the footprint level.

Parameters

name : str

The name of the scenario.

Returns

: gpd.GeoDataFrame

The impact footprints for the scenario.

get_buildings

FloodAdapt.get_buildings()

Get the buildings exposure that are used in Fiat.

Returns

: gpd.GeoDataFrame

gpd.GeoDataFrames with the buildings from FIAT exposure

get_depth_conversion

FloodAdapt.get_depth_conversion()

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

Returns

: 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 | EventSet

The event with the given name.

Raises

: ValueError

If the event with the given name does not exist.

get_event_mode

FloodAdapt.get_event_mode(name: str)

Get the mode of an event from the database by name.

Parameters

name : str

Returns

: Mode

The mode of the event with the given name, either risk or single_event.

get_event_templates

FloodAdapt.get_event_templates()

Get list of all implemented event templates.

get_events

FloodAdapt.get_events()

Get all events from the database.

Returns

: 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

: pd.DataFrame

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

get_hazard_measure_types

FloodAdapt.get_hazard_measure_types()

Get list of all implemented hazard measure types.

get_impact_measure_types

FloodAdapt.get_impact_measure_types()

Get list of all implemented impact measure types.

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

: 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

: 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

: pd.DataFrame

Raises

: FileNotFoundError

If the metrics file does not exist.

get_max_water_level

FloodAdapt.get_max_water_level(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

: 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

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

: 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

: GeoDataFrame

GeoDataFrame with the model boundary

get_model_grid

FloodAdapt.get_model_grid()

Get the model grid that is used in SFINCS.

Returns

: 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

: 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

: gpd.GeoDataFrame

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

get_outputs

FloodAdapt.get_outputs()

Get all completed scenarios from the database.

Returns

: 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_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

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

: 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_property_types

FloodAdapt.get_property_types()

Get the property types that are used in the exposure.

Returns

: list

list of property types

get_roads

FloodAdapt.get_roads(name: str)

Return a geodataframe of the impacts at roads.

Parameters

name : str

The name of the scenario.

Returns

: 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

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

: 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

: list

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

: gpd.gpd.GeoDataFrame

gpd.GeoDataFrame with the static map

get_strategies

FloodAdapt.get_strategies()

Get all strategies from the database.

Returns

: 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

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

: 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

: 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

: float

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

plot_forcing

FloodAdapt.plot_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

: str

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

read_csv

FloodAdapt.read_csv(csvpath: Union[str, os.PathLike])

Read a csv file into a pandas DataFrame.

Parameters

csvpath : Union[str, os.PathLike]

Path to the csv file

Returns

: pd.DataFrame

DataFrame containing the data from the csv file

read_database

FloodAdapt.read_database(database_path: Union[str, os.PathLike], site_name: str)

Given a path and a site name returns a IDatabase object.

Parameters

database_path : Union[str, os.PathLike]

path to database

site_name : str

name of the site

Returns

: IDatabase

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(name: Union[str, list[str]])

Run a scenario.

Parameters

name : Union[str, list[str]]

The name(s) of the scenario to run.

Raises

: ValueError

If the scenario does not exist.

save_benefit

FloodAdapt.save_benefit(benefit: Benefit)

Save a benefit object to the database.

Parameters

benefit : Benefit

The benefit object to save.

Raises

: ValueError

If the benefit object is not valid.

save_cyclone_track

FloodAdapt.save_cyclone_track(event: Event, track: TropicalCyclone)

Save cyclone track data to the event folder.

Parameters

event : Event

The event object

track : TropicalCyclone

The cyclone track data

save_event

FloodAdapt.save_event(event: Event)

Save an event object to the database.

Parameters

event : Event

The event object to save.

Raises

: ValueError

If the event object is not valid.

save_measure

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

Save an event object to the database.

Parameters

measure : Measure

The measure object to save.

Raises

: ValueError

If the event object is not valid.

save_projection

FloodAdapt.save_projection(projection: Projection)

Save a projection object to the database.

Parameters

projection : Projection

The projection object to save.

Raises

: ValueError

If the projection object is not valid.

save_scenario

FloodAdapt.save_scenario(scenario: Scenario)

Save the scenario to the database.

Parameters

scenario : Scenario

The scenario to save.

Returns

: bool

Whether the scenario was saved successfully.

: str

The error message if the scenario was not saved successfully.

save_strategy

FloodAdapt.save_strategy(strategy: Strategy)

Save a strategy object to the database.

Parameters

strategy : Strategy

The strategy object to save.

Raises

: ValueError

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

save_timeseries_csv

FloodAdapt.save_timeseries_csv(name: str, event: Event, df: pd.DataFrame)

Save timeseries data to a csv file.

Parameters

name : str

Name of the event

event : Event

Event object

df : pd.DataFrame

Dataframe of timeseries data

Back to top