FiatAdapter

adapter.FiatAdapter(
    self,
    model_root: Path,
    config: Optional[FiatConfigModel] = None,
    exe_path: Optional[os.PathLike] = None,
    delete_crashed_runs: bool = True,
    config_base_path: Optional[os.PathLike] = None,
)

ImpactAdapter for Delft-FIAT.

It includes: - preprocessing methods for adding measures, projections and hazards - executing method for running a Delft-FIAT simulation - postprocessing methods for saving impact results

Attributes

Name Description
damage_types Get the damage types that are present in the exposure.

Methods

Name Description
add_equity Calculate equity-based damages for a given aggregation label.
add_exceedance_probability Calculate exceedance probabilities and append them to the results table.
add_measure Add and apply a specific impact measure to the properties of the FIAT model.
add_projection Add the socioeconomic changes part of a projection to the FIAT model.
apply_economic_growth Apply economic growth to the FIAT-Model by adjusting the maximum potential damage values in the exposure database.
apply_population_growth_existing Apply population growth to the FIAT-Model by adjusting the existing max potential damage values for buildings.
apply_population_growth_new Apply population growth in a new area by adding new objects in the model.
buyout_properties Apply the buyout measure to the properties by setting their maximum potential damage to zero.
close_files Close all open files and clean up file handles.
create_infographics Create infographic files based on the provided metrics and configuration.
create_infometrics Create infometrics files based on the provided metric configuration paths.
delete_model Delete the Delft-FIAT simulation folder.
elevate_properties Elevate the ground floor height of properties based on the provided Elevate measure.
execute Execute the FIAT model.
fiat_completed Check if fiat has run as expected.
floodproof_properties Apply floodproofing measures to the properties by truncating the damage function.
get_all_building_ids Retrieve the IDs of all buildings in the FIAT model.
get_buildings Retrieve the building geometries from the FIAT model’s exposure database.
get_object_ids Retrieve the object IDs for a given impact measure.
get_property_types Retrieve the list of property types from the FIAT model’s exposure database.
has_run Check if the impact results file for the given scenario exists.
postprocess Post-process the results of the Delft-FIAT simulation for a given scenario.
preprocess Preprocess the FIAT-model given a scenario by setting up projections, measures, and hazards, and then saves any changes made to disk.
read Read the fiat model from the current model root.
read_outputs Read the output FIAT CSV file specified in the model configuration and stores the data in the outputs attribute.
run Execute the full process for a given scenario, including preprocessing, executing the simulation, and postprocessing steps.
save_aggregation_spatial Save aggregated metrics to a spatial file.
save_building_footprints Aggregate impacts at a building footprint level and then saves to an output file.
save_roads Save the impacts on roads to a spatial file.
set_hazard Set the hazard map and type for the FIAT model.
write Write the fiat model configuration to a directory.

add_equity

adapter.FiatAdapter.add_equity(
    aggr_label: str,
    metrics_path: os.PathLike,
    damage_column_pattern: str = 'TotalDamageRP{rp}',
    gamma: float = 1.2,
)

Calculate equity-based damages for a given aggregation label.

Parameters

aggr_label : str

The label of the aggregation area.

metrics_path : os.PathLike

The path to the metrics file.

damage_column_pattern : str = 'TotalDamageRP{rp}'

The pattern for the damage column names, by default “TotalDamageRP{rp}”.

gamma : float = 1.2

The equity weight parameter, by default 1.2

add_exceedance_probability

adapter.FiatAdapter.add_exceedance_probability(
    column: str,
    threshold: float,
    period: int,
)

Calculate exceedance probabilities and append them to the results table.

Parameters

column : str

The name of the column to calculate exceedance probabilities for.

threshold : float

The threshold value for exceedance probability calculation.

period : int

The return period for exceedance probability calculation.

Returns

: pd.DataFrame

The updated results table with exceedance probabilities appended.

add_measure

adapter.FiatAdapter.add_measure(measure: Measure)

Add and apply a specific impact measure to the properties of the FIAT model.

Parameters

measure : Measure

The impact measure to be applied. It can be of type Elevate, FloodProof, or Buyout.

Notes

The method logs the application of the measure and calls the appropriate method based on the measure type: - Elevate: Calls elevate_properties(measure) - FloodProof: Calls floodproof_properties(measure) - Buyout: Calls buyout_properties(measure)

If the measure type is unsupported, a warning is logged.

add_projection

adapter.FiatAdapter.add_projection(projection: Projection)

Add the socioeconomic changes part of a projection to the FIAT model.

Parameters

projection : Projection

The projection object containing socioeconomic changes to be applied.

Notes

  • Economic growth is applied to all existing buildings if specified.
  • New population growth areas are added if specified, taking into account economic growth.
  • Population growth is applied to existing objects if specified.

apply_economic_growth

adapter.FiatAdapter.apply_economic_growth(
    economic_growth: float,
    ids: Optional[list] = None,
)

Apply economic growth to the FIAT-Model by adjusting the maximum potential damage values in the exposure database.

