curve_interpolate

curve_interpolate(
    x,
    y,
    xout=None,
    yout=None,
    x_transform='none',
    y_transform='none',
    order_x='ascending',
    order_y='ascending',
    strict_x=True,
    strict_y=True,
)

Interpolate a paired x-y curve.

Mirrors the C# OrderedPairedData.GetYFromX/GetXFromY: linear interpolation over a curve that keeps itself sorted/validated against a caller-chosen monotonicity contract, with optional per-axis transforms (log10 or the standard normal z-score) applied before/after interpolation. Exactly one of xout/yout must be supplied.

Parameters

Name Type Description Default
x array_like Equal-length curve ordinates, at least two elements. required
y array_like Equal-length curve ordinates, at least two elements. required
xout array_like Positions to interpolate y at. None
yout array_like Positions to interpolate x at. None
x_transform ('none', 'logarithmic', 'log', 'normal_z') “log” is an accepted alias for “logarithmic” (both parse to the same value); “logarithmic” is the spelling used in this package’s own examples. "none"
y_transform ('none', 'logarithmic', 'log', 'normal_z') “log” is an accepted alias for “logarithmic” (both parse to the same value); “logarithmic” is the spelling used in this package’s own examples. "none"
order_x ('ascending', 'descending', 'none') "ascending"
order_y ('ascending', 'descending', 'none') "ascending"
strict_x bool Require x/y to strictly increase/decrease (per order_x/order_y) between consecutive ordinates. Default True. True
strict_y bool Require x/y to strictly increase/decrease (per order_x/order_y) between consecutive ordinates. Default True. True

Returns

Name Type Description
numpy.ndarray Same length as whichever of xout/yout was supplied.

Examples

>>> from corehydropy import curve_interpolate
>>> curve_interpolate([50, 100, 150, 200, 250], [100, 200, 300, 400, 500], xout=75)
array([150.])