def plotSuperimposed(self, alpha, beta): s = settings.Settings() app = mag.Application() field = SmoothField() field.alpha = alpha field.beta = beta field.Bz0 = app.fieldBaseStrength[0] for particle in self.particles: outfile = self.filename(particle, alpha, beta) s.outfile = outfile with open(s.outpath()) as f: t, x, y, z = extractData(f, [0, 1, 2, 3]) start = len(z) / 4 - 100 end = len(z) / 4 + 260 # start = 0 # end = len(z) plt.plot(z[start:end], y[start:end], self.style[particle], linewidth=1, label=self.label(particle)) # self.plotField(field, -1.6, 1.6, 0.35, 0.6) xmin, xmax = plt.xlim() ymin, ymax = plt.ylim() self.plotField(field, xmin, xmax, ymin, ymax) plt.xlabel('z (m)') plt.ylabel('y (m)') plt.tight_layout() plt.show()
def animate(self, alpha, beta, div=4, particle='tr+'): s = settings.Settings() app = mag.Application() field = SmoothField() field.alpha = alpha field.beta = beta field.Bz0 = app.fieldBaseStrength[0] outfile = self.filename(particle, alpha, beta) 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-1) * length # start=0 end = (i+1) * length if i > 0: plt.plot(z[0:start], y[0:start], 'm-', alpha=0.5, linewidth=0.5, label=self.label(particle)) plt.plot(z[start:end], y[start:end], self.style[particle], linewidth=1, label=self.label(particle)) self.plotField(field, -1.6, 1.6, 0.35, 0.6) # xmin, xmax = plt.xlim() # ymin, ymax = plt.ylim() # self.plotField(field, xmin, xmax, ymin, ymax) plt.xlabel('$z$ (m)') plt.ylabel('$y$ (m)') plt.tight_layout() s.outext = '_{index:03}.pdf'.format(index=i) plt.savefig(s.outpath()) plt.show() plt.clf()