y2 = spline(x_vals,y_vals, yp1=None, ypn=None) returns the y2 table for the spline as needed by splint() Definition at line 13 of file spline.py. 00013 : 00014 """y2 = spline(x_vals,y_vals, yp1=None, ypn=None) 00015 returns the y2 table for the spline as needed by splint()""" 00016 00017 n=len(x) 00018 u=zeros(n,Float) 00019 y2=zeros(n,Float) 00020 00021 x=asarray(x, Float) 00022 y=asarray(y, Float) 00023 00024 dx=x[1:]-x[:-1] 00025 dxi=1.0/dx 00026 dx2i=1.0/(x[2:]-x[:-2]) 00027 dy=(y[1:]-y[:-1]) 00028 siga=dx[:-1]*dx2i 00029 dydx=dy*dxi 00030 00031 # u[i]=(y[i+1]-y[i])/float(x[i+1]-x[i]) - (y[i]-y[i-1])/float(x[i]-x[i-1]) 00032 u[1:-1]=dydx[1:]-dydx[:-1] #this is an incomplete rendering of u... the rest requires recursion in the loop 00033 00034 if yp1 is None: 00035 y2[0]=u[0]=0.0 00036 else: 00037 y2[0]= -0.5 00038 u[0]=(3.0*dxi[0])*(dy[0]*dxi[0] -yp1) 00039 00040 for i in range(1,n-1): 00041 sig=siga[i-1] 00042 p=sig*y2[i-1]+2.0 00043 y2[i]=(sig-1.0)/p 00044 u[i]=(6.0*u[i]*dx2i[i-1] - sig*u[i-1])/p 00045 00046 if ypn is None: 00047 qn=un=0.0 00048 else: 00049 qn= 0.5 00050 un=(3.0*dxi[-1])*(ypn- dy[-1]*dxi[-1] ) 00051 00052 y2[-1]=(un-qn*u[-2])/(qn*y2[-2]+1.0) 00053 for k in range(n-2,-1,-1): 00054 y2[k]=y2[k]*y2[k+1]+u[k] 00055 00056 return y2 00057 def spline_extension(x, y, y2, xmin=None, xmax=None):
|