This is a an example of running a tiny single event FIAT model.
First of all, let’s make sure that there is some actual testdata.
! python ../ ../ .testdata/ create_test_data.py
/usr/share/miniconda3/envs/fiat_docs/lib/python3.11/site-packages/osgeo/osr.py:410: FutureWarning: Neither osr.UseExceptions() nor osr.DontUseExceptions() has been explicitly called. In GDAL 4.0, exceptions will be enabled by default.
warnings.warn(
Now that we have some testdata, let’s take a look at the settings file.
with open ("../../.testdata/settings.toml" , "r" ) as r:
settings = r.read()
print (settings)
[global]
crs = "EPSG:4326"
keep_temp_files = true
[output]
path = "output/event"
[output.csv]
name = "output.csv"
[output.geom]
name1 = "spatial.gpkg"
[hazard]
file = "hazard/event_map.nc"
crs = "EPSG:4326"
risk = false
elevation_reference = "DEM"
[exposure.csv]
file = "exposure/spatial.csv"
[exposure.geom]
file1 = "exposure/spatial.gpkg"
crs = "EPSG:4326"
[vulnerability]
file = "vulnerability/vulnerability_curves.csv"
step_size = 0.01
Now let’s execute the model!
! fiat run ../ ../ .testdata/ settings.toml
###############################################################
######### ## ## ##############
## ## #### ######
## ## #### ##
## ## ## ## ##
###### ## ## ## ##
## ## ######## ##
## ## ## ## ##
## ## ## ## ##
## ## ## ## ##
###############################################################
Fast Impact Assessment Tool
© Deltares
2024-02-19 15:02:25 INFO Delft-Fiat version: 0.1.0rc2
2024-02-19 15:02:25 INFO Setting up geom model..
2024-02-19 15:02:25 INFO Using settings from '/home/runner/work/Delft-FIAT/Delft-FIAT/docs/examples/../../.testdata/settings.toml'
2024-02-19 15:02:25 INFO Maximum number of threads: 4
2024-02-19 15:02:25 INFO Model srs set to: 'EPSG:4326'
2024-02-19 15:02:25 INFO Reading hazard data ('event_map.nc')
2024-02-19 15:02:25 INFO Executing hazard checks...
2024-02-19 15:02:25 INFO Reading vulnerability curves ('vulnerability_curves.csv')
2024-02-19 15:02:25 INFO Executing vulnerability checks...
2024-02-19 15:02:25 INFO Upscaling vulnerability curves, using a step size of: 0.01
2024-02-19 15:02:25 INFO Reading exposure data ('spatial.csv')
2024-02-19 15:02:25 INFO Executing exposure data checks...
2024-02-19 15:02:25 INFO Reading exposure geometry 'file1' ('spatial.gpkg')
2024-02-19 15:02:25 INFO Executing exposure geometry checks...
2024-02-19 15:02:25 INFO Starting the calculations
2024-02-19 15:02:25 INFO Using number of threads: 1
2024-02-19 15:02:25 INFO Submitting a job for the calculations in a seperate process
2024-02-19 15:02:25 INFO Busy...
2024-02-19 15:02:25 INFO Calculations time: 0.03 seconds
2024-02-19 15:02:25 INFO Producing model output from temporary files
2024-02-19 15:02:25 INFO Busy...
2024-02-19 15:02:25 INFO Output generated in: '/home/runner/work/Delft-FIAT/Delft-FIAT/docs/examples/../../.testdata/output/event'
2024-02-19 15:02:25 INFO Geom calculation are done!
Let’s take a quick look at the output.
# Import a method
from fiat.io import open_csv
from pathlib import Path
# check the output
out = open_csv(Path("../../.testdata/output/event" , "output.csv" ), index= "Object ID" )
print (out.columns)
('Extraction Method', 'Ground Floor Height', 'Ground Elevation', 'Damage Function: Structure', 'Max Potential Damage: Structure', 'Inundation Depth', 'Reduction Factor', 'Damage: Structure', 'Total Damage')
Assert that the output is what we would expect.
assert float (out[2 , "Total Damage" ]) == 740
assert float (out[3 , "Total Damage" ]) == 1038
Back to top