def animate(self, alpha, div=4, particle='tr+'): s = settings.Settings() app = mag.Application() field = RadialField() field.alpha = alpha field.Bz0 = app.fieldBaseStrength[2] outfile = self.filename(particle, alpha) s.outfile = outfile with open(s.outpath()) as f: t, x, y, z = extractData(f, [0, 1, 2, 3]) length = len(z) / div for i in xrange(div): # start = i * length # if i > 0: # start = (i) * length start=0 end = (i+1) * length # Plot front view, no real way to refactor these *sigh* plt.plot(x[start:end], y[start:end], self.style[particle], linewidth=1, label=self.label(particle)) xmin, xmax = [ -0.03, 0.03 ] ymin, ymax = [ -0.03, 0.03 ] self.plotField(field, xmin, xmax, ymin, ymax, orientation='front') plt.xlabel('$x$ (m)') plt.ylabel('$y$ (m)') plt.tight_layout() s.outext = '_long_front_{index:03}.pdf'.format(index=i) plt.savefig(s.outpath()) plt.show() plt.clf() # Plot right view, no real way to refactor these *sigh* plt.plot(z[start:end], y[start:end], self.style[particle], linewidth=1, label=self.label(particle)) xmin, xmax = [ 0.0, 25 ] ymin, ymax = [ -0.03, 0.03 ] self.plotField(field, xmin, xmax, ymin, ymax, orientation='right') plt.xlabel('$z$ (m)') plt.ylabel('$y$ (m)') plt.tight_layout() s.outext = '_long_right_{index:03}.pdf'.format(index=i) plt.savefig(s.outpath()) plt.show() plt.clf()
def plotSuperimposed(self, alpha): s = settings.Settings() app = mag.Application() field = RadialField() field.alpha = alpha field.Bz0 = app.fieldBaseStrength[2] for particle in self.particles: outfile = self.filename(particle, alpha) s.outfile = outfile with open(s.outpath()) as f: t, x, y, z = extractData(f, [0, 1, 2, 3]) plt.plot(x, y, self.style[particle], label=self.label(particle)) xmin, xmax = [ -0.03, 0.03 ] ymin, ymax = [ -0.03, 0.03 ] self.plotField(field, xmin, xmax, ymin, ymax) plt.xlabel('$z$ (m)') plt.ylabel('$y$ (m)') plt.tight_layout() plt.show()
def plotSuperimposed(self, alpha): s = settings.Settings() app = mag.Application() field = RadialField() field.alpha = alpha field.Bz0 = app.fieldBaseStrength[2] for particle in self.particles: outfile = self.filename(particle, alpha) s.outfile = outfile with open(s.outpath()) as f: t, x, y, z = extractData(f, [0, 1, 2, 3]) plt.plot(x, y, self.style[particle], label=self.label(particle)) xmin, xmax = [-0.03, 0.03] ymin, ymax = [-0.03, 0.03] self.plotField(field, xmin, xmax, ymin, ymax) plt.xlabel('$z$ (m)') plt.ylabel('$y$ (m)') plt.tight_layout() plt.show()
def animate(self, alpha, div=4, particle='tr+'): s = settings.Settings() app = mag.Application() field = RadialField() field.alpha = alpha field.Bz0 = app.fieldBaseStrength[2] outfile = self.filename(particle, alpha) s.outfile = outfile with open(s.outpath()) as f: t, x, y, z = extractData(f, [0, 1, 2, 3]) length = len(z) / div for i in xrange(div): # start = i * length # if i > 0: # start = (i) * length start = 0 end = (i + 1) * length # Plot front view, no real way to refactor these *sigh* plt.plot(x[start:end], y[start:end], self.style[particle], linewidth=1, label=self.label(particle)) xmin, xmax = [-0.03, 0.03] ymin, ymax = [-0.03, 0.03] self.plotField(field, xmin, xmax, ymin, ymax, orientation='front') plt.xlabel('$x$ (m)') plt.ylabel('$y$ (m)') plt.tight_layout() s.outext = '_long_front_{index:03}.pdf'.format(index=i) plt.savefig(s.outpath()) plt.show() plt.clf() # Plot right view, no real way to refactor these *sigh* plt.plot(z[start:end], y[start:end], self.style[particle], linewidth=1, label=self.label(particle)) xmin, xmax = [0.0, 25] ymin, ymax = [-0.03, 0.03] self.plotField(field, xmin, xmax, ymin, ymax, orientation='right') plt.xlabel('$z$ (m)') plt.ylabel('$y$ (m)') plt.tight_layout() s.outext = '_long_right_{index:03}.pdf'.format(index=i) plt.savefig(s.outpath()) plt.show() plt.clf()