def main(): parser = argparse.ArgumentParser(description=__doc__) parser.add_argument("--show", "--plot", action="store_true") args = vutil.common_argparse(parser) ####### test binary files f_bin = viscid.load_file(_viscid_root + "/../sample/ath_sample.*.bin") for i, grid in enumerate(f_bin.iter_times(":")): plt.subplot2grid((2, 2), (0, i)) mpl.plot(grid["bx"]) plt.subplot2grid((2, 2), (1, i)) mpl.plot(grid["by"]) if args.show: mpl.tighten() mpl.mplshow() plt.clf() ####### test ascii files f_tab = viscid.load_file(_viscid_root + "/../sample/ath_sample.*.tab") for i, grid in enumerate(f_tab.iter_times(":")): plt.subplot2grid((2, 2), (0, i)) mpl.plot(grid["bx"]) plt.subplot2grid((2, 2), (1, i)) mpl.plot(grid["by"]) if args.show: mpl.tighten() mpl.mplshow() plt.clf()
def main(): parser = argparse.ArgumentParser(description=__doc__) parser.add_argument("--show", "--plot", action="store_true") args = vutil.common_argparse(parser) ####### test binary files f_bin = viscid.load_file(sample_dir + '/ath_sample.*.bin') for i, grid in enumerate(f_bin.iter_times(":")): plt.subplot2grid((2, 2), (0, i)) mpl.plot(grid['bx']) plt.subplot2grid((2, 2), (1, i)) mpl.plot(grid['by']) mpl.plt.suptitle("athena bin (binary) files") mpl.auto_adjust_subplots(subplot_params=dict(top=0.9)) mpl.plt.savefig(next_plot_fname(__file__)) if args.show: mpl.show() plt.clf() ####### test ascii files f_tab = viscid.load_file(sample_dir + '/ath_sample.*.tab') for i, grid in enumerate(f_tab.iter_times(":")): plt.subplot2grid((2, 2), (0, i)) mpl.plot(grid['bx']) plt.subplot2grid((2, 2), (1, i)) mpl.plot(grid['by']) mpl.plt.suptitle("athena tab (ascii) files") mpl.auto_adjust_subplots(subplot_params=dict(top=0.9)) mpl.plt.savefig(next_plot_fname(__file__)) if args.show: mpl.show() plt.clf()
def main(): parser = argparse.ArgumentParser(description="Streamline a PSC file") parser.add_argument("-t", default="2000", help="which time to plot (finds closest)") parser.add_argument('infile', nargs=1, help='input file') args = vutil.common_argparse(parser) # f = readers.load_file("pfd.020000.xdmf") # ... or ... # using this way of loading files, one probably wants just to give # pfd.xdmf to the command line f = readers.load_file(args.infile[0]) f.activate_time(args.t) jz = f["jz"] # recreate hx as a field of 0 to keep streamlines from moving in # that direction hx = field.zeros_like(jz, name="hx") h1 = field.scalar_fields_to_vector([hx, f["hy"], f["hz"]], name="H", _force_layout="Interlaced", forget_source=True) e = field.scalar_fields_to_vector([f["ex"], f["ey"], f["ez"]], name="E", _force_layout="Interlaced", forget_source=True) # plot magnetic fields, just a sanity check # ax1 = plt.subplot(211) # mpl.plot(f["hy"], flip_plot=True) # ax2 = plt.subplot(212, sharex=ax1, sharey=ax1) # mpl.plot(f["hz"], flip_plot=True) # mpl.mplshow() # make a line of 30 seeds straight along the z axis (x, y, z ordered) seeds1 = seed.Line((0.0, 0.0, 2.0), (1022.0, 0.0, 0.0), 60) # set outer boundary limits for streamlines ds = 0.005 # spatial step along the stream line curve obound0 = np.array([1, -128, -1000], dtype=h1.dtype) obound1 = np.array([1023, 128, 1000], dtype=h1.dtype) # calc the streamlines lines1, topo1 = streamline.streamlines(h1, seeds1, ds0=ds, maxit=200000, obound0=obound0, obound1=obound1, ibound=0.0) # run with -v to see this logger.info("Topology flags: {0}".format(topo1)) # rotate plot puts the z axis along the horizontal flip_plot = True mpl.plot(jz, flip_plot=flip_plot, plot_opts="lin_-.05_.05") # mpl.plot_streamlines2d(lines1, "x", flip_plot=flip_plot, color='k') plt.xlim([0, 1024]) plt.ylim([-128, 128]) plt.show() # interpolate e onto each point of the first field line of lines1 e1 = cycalc.interp_trilin(e, seed.Point(lines1[0])) print(e1.shape, lines1[0].shape) plt.clf() plt.plot(np.linspace(0, ds * e1.shape[0], e1.shape[0]), e1[:, 0]) plt.xlabel("length along field line") plt.ylabel("Ex") plt.show() return 0