x, y, y2 = spline_extension(x_vals,y_vals, y2vals, xmin=None, xmax=None) returns the x, y, y2 table for the spline as needed by splint() with adjustments to allow quadratic extrapolation outside the range x[0]-x[-1], from xmin (or x[0] if xmin is None) to xmax (or x[-1] if xmax is None), working from x, y, y2 from an already-created spline Definition at line 58 of file spline.py. 00058 : 00059 """x, y, y2 = spline_extension(x_vals,y_vals, y2vals, xmin=None, xmax=None) 00060 returns the x, y, y2 table for the spline as needed by splint() with adjustments to allow quadratic extrapolation 00061 outside the range x[0]-x[-1], from xmin (or x[0] if xmin is None) to xmax (or x[-1] if xmax is None), 00062 working from x, y, y2 from an already-created spline""" 00063 00064 xl=[x] 00065 yl=[y] 00066 y2l=[y2] 00067 00068 if xmin is not None: 00069 h0=x[1]-x[0] 00070 h1=xmin-x[0] 00071 yextrap=y[0]+((y[1]-y[0])/h0 - h0*(y2[0]+2.0*y2[1])/6.0)*h1+y2[0]*h1*h1/2.0 00072 yl.insert(0, (yextrap,)) 00073 xl.insert(0, (xmin,)) 00074 y2l.insert(0, (y2[0],)) 00075 00076 if xmax is not None: 00077 h0=x[-1]-x[-2] 00078 h1=xmax-x[-1] 00079 yextrap=y[-1]+((y[-1]-y[-2])/h0 + h0*(2.0*y2[-2]+y2[-1])/6.0)*h1+y2[-1]*h1*h1/2.0 00080 yl.append((yextrap,)) 00081 xl.append((xmax,)) 00082 y2l.append((y2[-1],)) 00083 00084 return Numeric.concatenate(xl), Numeric.concatenate(yl), Numeric.concatenate(y2l) 00085 def spline_extrapolate(x, y, yp1=None, ypn=None, xmin=None, xmax=None):
|