This method updates the max potential damage values in the exposure database by applying a given economic growth rate. It can optionally filter the updates to specific objects identified by their IDs.

Parameters

economic_growth : float

The economic growth rate to apply, expressed as a percentage.

ids : Optional[list] = None

A list of object IDs to which the economic growth should be applied. If None, the growth is applied to all buildings.

apply_population_growth_existing

adapter.FiatAdapter.apply_population_growth_existing(
    population_growth: float,
    ids: Optional[list[str]] = None,
)

Apply population growth to the FIAT-Model by adjusting the existing max potential damage values for buildings.

This method updates the max potential damage values in the exposure database by applying a given population growth rate. It can optionally filter the updates to specific objects identified by their IDs.

Parameters

population_growth : float

The population growth rate as a percentage.

ids : Optional[list[str]] = None

A list of object IDs to filter the updates. If None, the updates are applied to all buildings.

apply_population_growth_new

adapter.FiatAdapter.apply_population_growth_new(
    population_growth: float,
    ground_floor_height: float,
    elevation_type: str,
    area_path: str,
    ground_elevation: Union[None, str, Path] = None,
)

Apply population growth in a new area by adding new objects in the model.

Parameters

population_growth : float

The percentage of population growth to apply.

ground_floor_height : float

The height of the ground floor.

elevation_type : str

The type of elevation reference to use. Must be either ‘floodmap’ or ‘datum’.

area_path : str

The path to the area file.

ground_elevation : Union[None, str, Path] = None

The ground elevation reference. Default is None.

Raises

: ValueError

If elevation_type is ‘floodmap’ and base flood elevation (bfe) map is not provided. If elevation_type is not ‘floodmap’ or ‘datum’.

buyout_properties

adapter.FiatAdapter.buyout_properties(buyout: Buyout)

Apply the buyout measure to the properties by setting their maximum potential damage to zero.

Parameters

buyout : Buyout

The Buyout measure containing the details of the properties to be bought out.

close_files

adapter.FiatAdapter.close_files()

Close all open files and clean up file handles.

create_infographics

adapter.FiatAdapter.create_infographics(
    name: str,
    output_base_path: os.PathLike,
    config_base_path: os.PathLike,
    metrics_path: os.PathLike,
    mode: Mode = Mode.single_event,
)

Create infographic files based on the provided metrics and configuration.

Parameters

name : str

The name of the scenario.

output_base_path : os.PathLike

The base path where the output files will be saved.

config_base_path : os.PathLike

The base path where the configuration files are located.

metrics_path : os.PathLike

The path to the metrics file.

mode : Mode = Mode.single_event

The mode of the infographic, by default Mode.single_event.

create_infometrics

adapter.FiatAdapter.create_infometrics(
    metric_config_paths: list[os.PathLike],
    metrics_output_path: os.PathLike,
)

Create infometrics files based on the provided metric configuration paths.

Parameters

metric_config_paths : list[os.PathLike]

A list of paths to the metric configuration files.

metrics_output_path : os.PathLike

The path where the metrics output file will be saved.

Raises

: FileNotFoundError

If a mandatory metric configuration file does not exist.

delete_model

adapter.FiatAdapter.delete_model()

Delete the Delft-FIAT simulation folder.

This method attempts to delete the directory specified by self.model_root.

Raises

: OSError: If the directory cannot be deleted.

elevate_properties

adapter.FiatAdapter.elevate_properties(elevate: Elevate)

Elevate the ground floor height of properties based on the provided Elevate measure.

Parameters

elevate : Elevate

The Elevate measure containing the elevation details.

Raises

: ValueError

If the elevation type is ‘floodmap’ and the base flood elevation (bfe) map is not provided. If the elevation type is not ‘floodmap’ or ‘datum’.

execute

adapter.FiatAdapter.execute(
    path: Optional[os.PathLike] = None,
    exe_path: Optional[os.PathLike] = None,
    delete_crashed_runs: Optional[bool] = None,
    strict,
)

Execute the FIAT model.

Parameters

path : Optional[os.PathLike] = None

The path to the model directory. If not provided, defaults to self.model_root.

exe_path : Optional[os.PathLike] = None

The path to the FIAT executable. If not provided, defaults to self.exe_path.

delete_crashed_runs : Optional[bool] = None

Whether to delete files from crashed runs. If not provided, defaults to self.delete_crashed_runs.

strict : bool = True

Whether to raise an error if the FIAT model fails to run. Defaults to True.

Returns

: bool

True if the FIAT model run successfully, False otherwise.

Raises

: ValueError

If exe_path is not provided and self.exe_path is None.

: RuntimeError

If the FIAT model fails to run and strict is True.

fiat_completed

adapter.FiatAdapter.fiat_completed()

Check if fiat has run as expected.

Returns

: boolean

True if fiat has run, False if something went wrong

floodproof_properties

adapter.FiatAdapter.floodproof_properties(floodproof: FloodProof)

Apply floodproofing measures to the properties by truncating the damage function.

Parameters

floodproof : FloodProof

