gettime=True, vector_norms=False) #choosing positions ylabel = 'z' if np.isclose(d['y'].max(), d['y'].min()) else 'y' if opts['--x-restrict']: res = parse_ftuple(opts['--x-restrict'], length=4) res[:2] = [np.abs(d['x'][:, 0] * 1e4 - ires).argmin() for ires in res[:2]] res[2:] = [ np.abs(d[ylabel][0, :] * 1e4 - ires).argmin() for ires in res[2:] ] #including the edges res[1] += 1 res[3] += 1 restrict(d, res) elif opts['--restrict']: res = parse_ituple(opts['--restrict'], length=None) restrict(d, res) x, y = d['x'] * 1e4, d[ylabel] * 1e4 avg = parse_ituple(opts['--average'], length=2) #massaging data t = d['t'] q = np.sum([d[Q] * i for Q, i in zip(qs, charges)], axis=0) #averaging acc = [q] qp = np.pad(q, ((avg[0], ) * 2, (avg[1], ) * 2), 'edge') qps = [ qp[:, avg[1]:-avg[1]], qp[avg[0]:-avg[0], :], ] for I, (ia, iqp) in enumerate(zip(avg, qps)): l = 2 * ia + 1
d = read_indexed(int(opts['<i>']), flds=fvar,sclr=qs, gzip=gzip,dir=opts['--dir'], gettime=True,vector_norms=False); #choosing positions ylabel = 'z' if np.isclose(d['y'].max(),d['y'].min()) else 'y'; if opts['--x-restrict']: res = parse_ftuple(opts['--x-restrict'], length=4); res[:2] = [ np.abs(d['x'][:,0]*1e4 - ires).argmin() for ires in res[:2] ]; res[2:] = [ np.abs(d[ylabel][0,:]*1e4 - ires).argmin() for ires in res[2:] ]; #including the edges res[1]+=1; res[3]+=1; restrict(d,res); elif opts['--restrict']: res = parse_ituple(opts['--restrict'],length=None); restrict(d,res); x,y = d['x']*1e4, d[ylabel]*1e4; avg = parse_ituple(opts['--average'],length=2); #massaging data t = d['t']; q = np.sum([d[Q]*i for Q,i in zip(qs,charges)],axis=0); #averaging acc = [q]; qp = np.pad(q, ((avg[0],)*2, (avg[1],)*2), 'edge'); qps = [ qp[:,avg[1]:-avg[1]], qp[avg[0]:-avg[0],:],]; for I,(ia,iqp) in enumerate(zip(avg,qps)): l=2*ia + 1; if l == 1: continue; Is = [
quantity = opts['--quantity']; fvar=['E'] if opts['--laser']: fvar+=['B']; titlestr=opts['--title'] units=opts['--units']; svar=[quantity]; ##################################### #reading data d = read_indexed(int(opts['<i>']), flds=fvar,sclr=svar, gzip=gzip,dir=opts['--dir'], gettime=True,vector_norms=False); if opts['--restrict']: res = parse_ituple(opts['--restrict'],length=None); restrict(d,res); #massaging data t = d['t']; x,y = d['x']*1e4,d['y']*1e4 Ex,Ey = d['Ex']*1e5, d['Ey']*1e5; if np.isclose(y.max(),y.min()): y = d['z']*1e4 Ey = d['Ez']*1e5; q = d[quantity]; dx = (x[1,0]-x[0,0])*1e-6; dy = (y[0,1]-y[0,0])*1e-6; rho = ( np.gradient(Ex,dx,axis=0) + np.gradient(Ey,dy,axis=1) ) * e0 / e * 1e-4;
files = os.listdir('.'); lspf=[f for f in files if re.search(".*\.lsp$",f)]; if len(lspf) < 1: raise ValueError("Need to specify a .lsp file or see one in the same directory."); lspf=lspf[0]; with open(lspf,"r") as f: lsp=f.read(); if not opts['--output']: outname = re.search("(.*)\.lsp$",lspf).group(1)+"-pext"; else: outname = opts['--output']; dim=getdim(lsp); pext_info = getpexts(lsp); if opts['--range']: a=parse_ituple(opts['--range'],length=2); mnpext,mxpext = min(*a),max(*a); else: mnpext,mxpext = float('-inf'),float('inf'); outkeys = set(); allkeys = []; def getpextfnames(path): files = os.listdir(path); pext = [f for f in files if re.search("pext[0-9]+.p4",f)]; key = [ float(re.search("pext([0-9]+).p4",f).group(1)) for f in pext ]; return [ ('{}/{}'.format(path,i),k) for i,k in zip(pext,key) if mnpext <= k <= mxpext]; #read first directory. Must do this in order to get headers AND not skip ahead. pextfnames = getpextfnames(opts['<dirs>'][0]); keys = [ i[1] for i in pextfnames ];
titlestr=opts['--title'] units=opts['--units']; svar=[quantity]; ##################################### #reading data i = int(opts['<i>']); d = read_indexed(i, flds=fvar,sclr=svar, gzip=gzip,dir=opts['--dir'], gettime=True,vector_norms=False); t = d['t']; if opts['--traj']: factor, offset = None, None; if opts['--traj-offset']: factor, offset = parse_ituple(opts['--traj-offset'],length=2); with np.load(opts['--traj'], mmap_mode='r') as f: if factor: tri = i*factor+offset; trt = f['time'][tri]; if not np.isclose(trt,t): import sys sys.stderr.write( "warning: time from trajectory is {} while time from sclr is {}\n".format( trt,t)); else: tri = np.sum((f['time'] <= t).astype(int)); trt = f['time'][tri]; tr = f['data'][:tri+1,:]; if opts['--traj-n']: tr = tr[:,:int(opts['--traj-n'])];
clim=(-1e19, 1e19), linthresh=1e15, ), #pmovies no_pmovies=False, #particle dumps dump_particle=True, particle_dump_interval_ns=0.0, particle_dump_times_ns=(1.1e-4, 1.4e-4), pext_species=(17, 18), ) if opts['--make-target']: try: targi = [int(opts['--make-target'])] except ValueError: targi = parse_ituple(opts['--make-target'], length=3) elif opts['--make-targets']: targi = [0, 1, 2] else: targi = [] if 0 not in targi: print("be sure to make this dat {} seperately".format(0)) else: d['f_2D'] = mk45(dim=(-5, 5, -5, 5), N0=1.0804e22, width=0.46e-4, dropcorners=False) d['dat_xres'] = 10000 print("making targets...sit tight.") gensim(**d)
flds=fvar,sclr=svar, gzip=gzip,dir=opts['--dir'], gettime=True,vector_norms=False); #choosing positions ylabel = 'z' if np.isclose(d['y'].max(),d['y'].min()) else 'y'; if opts['--x-restrict']: res = parse_ftuple(opts['--x-restrict'], length=4); res[:2] = [ np.abs(d['x'][:,0]*1e4 - ires).argmin() for ires in res[:2] ]; res[2:] = [ np.abs(d[ylabel][0,:]*1e4 - ires).argmin() for ires in res[2:] ]; #including the edges res[1]+=1; res[3]+=1; restrict(d,res); elif opts['--restrict']: res = parse_ituple(opts['--restrict'],length=None); restrict(d,res); x,y = d['x']*1e4, d[ylabel]*1e4; #massaging data t = d['t']; q = d[quantity]; ##################################### #plotting #getting options from user mn,mx = parse_ftuple(opts['--lims'],length=2); if opts['--rotate']: rot,flip = True, False; else:
ylabel='y'; coord = float(opts['--3d-coord'])*1e-4; dx = float(opts['--3d-width'])*1e-4; d=flatten3d_aa(d,coord=coord, dx=dx,axis=flataxis); del d[flataxis]; if opts['--x-restrict']: res = parse_ftuple(opts['--x-restrict'], length=4); res[:2] = [ np.abs(d[xlabel][:,0]*1e4 - ires).argmin() for ires in res[:2] ]; res[2:] = [ np.abs(d[ylabel][0,:]*1e4 - ires).argmin() for ires in res[2:] ]; #including the edges res[1]+=1; res[3]+=1; restrict(d,res); elif opts['--restrict']: res = parse_ituple(opts['--restrict'],length=None); restrict(d,res); #trajectories if opts['--traj']: factor, offset = None, None; if opts['--traj-offset']: factor, offset = parse_ituple(opts['--traj-offset'],length=2); with np.load(opts['--traj'], mmap_mode='r') as f: if factor: tri = i*factor+offset; trt = f['time'][tri]; if not np.isclose(trt,t): import sys sys.stderr.write( "warning: time from trajectory is {} while time from sclr is {}\n".format(