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. Requires yt>3.5 and Python3 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 1: global_zwin = np.empty_like(zwin) global_maxF = np.empty_like(maxF) comm_world.Reduce(zwin, global_zwin, op=MPI.MAX) comm_world.Reduce(maxF, global_maxF, op=MPI.MAX) zwin = global_zwin maxF = global_maxF if rank == 0: plot_field_max(zwin, maxF)