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 setup_plots(fig, stability=None, zmode=33): """Setup plots from a figure.""" rows = 2 if stability is not None else 1 MVC = MultiViewController(fig, rows, 3) MVC[0,0] = GridView("Temperature", cmap="hot") MVC[0,1] = GridView("Vorticity", cmap='Blues') MVC[0,2] = GridView("Stream", cmap='Greens') if stability is not None: MVC[1,0] = EvolutionViewStabilityTest("Temperature", stability, zmode) MVC[1,1] = EvolutionViewStabilityTest("Vorticity", stability, zmode) MVC[1,2] = EvolutionViewStabilityTest("Stream", stability, zmode) return MVC
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 setup_plots(fig, stability=None, zmode=33): """Setup plots from a figure.""" rows = 4 if stability is not None else 2 MVC = MultiViewController(fig, rows, 3) MVC[0, 0] = GridView("Temperature", cmap="hot") MVC[0, 1] = GridView("Vorticity", cmap='Blues') MVC[0, 2] = GridView("Stream", cmap='Greens') MVC[1, 0] = RawGridView("Temperature", cmap="hot") MVC[1, 1] = RawGridView("Vorticity", cmap='Blues') MVC[1, 2] = RawGridView("Stream", cmap='Greens') if stability is not None: MVC[2, 0] = EvolutionViewSingleMode("Temperature", stability, zmode) MVC[2, 1] = EvolutionViewSingleMode("Vorticity", stability, zmode) MVC[2, 2] = EvolutionViewSingleMode("Stream", stability, zmode) MVC[3, 0] = EvolutionViewSingleMode("dTemperature", stability, zmode) MVC[3, 1] = EvolutionViewSingleMode("dVorticity", stability, zmode) MVC[3, 2] = VProfileView("Temperature", 0) return MVC
def setup_plots_watch(fig, stability=None, zmode=33): """Setup plots from a figure.""" rows = 5 MVC = MultiViewController(fig, rows, 3) MVC[0, 0] = GridView("Temperature", cmap="hot") MVC[0, 1] = GridView("Vorticity", cmap='Blues') MVC[0, 2] = GridView("Stream", cmap='Greens') MVC[1, 0] = RawGridView("Temperature", cmap="hot") MVC[1, 1] = RawGridView("Vorticity", cmap='Blues') MVC[1, 2] = RawGridView("Stream", cmap='Greens') MVC[2, 0] = VProfileView("Temperature", stability) MVC[2, 1] = VProfileView("Vorticity", stability) MVC[2, 2] = VProfileView("Stream", stability) MVC[3, 0] = V2DProfileView("Temperature", stability) MVC[3, 1] = V2DProfileView("Vorticity", stability) MVC[3, 2] = V2DProfileView("Stream", stability) MVC[4, 0] = V1DProfileView("Temperature", stability) MVC[4, 1] = V1DProfileView("Vorticity", stability) MVC[4, 2] = V1DProfileView("Stream", stability) return MVC
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()
def setup_movie(fig, variables=["Temperature"], kwargs=[dict(cmap="hot")]): """Setup a movie view.""" MVC = MultiViewController(fig, len(variables), 1) for i, (variable, kwds) in enumerate(zip(variables, kwargs)): MVC[i, 0] = GridView(variable, **kwds) return MVC
parser.add_argument('base', nargs="?", default='linear_op') parser.add_argument('-s', '--stability', type=int, help='Show stability plots') 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') print(System) fig = plt.figure(figsize=(10, 10)) rows = 2 if opt.stability else 1 MVC = MultiViewController(fig, rows, 3) MVC[0, 0] = GridView("Temperature", perturbed=False) MVC[0, 1] = GridView("Vorticity", cmap='Blues') MVC[0, 2] = GridView("Stream", cmap='Greens') if opt.stability: MVC[1, 0] = EvolutionViewStabilityTest("Temperature", opt.stability, 33) MVC[1, 1] = EvolutionViewStabilityTest("Vorticity", opt.stability, 33) MVC[1, 2] = EvolutionViewStabilityTest("Stream", opt.stability, 33) System.it = 2 MVC.update(System) System.infer_iteration() def update(i): System.it = i MVC.update(System)