Linear function to calculate weight transition between boundaries.
Arguments
- x
Numeric value to calculate weight from
- lwr
Numeric value for lower boundary. If
x <= lwr
the function returns 0 as a weight.- upr
Numeric value for upper boundary. If
x >= upr
the function returns 1 as a weight.
Examples
if (FALSE) {
# All examples below must be included in the dynamic
# rules in the management csv file to be effective.
# Low weight for days below 0 degC with a
# linear transition from 5 degC to 0 degC:
tmp <- -5:10
weight <- linear(tmp, 0, 5)
plot(tmp, weight)
# Low weight for days with high precipitation
# (transition range: 2 to 10 mm)
pcp <- 0:12
weight <- (1 - linear(pcp, 0, 5))
plot(pcp, weight)
# Harvesting crop in optimum PHU fraction range 1 to 1.1
hu_fr <- seq(0.75, 1.4, 0.01)
weight <- linear(hu_fr, 0.9, 1) * (1 - linear(hu_fr, 1.1, 1.2))
}