From cae1e79ad5caacbc69298f1f39d03a227da94f2b Mon Sep 17 00:00:00 2001 From: MaxThevenet Date: Fri, 6 Sep 2019 18:21:15 -0700 Subject: add parallel plotfile --- Tools/plot_parallel.py | 250 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 250 insertions(+) create mode 100644 Tools/plot_parallel.py (limited to 'Tools/plot_parallel.py') diff --git a/Tools/plot_parallel.py b/Tools/plot_parallel.py new file mode 100644 index 000000000..db8ac0aed --- /dev/null +++ b/Tools/plot_parallel.py @@ -0,0 +1,250 @@ +import os, glob, matplotlib, sys, argparse +import yt ; yt.funcs.mylog.setLevel(50) +import numpy as np +import matplotlib.pyplot as plt +import scipy.constants as scc + +''' +This script loops over all WarpX plotfiles in a directory and, for each +plotfile, saves an image showing the field and particles. + +It can be run serial: +> python plot_parallel.py --path +or parallel +> mpirun -np 32 python plot_parallel.py --path --parallel +When running parallel, the plotfiles are distributed as evenly as possible +between MPI ranks. + +This script also proposes an option to plot one quantity over all timesteps. +The data of all plotfiles are gathered to rank 0, and the quantity evolution +is plotted and saved to file. For the illustration, this quantity is the max +of Ey. Use " --plot_Ey_max_evolution " to activate this option. + +To get help, run +> python plot_parallel --help +''' + +# Parse command line for options. +parser = argparse.ArgumentParser() +parser.add_argument('--path', dest='path', default='.', + help='path to plotfiles. Plotfiles names must be plt?????') +parser.add_argument('--plotlib', dest='plotlib', default='yt', + choices=['yt','matplotlib'], + help='Plotting library to use') +parser.add_argument('--field', dest='field', default='Ez', + help='Which field to plot, e.g., Ez, By, jx or rho. The central slice in y is plotted') +parser.add_argument('--pjump', dest='pjump', default=20, + help='When plotlib=matplotlib, we plot every pjump particle') +parser.add_argument('--use_vmax', dest='use_vmax', default=False, + help='Whether to put bounds to field colormap') +parser.add_argument('--vmax', dest='vmax', default=1.e12, + help='If use_vmax=True, the colormab will have bounds [-vamx, vmax]') +parser.add_argument('--slicewidth', dest='slicewidth', default=10.e-6, + help='Only particles with -slicewidth/2