def elam_spline(xin, yin, yspl_in, x):
    """ interpolate values from Elam photoabsorption and scattering tables,
    according to Elam, Numerical Recipes.  Calc borrowed from D. Dale.
    """
    x = as_ndarray(x)
    x[np.where(x < min(xin))] =  min(xin)
    x[np.where(x > max(xin))] =  max(xin)

    lo, hi = np.array([(np.flatnonzero(xin < e)[-1],
                        np.flatnonzero(xin > e)[0])
                       for e in x]).transpose()

    diff = xin[hi] - xin[lo]
    if any(diff <= 0):
        raise ValueError('x must be strictly increasing')
    a = (xin[hi] - x) / diff
    b = (x - xin[lo]) / diff
    return (a * yin[lo] + b * yin[hi] +
            (diff*diff/6) * ((a*a - 1) * a * yspl_in[lo] +
                             (b*b - 1) * b * yspl_in[hi] ))
dataset/ETHPy150Open xraypy/xraylarch/plugins/xray/xraydb.py/elam_spline/original