示例#1
0
文件: rho.py 项目: noobermin/lspplot
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;

#####################################
示例#2
0
                 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], :],
]
示例#3
0
                    "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'])];
    if opts['--verbose']:
        print("size of trajectories: {}".format(tr.shape));
        print("final time is {}".format(trt));
        print("with sclr time as {}".format(t));
    pass;
if opts['--restrict']:
    res = parse_ituple(opts['--restrict'],length=None);
    restrict(d,res);

#massaging data
x,y = d['x']*1e4,d['y']*1e4
coords = ['x','y'];
if np.isclose(y.max(),y.min()):
    y = d['z']*1e4
    coords[1] = 'z';
q = d[quantity];

#####################################
#plotting

#getting options from user
mn,mx = parse_ftuple(opts['--lims'],length=2);
myhi  = float(opts['--highlight']);