def plot_trajectories(self, ax1): X1 = np.copy(self.Time.data.X) Y1 = np.copy(self.Time.data.Y) p1 = np.copy(self.Time.data.p) t = np.copy(self.Time.data.t[0]) tb = int(input("time frame 2?")) self.time(tb) self.Time.timelist() #self.plotsquares(ax1,tb,color="b") self.Time.fields(['t', 'Y', 'X', 'p']) ax1.scatter(self.Time.data.X, self.Time.data.Y, color="b") X2 = np.copy(self.Time.data.X) Y2 = np.copy(self.Time.data.Y) p2 = np.copy(self.Time.data.p) #;t2=F.Time.data.t print("test") for pp, id1, xx1, yy1 in zip(p1, range(len(p1)), X1, Y1): id2 = np.where(p2 == pp)[0] if len(id2) == 1: xx2 = X2[id2] yy2 = Y2[id2] print([xx1, xx2, yy1, yy2]) ax1.plot([xx1, xx2], [yy1, yy2], color="k", lw=1) elif len(id2) > 1: print("Strange, particle %s found twice at time step %s" % (pp, tb)) pi1, ix1 = Tools.pick(p1, X1, Y1) #self.plotsquares(ax1,t,p=[pi1],color="r",alpha=1) ax1.scatter(self.Time.data.X, self.Time.data.Y, color="r") pi2, ix2 = Tools.pick(p2, X2, Y2) self.plotsquares(ax1, tb, p=[pi2], color="r", alpha=1) self.part(pi1) self.Part.fields(["X", "Y", "t"]) Xp1 = np.copy(self.Part.data.X) Yp1 = np.copy(self.Part.data.Y) tp1 = np.copy(self.Part.data.t) self.part(pi2) self.Part.fields(["X", "Y", "t"]) Xp2 = np.copy(self.Part.data.X) Yp2 = np.copy(self.Part.data.Y) tp2 = np.copy(self.Part.data.t) #ax1.plot(Xp1,Yp1,color="r") #ax1.plot(Xp2,Yp2,color="b") self.fig2 = plt.figure(2, figsize=(8, 8)) self.ax2 = self.fig2.add_axes([0.1, 0.1, .8, .4]) self.ax2b = self.fig2.add_axes([0.1, 0.55, .8, .4]) self.ax2.plot(tp1, Xp1, color="r") self.ax2.plot(tp2, Xp2, color="b") self.ax2b.plot(tp1, Yp1, color="r") self.ax2b.plot(tp2, Yp2, color="b") self.pi1 = pi1 self.pi2 = pi2 x = plt.ginput(1)
def assign_nx(self, ax1): X1 = self.Time.data.X Y1 = self.Time.data.Y p1 = self.Time.data.p pi1, ix1 = Tools.pickrectangle(ax1, p1, X1, Y1) x = plt.ginput() conf = int(input('which nx?\n')) self.updatenx(pi1, conf)
def remove_particle(self, ax1): X1 = self.Time.data.X Y1 = self.Time.data.Y p1 = self.Time.data.p t = self.Time.data.t[0] pi1, ix1 = Tools.pick(p1, X1, Y1) self.plotsquares(ax1, t, p=[pi1], color="b") #F.drawellipse(ax1,pi1,t1[ix1],color='b',linestyle='-',linewidth=1) x = plt.ginput(1) conf = input('continue? (1=y/0=n)\n') if conf == "1": self.remove(pi1) self.compress_indexes()
def remove_batch_particles(self, ax1): X1 = self.Time.data.X Y1 = self.Time.data.Y p1 = self.Time.data.p t = self.Time.data.t[0] go = "1" ps = [] while go == "1": pi1, ix1 = Tools.pick(p1, X1, Y1) ps += [pi1] self.plotsquares(ax1, t, p=[pi1], color="b") go = input("keep on selecting particles? (1=y/0=n)\n") x = plt.ginput(1) conf = input('This will erase the particles, continue? (1=y/0=n)\n') if conf == "1": self.remove_batch(ps) self.compress_indexes()