PlasmaCalcs.addons.instability_tools.instability_data_tools.pwl2_flatend

PlasmaCalcs.addons.instability_tools.instability_data_tools.pwl2_flatend(xx, b0, m0, end0)
evaluate xx at piecewise linear function with 2 pieces, with final piece slope=0.

xx: 1D array. Assumed to be monotonically increasing. b0: y-intercept of piece 0 m0: slope of piece 0 end0: “index” of end of piece 0

if end0 is not an int, does weighted averaging of xx[int(end0)] and xx[int(end0)+1].
E.g. end0 = 10.25 –> extend piece 0 to xx[10] + 0.25 * (xx[11] - xx[10])
b1 is computed based on the other inputs.
This is a decent approx. for ln(val) with linear growth then saturation.
xx <–> time
b0 <–> pre-growth noise level
m0 <–> growth rate
end0 <–> “saturation index” when linear growth stops.
x0 <–> “saturation time” when linear growth stops, where:
x0 = xx[i0] + (end0 - i0) * (xx[i0+1] - xx[i0], where i0 = int(end0).
y0 <–> “saturation level”; value when saturated, where:
y0 = m0 * x0 + b0.