# 
# 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 determine buildings in south-east Upolu exposed to inundation, \
    based on data that models the 2009 tsunami

[model total-exposed]
description = Summarizes the total number of exposed buildings
framework = wizard
input-exposures.layer = Buildings_SE_Upolu.shp
input-exposures.geoprocess = false
input-hazards.layer = MaxEnv_All_Scenarios_50m.tif
sample.hazards-by = CLOSEST
analysis.function = is_exposed
reports.name[0] = summary
report-event-impact.select[0] = *
report-summary.group-by[0] = 'Total' as Results
report-summary.aggregate[0] = count(hazard) as Number_Exposed
report-summary.aggregate[1] = count(exposure) as Total_buildings
report-summary.aggregate[2] = bucket_range(pick: hazard, select: { count(*) }, range: [ 1, 2, 3 ]) as Depth
report-summary.format = csv

[model exposed-by-region]
description = Model that summarizes the exposed elements-at-risk by region
framework = wizard
input-exposures.layer = Buildings_SE_Upolu.shp
input-exposures.geoprocess = false
input-hazards.layer = MaxEnv_All_Scenarios_50m.tif
input-areas.layer = Samoa_constituencies.shp
input-areas.geoprocess = false
sample.hazards-by = CLOSEST
# some buildings are offshore, so match them to the nearest region (up to 1km away)
sample.areas-buffer = 1000
analysis.function = is_exposed
reports.name[0] = summary
report-event-impact.select[0] = *
report-summary.group-by[0] = area.Region as Region
report-summary.aggregate[0] = count(hazard) as Number_Exposed
report-summary.aggregate[1] = count(exposure) as Total_buildings
report-summary.aggregate[2] = bucket_range(pick: hazard, select: { count(*) }, range: [ 1, 2, 3 ]) as Depth
report-summary.sort-by[0][attribute] = Region
report-summary.sort-by[0][direction] = ASC
report-summary.format = csv

[model building-damage]
description = Model that calculates building damage
framework = pipeline
location = building-damage-pipeline.txt

[type damage_states]
type.DS_1 = floating
type.DS_2 = floating
type.DS_3 = floating
type.DS_4 = floating
type.DS_5 = floating

[function Samoa_Building_Fragility]
description = Samoa tsunami fragility functions for buildings
location = Samoa_Building_Fragility.py
argument-types = [building: struct(Cons_Frame: text), hazard: nullable(floating)]
return-type = damage_states
framework = jython

[bookmark Building SE Upolu (exposure-layer)]
description = Buildings in south-eastern Upolu (Source: Open Street Maps)
location = Buildings_SE_Upolu.shp

[bookmark Samoa constituencies (area-layer)]
description = Electoral constituency boundaries for Samoa (Source: PCRAFI)
location = Samoa_constituencies.shp

[bookmark SPT inundation 50m grid (hazard-layer)]
description = Inundation depth from South Pacific Tsunami with 50m grid resolution
location = MaxEnv_All_Scenarios_50m.tif

