def plot(opt): """Plot just the stability criteria.""" import matplotlib.pyplot as plt Config = FloxConfiguration.fromfile(opt.configuration) Writer = HDF5Writer(opt.filename) fig = plt.figure(figsize=(11, 8.5)) for i, system in enumerate("stable critical unstable".split()): MVC = MultiViewController(fig, 3, 3, wspace=0.6, hspace=0.4) System = NDSystem2D.from_params(Config["system"]) Writer.read(System, "{}-{:d}".format(system, opt.mode)) print(System) MVC[0, i] = EvolutionViewStabilityTest("Temperature", opt.mode, System.nz // 3) MVC[1, i] = EvolutionViewStabilityTest("Vorticity", opt.mode, System.nz // 3) MVC[2, i] = EvolutionViewStabilityTest("Stream", opt.mode, System.nz // 3) MVC.views[0].ax.text(0.5, 1.25, system.capitalize(), transform=MVC.views[0].ax.transAxes, ha='center') MVC.update(System) fig.savefig(opt.plot, dpi=300)
def animate(opt): """Animate the data sets.""" from astropy.utils.console import ProgressBar import matplotlib matplotlib.rcParams['text.usetex'] = False import matplotlib.pyplot as plt Config = FloxConfiguration.fromfile(opt.configuration) Writer = HDF5Writer(opt.filename) fig = plt.figure(figsize=(11, 8.5)) Plots = [] for i, system in enumerate("stable critical unstable".split()): MVC = MultiViewController(fig, 3, 3, wspace=0.6, hspace=0.4) System = NDSystem2D.from_params(Config["system"]) Writer.read(System, "{}-{:d}".format(system, opt.mode)) print(System) MVC[0, i] = EvolutionViewStabilityTest("Temperature", opt.mode, System.nz // 3) MVC[1, i] = EvolutionViewStabilityTest("Vorticity", opt.mode, System.nz // 3) MVC[2, i] = EvolutionViewStabilityTest("Stream", opt.mode, System.nz // 3) System.it = 2 MVC.update(System) Plots.append((MVC, System)) with ProgressBar(System.nit - 2) as pbar: def update(i): """Animation""" for MVC, System in Plots: System.it = i + 2 MVC.update(System) pbar.update(i) anim = animation.FuncAnimation(fig, update, frames=int(System.nit) - 2, repeat=False) # anim.save(opt.movie, writer='ffmpeg') plt.show()
def plot(opt): """Plot just the stability criteria.""" import matplotlib.pyplot as plt Config = FloxConfiguration.fromfile(opt.configuration) Writer = HDF5Writer(opt.filename) fig = plt.figure(figsize=(11, 8.5)) for i,system in enumerate("stable critical unstable".split()): MVC = MultiViewController(fig, 3, 3, wspace=0.6, hspace=0.4) System = NDSystem2D.from_params(Config["system"]) Writer.read(System, "{}-{:d}".format(system, opt.mode)) print(System) MVC[0,i] = EvolutionViewStabilityTest("Temperature", opt.mode, System.nz//3) MVC[1,i] = EvolutionViewStabilityTest("Vorticity", opt.mode, System.nz//3) MVC[2,i] = EvolutionViewStabilityTest("Stream", opt.mode, System.nz//3) MVC.views[0].ax.text(0.5, 1.25, system.capitalize(), transform=MVC.views[0].ax.transAxes, ha='center') MVC.update(System) fig.savefig(opt.plot, dpi=300)
def animate(opt): """Animate the data sets.""" from astropy.utils.console import ProgressBar import matplotlib matplotlib.rcParams['text.usetex'] = False import matplotlib.pyplot as plt Config = FloxConfiguration.fromfile(opt.configuration) Writer = HDF5Writer(opt.filename) fig = plt.figure(figsize=(11, 8.5)) Plots = [] for i,system in enumerate("stable critical unstable".split()): MVC = MultiViewController(fig, 3, 3, wspace=0.6, hspace=0.4) System = NDSystem2D.from_params(Config["system"]) Writer.read(System, "{}-{:d}".format(system, opt.mode)) print(System) MVC[0,i] = EvolutionViewStabilityTest("Temperature", opt.mode, System.nz//3) MVC[1,i] = EvolutionViewStabilityTest("Vorticity", opt.mode, System.nz//3) MVC[2,i] = EvolutionViewStabilityTest("Stream", opt.mode, System.nz//3) System.it = 2 MVC.update(System) Plots.append((MVC, System)) with ProgressBar(System.nit-2) as pbar: def update(i): """Animation""" for MVC, System in Plots: System.it = i+2 MVC.update(System) pbar.update(i) anim = animation.FuncAnimation(fig, update, frames=int(System.nit)-2, repeat=False) # anim.save(opt.movie, writer='ffmpeg') plt.show()
def filename(extension=".yml", base=None): """Filenames related to this file!""" directory = os.path.dirname(__file__) base = os.path.splitext(os.path.basename(__file__))[0] if base is None else base return os.path.join(directory, base + extension) if __name__ == '__main__': parser = argparse.ArgumentParser() parser.add_argument('base', nargs="?", default='linear_op') opt = parser.parse_args() rcParams['text.usetex'] = False ipydb() Config = FloxConfiguration.fromfile(filename(".yml", base=opt.base)) System = NDSystem2D.from_params(Config["system"]) Writer = HDF5Writer(filename(".hdf5", base=opt.base)) Writer.read(System, 'main') System.it = 1 print(System) print(System.diagnostic_string()) fig = plt.figure(figsize=(10, 10)) MVC = MultiViewController(fig, 2, 2) MVC[0,0] = GridView("Temperature") MVC[1,0] = EvolutionViewStabilityTest("Temperature", 1, 33) MVC[0,1] = GridView("Vorticity", cmap='Blues', vmin=-1e-7, vmax=1e-7, norm=SymLogNorm(1e-9), perturbed=True) MVC[1,1] = EvolutionViewStabilityTest("Vorticity", 1, 33) MVC.update(System) plt.show()
os.path.basename(__file__))[0] if base is None else base return os.path.join(directory, base + extension) if __name__ == '__main__': parser = argparse.ArgumentParser() parser.add_argument('base', nargs="?", default='linear_op') opt = parser.parse_args() rcParams['text.usetex'] = False ipydb() Config = FloxConfiguration.fromfile(filename(".yml", base=opt.base)) System = NDSystem2D.from_params(Config["system"]) Writer = HDF5Writer(filename(".hdf5", base=opt.base)) Writer.read(System, 'main') System.it = 1 print(System) print(System.diagnostic_string()) fig = plt.figure(figsize=(10, 10)) MVC = MultiViewController(fig, 2, 2) MVC[0, 0] = GridView("Temperature") MVC[1, 0] = EvolutionViewStabilityTest("Temperature", 1, 33) MVC[0, 1] = GridView("Vorticity", cmap='Blues', vmin=-1e-7, vmax=1e-7, norm=SymLogNorm(1e-9), perturbed=True) MVC[1, 1] = EvolutionViewStabilityTest("Vorticity", 1, 33) MVC.update(System) plt.show()