def extrap1d(interpolator):
    """
    Function to extend an interpolation function to an
    extrapolation function.

    :param interpolator: scipy interp1d object

    :returns ufunclike: extension of function to extrapolation
    """
    
    xs = interpolator.x
    ys = interpolator.y

    def pointwise(x):
        if x < xs[0]:
            return ys[0] # +(x-xs[0])*(ys[1]-ys[0])/(xs[1]-xs[0])
        elif x > xs[-1]:
            return ys[-1] # +(x-xs[-1])*(ys[-1]-ys[-2])/(xs[-1]-xs[-2])
        else:
            return interpolator(x)

    def ufunclike(xs):
        return N.array(map(pointwise, N.array(xs)))

    return ufunclike
def extrap1d ( interpolator ) : xs = interpolator . x ys = interpolator . y def pointwise ( x ) : if x < xs [ 0 ] : return ys [ 0 ] elif x > xs [ - 1 ] : return ys [ - 1 ] else : return interpolator ( x ) def ufunclike ( xs ) : return N . array ( map ( pointwise , N . array ( xs ) ) ) return ufunclike
Function to extend an interpolation function to an
    extrapolation function.

    :param interpolator: scipy interp1d object

    :returns ufunclike: extension of function to extrapolation