import pylab as plt rkey, ikey = amrex.get_particle_keys() t = [] fee = [] fexR = [] fexI = [] fxx = [] pupt = [] files = sorted(glob.glob("plt[0-9][0-9][0-9][0-9][0-9]")) print(files[0], files[-1]) nfiles = len(files) idata, rdata = amrex.read_particle_data(files[0], ptype="neutrinos") nparticles = len(rdata) print("Detected " + str(nparticles) + " particles.") t = np.zeros(nfiles) fee = np.zeros((nparticles, nfiles)) fexR = np.zeros((nparticles, nfiles)) fexI = np.zeros((nparticles, nfiles)) fxx = np.zeros((nparticles, nfiles)) feebar = np.zeros((nparticles, nfiles)) fexRbar = np.zeros((nparticles, nfiles)) fexIbar = np.zeros((nparticles, nfiles)) fxxbar = np.zeros((nparticles, nfiles)) pupt = np.zeros((nparticles, nfiles)) for (fi, f) in zip(range(nfiles), files):
dx = 64. / 1024. #ix = 500 basedir = "/global/project/projectdirs/m3018/Emu/PAPER/1D/converge_direction/1D_dir128" directory = basedir + "/plt00300" #[basedir+"/plt00000",basedir+"/plt00300",basedir+"/plt04800"] ds = yt.load(directory) print(ds.current_time) ad = ds.all_data() f01 = ad['boxlib', "Fx01_Re"] ix = np.argmin(f01) print("ix=", ix, np.min(f01)) rkey, ikey = amrex.get_3flavor_particle_keys() idata, rdata = amrex.read_particle_data(directory, ptype="neutrinos") zvals = rdata[:, rkey["z"]] locs = np.where((zvals < (ix + 1) * dx) & (zvals > ix * dx)) zvals = zvals[locs] #fee = np.arctan2(rdata[:,rkey["f01_Im"]][locs],rdata[:,rkey["f01_Re"]][locs]) fee = rdata[:, rkey["f01_Re"]][locs] pupx = rdata[:, rkey["pupx"]][locs] pupy = rdata[:, rkey["pupy"]][locs] pupz = rdata[:, rkey["pupz"]][locs] pupt = rdata[:, rkey["pupt"]][locs] xhat = pupx / pupt yhat = pupy / pupt zhat = pupz / pupt latitude = np.arccos(zhat) - np.pi / 2. longitude = np.arctan2(yhat, xhat) print(np.min(fee), np.max(fee))
import numpy as np import argparse import amrex_plot_tools as amrex parser = argparse.ArgumentParser() parser.add_argument("plotfile", type=str, help="Name of plotfile to process.") args = parser.parse_args() if __name__ == "__main__": import pylab as plt x0 = [] y0 = [] idata, rdata = amrex.read_particle_data(args.plotfile, ptype="neutrinos") for p in rdata: x0.append(p[0]) y0.append(p[1]) fig = plt.gcf() fig.set_size_inches(8, 8) plt.plot(x0, y0, 'b.') plt.axis((0., 1., 0., 1.)) ax = plt.gca() ax.set_xlabel(r'$x$') ax.set_ylabel(r'$y$') plt.savefig('{}_neutrinos.png'.format(args.plotfile))
ad = ds.all_data() grid_data = GridData(ad) nlevels = len(header.grids) assert nlevels==1 level = 0 ngrids = len(header.grids[level]) # average the angular power spectrum over many cells # loop over all cells within each grid spectrum = np.zeros((nl,2,6)) total_ncells = 0 for gridID in range(ngrids): print(" grid",gridID+1,"/",ngrids) # read particle data on a single grid idata, rdata = amrex.read_particle_data(directory, ptype="neutrinos", level_gridID=(level,gridID)) # get list of cell ids idlist = grid_data.get_particle_cell_ids(rdata) # sort rdata based on id list sorted_indices = idlist.argsort() rdata = rdata[sorted_indices] idlist = idlist[sorted_indices] # split up the data into cell chunks ncells = np.max(idlist)+1 nppc = len(idlist) // ncells rdata = [ rdata[icell*nppc:(icell+1)*nppc,:] for icell in range(ncells)] idlist = [idlist[icell*nppc:(icell+1)*nppc ] for icell in range(ncells)] icell_list = [icell for icell in range(ncells)]