# 
# 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 2025 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.
# 
[bookmark cities]
description = The location (point) of some New Zealand cities.
location = data/cities.csv
crs-name = EPSG:4326
set-attribute.geom = create_point(latitude, longitude)

[bookmark atmospheric]
description = A sample file from UniData. Has one time step of precipitation flux, \
  air temperature, and eastward wind.
location = https://archive.unidata.ucar.edu/software/netcdf/examples/sresa1b_ncar_ccsm3-example.nc
format = netcdf
# pr = precipitation_flux, tas = air_temperature
layer = pr, tas
crs-name = EPSG:4326
# the data has a lon range of 0 - 360. we need this -180 < lon <= 180
set-attribute.geom = create_point(lat, if(lon <= 180.0, lon, lon - 360.0))
# convert temperature in Kelvin -> Celsius
set-attribute.tas = tas - 273.15

[model atmospheric]
description = A basic example pipeline that spatially matches against NetCDF data \
  (joins NZ cities to atmospheric NetCDF data)
framework = pipeline
location = atmospheric-pipeline.txt
param.exposure_layer = 'cities'
# nearest neighbour cutoff distance to approximately 1 degrees in metres.
# there are 60 nautical miles per degree, and approx 2000m per nautical mile
param.nn_cutoff = 1 * 60 * 2000

[model atmospheric-join]
description = Same as atmospheric except it uses input + join steps instead of the bookmark() function
framework = pipeline
location = atmospheric-pipeline-join.txt
param.exposure_layer = 'cities'
# nearest neighbour cutoff distance to approximately 1 degrees in metres.
param.nn_cutoff = 1 * 60 * 2000


[bookmark sea-temperature]
description = A sample file from UniData. Has sea surface temperature at monthly intervals
location = https://archive.unidata.ucar.edu/software/netcdf/examples/tos_O1_2001-2002.nc
format = netcdf
layer = tos
crs-name = EPSG:4326
# convert temperature in Kelvin -> Celsius
set-attribute.tos = tos - 273.15
# longitude values are in the range 0 to 360. Convert them to -180 to 180 range
set-attribute.geom = create_point(lat, if(lon <= 180.0, lon, lon - 360.0))
# any point in the grid that's on land shows up as not a number (Nan).
# Filter these out so we only get sea temperature readings
filter = str(tos) != 'NaN'

[model sea-temperature]
description = An example pipeline that spatially matches against NetCDF data \
  with a time dimension
framework = pipeline
location = sea-temperature-pipeline.txt
param.exposure_layer = 'cities'
# nearest neighbour cutoff distance to approximately 2 degrees in metres.
param.nn_cutoff = 2 * 60 * 2000

[model sea-temperature-aggregated]
description = Same as sea-temperature model except it aggregates across the time dimension \
    instead of turning all time steps into a list
framework = pipeline
location = sea-temperature-aggregated-pipeline.txt
param.exposure_layer = 'cities'
# nearest neighbour max distance to approximately 2 degrees in metres.
param.nn_cutoff = 2 * 60 * 2000


[bookmark site-mesh]
description = Advanced: an example of building a geospatial site-mesh from NetCDF data
location = https://archive.unidata.ucar.edu/software/netcdf/examples/tos_O1_2001-2002.nc
format = netcdf
layer = tos
crs-name = EPSG:4326
# convert temperature in Kelvin -> Celsius
set-attribute.tos = tos - 273.15
# longitude values are in the range 0 to 360. Convert them to -180 to 180 range
set-attribute.geom = create_point(lat, if(lon <= 180.0, lon, lon - 360.0))
# just read data for the first time step (t=15)
filter = time = 15 and str(tos) != 'NaN'


[model scalable-netcdf]
description = Advanced: a 'flipped' version of the 'sea-temperature' pipeline that \
    turns the exposure-layer into a coverage and matches that against the NetCDF data
framework = pipeline
location = scalable-netcdf-pipeline.txt
param.exposure_layer = 'cities'
# nearest neighbour max distance to approximately 2 degrees in metres.
param.nn_cutoff = 2 * 60 * 2000
