adapter.fiat_adapter.FiatAdapter(
self ,
model_root,
config= None ,
exe_path= None ,
delete_crashed_runs= True ,
config_base_path= 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
Methods
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.fiat_adapter.FiatAdapter.add_equity(
aggr_label,
metrics_path,
damage_column_pattern= 'TotalDamageRP {rp} ' ,
gamma= 1.2 ,
)
Calculate equity-based damages for a given aggregation label.
Parameters
aggr_label
str
The label of the aggregation area.
required
metrics_path
os.PathLike
The path to the metrics file.
required
damage_column_pattern
str
The pattern for the damage column names, by default “TotalDamageRP{rp}”.
'TotalDamageRP{rp}'
gamma
float
The equity weight parameter, by default 1.2
1.2
add_exceedance_probability
adapter.fiat_adapter.FiatAdapter.add_exceedance_probability(
column,
threshold,
period,
)
Calculate exceedance probabilities and append them to the results table.
Parameters
column
str
The name of the column to calculate exceedance probabilities for.
required
threshold
float
The threshold value for exceedance probability calculation.
required
period
int
The return period for exceedance probability calculation.
required
Returns
pd.DataFrame
The updated results table with exceedance probabilities appended.
add_measure
adapter.fiat_adapter.FiatAdapter.add_measure(measure)
Add and apply a specific impact measure to the properties of the FIAT model.
Parameters
measure
IMeasure
The impact measure to be applied. It can be of type Elevate, FloodProof, or Buyout.
required
The
required
If
required
add_projection
adapter.fiat_adapter.FiatAdapter.add_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.
required
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.fiat_adapter.FiatAdapter.apply_economic_growth(
economic_growth,
ids= 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.
required
ids
Optional[list]
A list of object IDs to which the economic growth should be applied. If None, the growth is applied to all buildings.
None
apply_population_growth_existing
adapter.fiat_adapter.FiatAdapter.apply_population_growth_existing(
population_growth,
ids= 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.
required
ids
Optional[list[str]]
A list of object IDs to filter the updates. If None, the updates are applied to all buildings.
None
apply_population_growth_new
adapter.fiat_adapter.FiatAdapter.apply_population_growth_new(
population_growth,
ground_floor_height,
elevation_type,
area_path,
ground_elevation= 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.
required
ground_floor_height
float
The height of the ground floor.
required
elevation_type
str
The type of elevation reference to use. Must be either ‘floodmap’ or ‘datum’.
required
area_path
str
The path to the area file.
required
ground_elevation
Union[None, str, Path]
The ground elevation reference. Default is None.
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.fiat_adapter.FiatAdapter.buyout_properties(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.
required
close_files
adapter.fiat_adapter.FiatAdapter.close_files()
Close all open files and clean up file handles.
create_infographics
adapter.fiat_adapter.FiatAdapter.create_infographics(
name,
output_base_path,
config_base_path,
metrics_path,
mode= Mode.single_event,
)
Create infographic files based on the provided metrics and configuration.
Parameters
name
str
The name of the scenario.
required
output_base_path
os.PathLike
The base path where the output files will be saved.
required
config_base_path
os.PathLike
The base path where the configuration files are located.
required
metrics_path
os.PathLike
The path to the metrics file.
required
mode
Mode
The mode of the infographic, by default Mode.single_event.
Mode.single_event
create_infometrics
adapter.fiat_adapter.FiatAdapter.create_infometrics(
metric_config_paths,
metrics_output_path,
)
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.
required
metrics_output_path
os.PathLike
The path where the metrics output file will be saved.
required
Raises
FileNotFoundError
If a mandatory metric configuration file does not exist.
delete_model
adapter.fiat_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.fiat_adapter.FiatAdapter.elevate_properties(elevate)
Elevate the ground floor height of properties based on the provided Elevate measure.
Parameters
elevate
Elevate
The Elevate measure containing the elevation details.
required
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.fiat_adapter.FiatAdapter.execute(
path= None ,
exe_path= None ,
delete_crashed_runs= None ,
strict= True ,
)
Execute the FIAT model.
Parameters
path
Optional[os.PathLike]
The path to the model directory. If not provided, defaults to self.model_root
.
None
exe_path
Optional[os.PathLike]
The path to the FIAT executable. If not provided, defaults to self.exe_path
.
None
delete_crashed_runs
Optional[bool]
Whether to delete files from crashed runs. If not provided, defaults to self.delete_crashed_runs
.
None
strict
bool
Whether to raise an error if the FIAT model fails to run. Defaults to True.
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.fiat_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.fiat_adapter.FiatAdapter.floodproof_properties(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.
required
get_all_building_ids
adapter.fiat_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.fiat_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.fiat_adapter.FiatAdapter.get_object_ids(measure)
Retrieve the object IDs for a given impact measure.
Parameters
measure
IMeasure
The impact measure for which to retrieve object IDs.
required
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.fiat_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.fiat_adapter.FiatAdapter.has_run(scenario)
Check if the impact results file for the given scenario exists.
Parameters
scenario
IScenario
The scenario for which to check the FIAT results.
required
Returns
bool
True if the FIAT results file exists, False otherwise.
postprocess
adapter.fiat_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.
required
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.fiat_adapter.FiatAdapter.preprocess(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 (IScenario): The scenario to preprocess, which includes projection, strategy, and hazard.
read
adapter.fiat_adapter.FiatAdapter.read(path)
Read the fiat model from the current model root.
read_outputs
adapter.fiat_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.fiat_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.
save_aggregation_spatial
adapter.fiat_adapter.FiatAdapter.save_aggregation_spatial(
aggr_label,
metrics_path,
output_path,
)
Save aggregated metrics to a spatial file.
Parameters
aggr_label
str
The label of the aggregation area.
required
metrics_path
os.PathLike
The path to the metrics file.
required
output_path
os.PathLike
The path where the output spatial file will be saved.
required
save_roads
adapter.fiat_adapter.FiatAdapter.save_roads(output_path)
Save the impacts on roads to a spatial file.
Parameters
output_path
os.PathLike
The path where the output spatial file will be saved.
required
set_hazard
adapter.fiat_adapter.FiatAdapter.set_hazard(
map_fn,
map_type,
var,
is_risk= False ,
units= us.UnitTypesLength.meters,
)
Set the hazard map and type for the FIAT model.
Parameters
map_fn
str
The filename of the hazard map.
required
map_type
FloodMapType
The type of the flood map.
required
var
str
The variable name in the hazard map.
required
is_risk
bool
Flag indicating if the map is a risk output. Defaults to False.
False
units
str
The units of the hazard map. Defaults to us.UnitTypesLength.meters.
us.UnitTypesLength.meters
write
adapter.fiat_adapter.FiatAdapter.write(path_out, overwrite= True )
Write the fiat model configuration to a directory.