def bilinear(x,y,F,px,py): i = search.bin(x,px) j = search.bin(y,py) a1 = F[i][j] a2 = F[i + 1][j] - F[i][j] a3 = F[i][j + 1] - F[i][j] a4 = F[i][j] - F[i + 1][j] - F[i][j + 1] + F[i + 1][j + 1] p = a1 + a2 * (px - x[i]) + a3 * (py - y[j]) + a4 * (px - x[i]) * (py - y[j]) return p
def bilinear(x, y, F, px, py): i = search.bin(x, px) j = search.bin(y, py) a1 = F[i][j] a2 = F[i + 1][j] - F[i][j] a3 = F[i][j + 1] - F[i][j] a4 = F[i][j] - F[i + 1][j] - F[i][j + 1] + F[i + 1][j + 1] p = a1 + a2 * (px - x[i]) + a3 * (py - y[j]) + a4 * (px - x[i]) * (py - y[j]) return p
def qinterp(x,y,z): qs = np.zeros(len(z)) dz = np.zeros(len(z)) qint = np.zeros(len(z)) dint = np.zeros(len(z)) dx = np.zeros(len(x)) dy = np.zeros(len(x)) a1 = np.zeros(len(x)) a2 = np.zeros(len(x)) a1[0]=0 a2[-1]=0 for i in range(len(x)-1): dx[i] = x[i+1]-x[i] dy[i] = y[i+1]-y[i] for i in range(len(z)-1): dz[i] = z[i+1]-z[i] for j in range(len(x)-1): a1[j+1] = 1/dx[j+1]*(dy[j+1]/dx[j+1]-dy[j]/dx[j]-a1[j]*dx[j]) for j in range(len(x)-3,-1,-1): a2[j] = 1/dx[j]*(dy[j+1]/dx[j+1]-dy[j]/dx[j]-a2[j+1]*dx[j+1]) a=(a1+a2)/2 for k in range(len(z)): l = search.bin(x,z[k]) qs[k] = y[l] + dy[l]/dx[l]*(z[k]-x[l])+a[l]*(z[k]-x[l])*(z[k]-x[l+1]) for i in range(len(z)-1): qint[i] = qs[i]*dz[i] dint[i] = (qs[i+1]-qs[i])/dz[i] qint = np.add.accumulate(qint) return qs,qint,dint
def linterp(x, y, z): ls=np.zeros(len(z)) dx = x[1:] - x[0:-1] dy = y[1:] - y[0:-1] for i in range(len(z)): l = search.bin(x,z[i]) ls[i] = y[l]+(z[i]-x[l])*(dy[l]/dx[l]) return ls
def linterp(x,y,z): ls=np.zeros(len(z)) dx=np.zeros(len(x)) dy=np.zeros(len(x)) for i in range(len(x)-1): dx[i] = x[i+1]-x[i] dy[i] = y[i+1]-y[i] for j in range(len(z)): l = search.bin(x,z[j]) ls[j] = y[l]+(dy[l]/dx[l])*(z[j]-x[l]) return ls
def qinterp(x,y,z): qs = np.zeros(len(z)) dx = np.zeros(len(x)) dy = np.zeros(len(x)) a1 = np.zeros(len(x)) a2 = np.zeros(len(x)) a1[0]=0 a2[-1]=0 for i in range(len(x)-1): dx[i] = x[i+1]-x[i] dy[i] = y[i+1]-y[i] for j in range(len(x)-1): a1[j+1] = 1/dx[j+1]*(dy[j+1]/dx[j+1]-dy[j]/dx[j]-a1[j]*dx[j]) for j in range(len(x)-3,-1,-1): a2[j] = 1/dx[j]*(dy[j+1]/dx[j+1]-dy[j]/dx[j]-a2[j+1]*dx[j+1]) a=(a1+a2)/2 for k in range(len(z)): l = search.bin(x,z[k]) qs[k] = y[l] + dy[l]/dx[l]*(z[k]-x[l])+a[l]*(z[k]-x[l])*(z[k]-x[l+1]) return qs