def addRBF(self, newXt, n=1000, qhull_opts="", output=True, makeHull=True): sampled=False; x=1.0;i=0 while not(sampled): diff=self.Xt-newXt diff[:,2]*=self.vref*x diff*=diff diff=diff.sum(1) diff=np.sqrt(diff) index=np.argpartition(diff, n)[:n] #provide the indices of the n closest points points=self.array[index,:] rsampled=len(set(points[:,0]))>5 zsampled=len(set(points[:,1]))>5 tsampled=len(set(points[:,2]))>5 if rsampled and zsampled and tsampled: sampled=True elif not(rsampled and zsampled): x*=2;i+=1 else: x/=1.3;i+=1 if i>=100: sampled=True print "max iterations reached, forcing convergence" if output: print("creating RBF at ", newXt) def dist_func(X1,X2): X=X1[:-1,...]-X2[:-1,...] T=(X1[-1,...]-X2[-1,...])*self.vref return np.sqrt((X**2).sum(0)+T**2) RBFu=Rbf(points[:,0], points[:,1], points[:,2], points[:,3],\ norm=dist_func, smooth=0, epsilon=5e2) RBFw=Rbf(points[:,0], points[:,1], points[:,2], points[:,4],\ norm=dist_func, smooth=0, epsilon=5e2) if makeHull: hull=Delaunay(RBFu.xi.T, qhull_options="QJ10000 "+qhull_opts) #creates a convex hull around the points used to construct the RBF RBFu.hull=hull #a point cant be tested to be interior to the hull with: RBFw.hull=hull #RBF.hull.find_simplex([r,z,t])>=0 RBFu.centre=points.mean(0) RBFw.centre=points.mean(0) self.RBFs.appendleft([RBFu, RBFw])