# 
# RiskScape™ Copyright New Zealand Institute for Earth Science Limited
# (Earth Sciences New Zealand) is distributed for research purposes only
# under the terms of AGPLv3.
# 
# RiskScape™ Copyright 2026 New Zealand Institute for Earth Science
# Limited (Earth Sciences New Zealand). All rights reserved. Source code
# available under the AGPLv3.
# 
# This program is free software: you can redistribute it and/or modify it under
#  the terms of the GNU Affero General Public License as published by the Free
#  Software Foundation, either version 3 of the License, or (at your option) any
#  later version.
# 
# This program is distributed for RESEARCH PURPOSES ONLY, in the hope that it will
# be useful for research and education initiatives.
# 
# If you are not a researcher, or you are a researcher who wishes to use this
# program on terms other than AGPLv3 (including those who wish to restrict the
# distribution of any source code created using this program), please contact:
# https://riskscape.org.nz
# 
# This program is distributed WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Affero General Public License for more details.  You should have received a copy
# of the GNU Affero General Public License along with this program.  If not, see
# <http://www.gnu.org/licenses/>.
# 
# By way of summary only, under the AGPLv3:
#     • Permissions of this strongest copyleft license are conditioned
#       on making available complete source code of licensed works and
#       modifications, which include larger works using a licensed work,
#       under the same license.
#     • Copyright and license notices must be preserved.
#     • Contributors provide an express grant of patent rights.
#     • When a modified version is used to provide a service over a
#       network, the complete source code of the modified version must be made
#       available.
# 
[project]
description = Example models to demonstrate different modelling techniques

[bookmark Buildings_SE_Upolu]
location = data/Buildings_SE_Upolu.shp

[bookmark SPT_inundation_10m_grid]
location = data/MaxEnv_All_Scenarios_10m.tif

[model sample-centroid]
description = Exposure model that uses centroid spatial sampling
framework = wizard
input-exposures.layer = data/Buildings_SE_Upolu.shp
input-exposures.geoprocess = false
input-hazards.layer = data/MaxEnv_All_Scenarios_10m.tif
sample.hazards-by = CENTROID
analysis.function = is_exposed
report-event-impact.group-by[0] = 'Total' as Results
report-event-impact.aggregate[0] = count(hazard) as Number_Exposed
report-event-impact.aggregate[1] = count(exposure) as Total_buildings
report-event-impact.aggregate[2] = max(hazard) as Max_hazard
report-event-impact.aggregate[3] = mean(hazard) as Average_hazard

[model sample-closest]
description = Exposure model that uses closest spatial sampling
framework = wizard
input-exposures.layer = data/Buildings_SE_Upolu.shp
input-exposures.geoprocess = false
input-hazards.layer = data/MaxEnv_All_Scenarios_10m.tif
sample.hazards-by = CLOSEST
analysis.function = is_exposed
report-event-impact.group-by[0] = 'Total' as Results
report-event-impact.aggregate[0] = count(hazard) as Number_Exposed
report-event-impact.aggregate[1] = count(exposure) as Total_buildings
report-event-impact.aggregate[2] = max(hazard) as Max_hazard
report-event-impact.aggregate[3] = mean(hazard) as Average_hazard

[model sample-all-intersections]
description = Exposure model that uses all-intersections spatial sampling
framework = wizard
input-exposures.layer = data/Buildings_SE_Upolu.shp
input-exposures.geoprocess = false
input-hazards.layer = data/MaxEnv_All_Scenarios_10m.tif
sample.hazards-by = ALL_INTERSECTIONS
analysis.aggregate-hazards = true
analysis.aggregate-hazards-function = max
analysis.function = is_exposed
report-event-impact.group-by[0] = 'Total' as Results
report-event-impact.aggregate[0] = count(hazard) as Number_Exposed
report-event-impact.aggregate[1] = count(exposure) as Total_buildings
report-event-impact.aggregate[2] = max(hazard) as Max_hazard
report-event-impact.aggregate[3] = mean(hazard) as Average_hazard

[model aggregate-hazard]
description = Turns multiple hazard intensities into a single measurement for each building
framework = wizard
input-exposures.layer = data/Buildings_SE_Upolu.shp
input-exposures.geoprocess = false
input-hazards.layer = data/MaxEnv_All_Scenarios_10m.tif
sample.hazards-by = ALL_INTERSECTIONS
sample.hazards-buffer = 0
analysis.aggregate-hazards = true
analysis.aggregate-hazards-function = mean
analysis.function = Samoa_Building_Fragility_DS5
report-event-impact.filter = hazard > 0
report-event-impact.group-by[0] = 'Total' as Results
report-event-impact.aggregate[0] = count(exposure) as Number_Exposed
report-event-impact.aggregate[1] = percentiles(consequence, [25, 50, 75]) as DS5_Percentile

[model aggregate-consequence]
description = Computes multiple consequences for each building and turns it into a single outcome
framework = wizard
input-exposures.layer = data/Buildings_SE_Upolu.shp
input-exposures.geoprocess = false
input-hazards.layer = data/MaxEnv_All_Scenarios_10m.tif
sample.hazards-by = ALL_INTERSECTIONS
analysis.aggregate-hazards = false
analysis.aggregate-consequences = true
analysis.aggregate-consequences-function = mean
analysis.scale-losses = false
analysis.function = Samoa_Building_Fragility_DS5
report-event-impact.filter = length(hazard) > 0
report-event-impact.group-by[0] = 'Total' as Results
report-event-impact.aggregate[0] = count(exposure) as Number_Exposed
report-event-impact.aggregate[1] = percentiles(consequence, [25, 50, 75]) as DS5_Percentile

[function Samoa_Building_Fragility_DS5]
description = determines the probability of a building being in Damage State 5 (complete structural collapse)
location = functions/Samoa_Building_Fragility_DS5.py
argument-types = [ building: struct(Cons_Frame: text), hazard_depth: nullable(floating) ]
return-type = floating
framework = jython

[function CPython_Building_Fragility_DS5]
description = Same as Samoa_Building_Fragility_DS5, but in CPython
location = functions/CPython_Building_Fragility_DS5.py
argument-types = [ building: struct(Cons_Frame: text), hazard_depth: nullable(floating) ]
return-type = floating
framework = cpython

