Kia ora,
That’s a scoped lambda type. There’s an explanation in the docs about what RiskScape lambda expressions are here:
https://riskscape.org.nz/docs/intermediate/write-expressions.html#lambda-expressions
The ‘scoped’ part just means the lambda expression can access any other attributes that are accessible for that particular pipeline step (e.g. exposure attributes).
The create_continuous()
function expects a lambda expression that will yield a y
value for a given x
value. (Replace x and y with domain-appropriate modelling terminology, e.g. x=flood depth, y=DR). For example, a simple example of a lambda expression might be: x -> if(x > 500, then: 0.2, else: 0.1)
.
This is not exactly what you want here. What you want is more like ‘given a predetermined x value, return a predetermined y value’. The simplest way to do this in a pipeline is via a ‘lookup table’. Here’s an example:
input(value: { x_point: [0.0,500.0,1000.0], y_point: [0.0,0.1,0.2] })
->
unnest([x_point, y_point]) as foo
->
group({ to_lookup_table(key: x_point, value: y_point, options: { unique: true }) as lookup_table })
->
select({
create_continuous(
[0.0,500.0,1000.0],
x -> lookup(lookup_table, x)) as testCurve
})
->
select({
apply_continuous(testCurve, 250) as y250,
apply_continuous(testCurve, 750) as y750
})
Hope that helps.
Tim