class movie(object): ''' ''' def __init__(self, hdf5_file, nPlot=1, ntMax=0, write=False): ''' Constructor ''' self.diagnostics = Diagnostics(hdf5_file) if ntMax > 0 and ntMax < self.diagnostics.nt: self.nt = ntMax else: self.nt = self.diagnostics.nt self.nPlot = nPlot self.plot = PlotMHD2D(self.diagnostics, self.diagnostics.nt, self.nt, nPlot, write) self.init() def init(self): self.update(0) def update(self, itime, final=False): self.diagnostics.read_from_hdf5(itime) self.diagnostics.update_invariants(itime) return self.plot.update(itime, final=final) def run(self, write=False): for itime in range(1, self.nt + 1): print("it = %4i" % (itime)) self.update(itime, final=(itime == self.nt))
class Plot(object): ''' ''' def __init__(self, hdf5_file, nPlot=1, ntMax=0): ''' Constructor ''' self.diagnostics = Diagnostics(hdf5_file) if ntMax > 0 and ntMax < self.diagnostics.nt: self.nt = ntMax else: self.nt = self.diagnostics.nt self.plot = PlotMHD2D(self.diagnostics, args.hdf5_file.replace(".hdf5", ""), self.nt, nPlot) def update(self, itime): self.diagnostics.read_from_hdf5(itime) self.diagnostics.update_invariants(itime) if itime > 0: self.plot.add_timepoint() self.plot.update() def run(self): for itime in range(1, self.nt + 1): print("it = %4i" % (itime)) self.update(itime)
def __init__(self, hdf5_file, nPlot=1): ''' Constructor ''' self.diagnostics = Diagnostics(hdf5_file) self.nPlot = nPlot self.plot = PlotMHD2D(self.diagnostics, self.diagnostics.nt, nPlot) self.init()
class replay(object): ''' ''' def __init__(self, hdf5_file, nPlot=1): ''' Constructor ''' self.diagnostics = Diagnostics(hdf5_file) self.nPlot = nPlot self.plot = PlotMHD2D(self.diagnostics, self.diagnostics.nt, nPlot) self.init() def init(self): self.update(0) def update(self, itime, final=False): self.diagnostics.read_from_hdf5(itime) self.diagnostics.update_invariants(itime) # if (itime == 0 or itime == 1 or (itime-1) % self.nPlot == 0 or itime-1 == self.plot.nTime): # self.diagnostics.calculate_divergence() # # print(" min(Bx) = %20.12E, max(Bx) = %20.12E" % (self.diagnostics.Bx.min(), self.diagnostics.Bx.max())) # # print(" min(By) = %20.12E, max(By) = %20.12E" % (self.diagnostics.By.min(), self.diagnostics.By.max())) # # print(" min(Vx) = %20.12E, max(Vx) = %20.12E" % (self.diagnostics.Vx.min(), self.diagnostics.Vx.max())) # # print(" min(Vy) = %20.12E, max(Vy) = %20.12E" % (self.diagnostics.Vy.min(), self.diagnostics.Vy.max())) # # print(" min(div B) = %20.12E, max(div B) = %20.12E" % (self.diagnostics.divB.min(), self.diagnostics.divB.max())) # # print(" min(div V) = %20.12E, max(div V) = %20.12E" % (self.diagnostics.divV.min(), self.diagnostics.divV.max())) # print(" energy = %20.12E" % self.diagnostics.energy) # print(" helicity = %20.12E" % self.diagnostics.helicity) # print(" max(div B) = %20.12E" % max(-self.diagnostics.divB.min(), self.diagnostics.divB.max())) # print(" max(div V) = %20.12E" % max(-self.diagnostics.divV.min(), self.diagnostics.divV.max())) # print return self.plot.update(itime, final=final) def run(self): for itime in range(1, self.diagnostics.nt + 1): print("it = %4i" % (itime)) self.update(itime, final=(itime == self.diagnostics.nt)) def movie(self, outfile, fps=1): self.plot.nPlot = 1 ani = animation.FuncAnimation(self.plot.figure, self.update, np.arange(1, self.diagnostics.nt + 1), init_func=self.init, repeat=False, blit=True) ani.save(outfile, fps=fps)
def __init__(self, hdf5_file, nPlot=1, ntMax=0, plotRef=False): ''' Constructor ''' self.diagnostics = Diagnostics(hdf5_file) if ntMax > 0 and ntMax < self.diagnostics.nt: self.nt = ntMax else: self.nt = self.diagnostics.nt self.plot = PlotMHD2D(self.diagnostics, args.hdf5_file.replace(".hdf5", ""), self.nt, nPlot, plotRef)
def __init__(self, hdf5_file, nPlot=1, ntMax=0, write=False): ''' Constructor ''' self.diagnostics = Diagnostics(hdf5_file) if ntMax > 0 and ntMax < self.diagnostics.nt: self.nt = ntMax else: self.nt = self.diagnostics.nt self.nPlot = nPlot self.plot = PlotMHD2D(self.diagnostics, self.diagnostics.nt, self.nt, nPlot, write)
parser.add_argument('hdf5_file', metavar='<run.hdf5>', type=str, help='Run HDF5 File') parser.add_argument('-np', metavar='i', type=int, default=1, help='plot every i\'th frame') parser.add_argument('-ntmax', metavar='i', type=int, default=0, help='limit to i points in time') args = parser.parse_args() print print("Replay run with " + args.hdf5_file) print diagnostics = Diagnostics(args.hdf5_file) ntMax=args.ntmax nPlot=args.np if ntMax > 0 and ntMax < diagnostics.nt: nt = ntMax else: nt = diagnostics.nt plot = PlotEnergy(diagnostics, args.hdf5_file.replace(".hdf5", ""), nt, nPlot) print print("Replay finished.") print