The FloodProof measure containing the details of the properties to be floodproofed.

get_all_building_ids

adapter.FiatAdapter.get_all_building_ids()

Retrieve the IDs of all buildings in the FIAT model.

Returns

: list

A list of IDs for all buildings in the FIAT model.

get_buildings

adapter.FiatAdapter.get_buildings()

Retrieve the building geometries from the FIAT model’s exposure database.

Returns

: gpd.GeoDataFrame

A GeoDataFrame containing the geometries of all buildings in the FIAT model.

Raises

: ValueError

If the FIAT model does not have an exposure database initialized.

get_object_ids

adapter.FiatAdapter.get_object_ids(measure: Measure)

Retrieve the object IDs for a given impact measure.

Parameters

measure : Measure

The impact measure for which to retrieve object IDs.

Returns

: list[Any]

A list of object IDs that match the criteria of the given measure.

Raises

: ValueError

If the measure type is not an impact measure.

get_property_types

adapter.FiatAdapter.get_property_types()

Retrieve the list of property types from the FIAT model’s exposure database.

Returns

: list

A list of property types available in the FIAT model.

Raises

: ValueError

If no property types are found in the FIAT model.

has_run

adapter.FiatAdapter.has_run(scenario: Scenario)

Check if the impact results file for the given scenario exists.

Parameters

scenario : Scenario

The scenario for which to check the FIAT results.

Returns

: bool

True if the FIAT results file exists, False otherwise.

postprocess

adapter.FiatAdapter.postprocess(scenario)

Post-process the results of the Delft-FIAT simulation for a given scenario.

Parameters

scenario : Scenario

The scenario object containing all relevant data and configurations.

Raises

: RuntimeError

If the Delft-FIAT simulation did not run successfully.

: Post-processing steps include:
: - Reading the outputs of the Delft-FIAT simulation.
: - Adding exceedance probabilities for risk mode scenarios.
: - Saving detailed impacts per object to a CSV file.
: - Creating infometrics files based on different metric configurations.
: - Generating infographic files if configured.
: - Calculating equity-based damages for risk mode scenarios.
: - Saving aggregated metrics to shapefiles.
: - Merging points data to building footprints.
: - Creating a roads spatial file if configured.
: - Deleting the simulation folder if the site configuration is set to not keep the simulation.

Logging

Logs the start and completion of the post-processing steps.

preprocess

adapter.FiatAdapter.preprocess(scenario: Scenario)

Preprocess the FIAT-model given a scenario by setting up projections, measures, and hazards, and then saves any changes made to disk.

Args: scenario (Scenario): The scenario to preprocess, which includes projection, strategy, and hazard.

Returns

: None

read

adapter.FiatAdapter.read(path: Path)

Read the fiat model from the current model root.

read_outputs

adapter.FiatAdapter.read_outputs()

Read the output FIAT CSV file specified in the model configuration and stores the data in the outputs attribute.

Attributes

outputs : dict

A dictionary containing the following keys: - “path” : Path The path to the output directory. - “table” : DataFrame The contents of the output CSV file.

run

adapter.FiatAdapter.run(scenario)

Execute the full process for a given scenario, including preprocessing, executing the simulation, and postprocessing steps.

Args: scenario: An object containing the scenario data.

Returns

: None

save_aggregation_spatial

adapter.FiatAdapter.save_aggregation_spatial(
    aggr_label: str,
    metrics_path: os.PathLike,
    output_path: os.PathLike,
)

Save aggregated metrics to a spatial file.

Parameters

aggr_label : str

The label of the aggregation area.

metrics_path : os.PathLike

The path to the metrics file.

output_path : os.PathLike

The path where the output spatial file will be saved.

save_building_footprints

adapter.FiatAdapter.save_building_footprints(output_path: os.PathLike)

Aggregate impacts at a building footprint level and then saves to an output file.

Parameters

output_path : os.PathLike

The path where the output spatial file will be saved.

Raises

: ValueError

If no building footprints are provided in the configuration.

save_roads

adapter.FiatAdapter.save_roads(output_path: os.PathLike)

Save the impacts on roads to a spatial file.

Parameters

output_path : os.PathLike

The path where the output spatial file will be saved.

set_hazard

adapter.FiatAdapter.set_hazard(
    map_fn: Union[os.PathLike, list[os.PathLike]],
    map_type: FloodmapType,
    var: str,
    is_risk: bool = False,
    units: str = us.UnitTypesLength.meters,
)

Set the hazard map and type for the FIAT model.

Parameters

map_fn : str

The filename of the hazard map.

map_type : FloodmapType

The type of the flood map.

var : str

The variable name in the hazard map.

is_risk : bool = False

Flag indicating if the map is a risk output. Defaults to False.

units : str = us.UnitTypesLength.meters

The units of the hazard map. Defaults to us.UnitTypesLength.meters.

write

adapter.FiatAdapter.write(
    path_out: Union[str, os.PathLike],
    overwrite: bool = True,
)

Write the fiat model configuration to a directory.

Back to top