Esempio n. 1
0
  --timestamp-pos=POS         Set the timestamp position as a tuple [default: (0.02,0.05)];

'''
from docopt import docopt;
import numpy as np;
import matplotlib.pyplot as plt;
import matplotlib.animation as anim;
from lspplot.angular import _prep2,angular
from pys import test,parse_ftuple;
opts = docopt(__doc__,help=True);
d,kw = _prep2(opts);

tstep = float(opts['--timestep']);
ti    = float(opts['--initial-time']);
mt    = float(opts['--minus-time']);
tx,ty  = parse_ftuple(opts['--timestamp-pos']);

interval=float(opts['--interval']);
#process by times.
good = np.argsort(d['t'])
d = d[good];
t = d['t'];
tbins = np.arange(ti,t[-1]+tstep,tstep);
#f*****g c like loop shit mother f****r.
i=0;
Is=[];
for j,ct in enumerate(t):
    if ct > tbins[i]:
        Is.append(j);
        i+=1;
#do first
Esempio n. 2
0
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;

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

#getting options from user
mn,mx = parse_ftuple(opts['--lims'],length=2);
if opts['--flip']:
    rot,flip = False, True;
else:
    rot,flip = True, False;


#plot the density
toff = float(opts['--t-offset']);
title="{}\nTime: {:.2f} fs".format(titlestr,t*1e6+toff);
r=pc(
    rho,(x,y), lims=(mn,mx),log=opts['--log10'],
    clabel=units, title=title,
    agg=not opts['--show'],
    linthresh=float(opts['--linthresh']),
    linscale=float(opts['--linscale']),
Esempio n. 3
0
from lspreader.flds import read_indexed, restrict
from lspplot.sclr import S
from lspplot.pc import pc, highlight
from lspplot.consts import c, mu0, e0
import re
opts = docopt(__doc__, help=True)
if opts['--nozip']:
    gzip = False
elif opts['--zip']:
    gzip = True
else:
    gzip = 'guess'

if not re.match(r" *[\[\(](?:\w+,)*(?:\w+)?[\[\)]", opts['--ions']):
    raise ValueError("--ions argument invalid, see --help")
charges = parse_ftuple(opts['--charges'], length=None)
qs = re.search("[\[\(](.+)[\]\)]", opts['--ions']).group(1).split(",")
if qs[-1] == '': qs = qs[:-1]
if len(qs) != len(charges):
    raise ValueError("--charges and --ions arguments have differing lengths.")
fvar = ['E', 'B'] if opts['--laser'] else None
titlestr = opts['--title']
units = opts['--units']
#####################################
#reading data
d = read_indexed(int(opts['<i>']),
                 flds=fvar,
                 sclr=qs,
                 gzip=gzip,
                 dir=opts['--dir'],
                 gettime=True,
Esempio n. 4
0
    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']);

#plot the density
title="{}\nTime: {:.2f} fs".format(titlestr,t*1e6);
r=pc(
    q,(x,y), lims=(mx,mn),log=opts['--log10'],
    clabel=units, title=title,
    agg=not opts['--show']);
highlight(
    r, myhi,
    color="lightyellow", alpha=0.5);

if opts['--laser']:
    laser = S(d);
    I = float(opts['--intensity']);
Esempio n. 5
0
from lspreader.flds import read_indexed, restrict
from lspplot.sclr import S;
from lspplot.pc import pc,highlight, timelabel;
from lspplot.physics import c,mu0,e0;
import re
opts = docopt(__doc__,help=True);
if opts['--nozip']:
    gzip = False;
elif opts['--zip']:
    gzip = True;
else:
    gzip = 'guess';

if not re.match(r" *[\[\(](?:\w+,)*(?:\w+)?[\[\)]", opts['--ions']):
    raise ValueError("--ions argument invalid, see --help");
charges=parse_ftuple(opts['--charges'],length=None);
qs = re.search("[\[\(](.+)[\]\)]",opts['--ions']).group(1).split(",");
if qs[-1] == '': qs = qs[:-1];
if len(qs) != len(charges):
    raise ValueError(
        "--charges and --ions arguments have differing lengths.");
fvar=['E','B'] if opts['--laser'] else None;
titlestr=opts['--title']
units=opts['--units'];
#####################################
#reading data
d = read_indexed(int(opts['<i>']),
    flds=fvar,sclr=qs,
    gzip=gzip,dir=opts['--dir'],
              gettime=True,vector_norms=False);
#choosing positions
Esempio n. 6
0
    gzip = False;
elif opts['--zip']:
    gzip = True;
else:
    gzip = 'guess';
#####################################
#reading data
d = read_indexed(int(opts['<i>']),
    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];
Esempio n. 7
0
    'res':(1400,1600),
    'tlim':(-27.5,0,-15,15),
    'fp':(0,0,0),
    'domains':48,
    'totaltime':300e-15,
    'timestep':4e-17,
    'components':(0,1,0),
    'phases':(0,0,0),
    'targetdat':'watercolumn.dat',
    'dumpinterval':2e-16,
    'description':'Hotwater in 2d'
};
c  = 299792458
e0 = 8.8541878176e-12

gettuple = lambda l,length=4,scale=1: parse_ftuple(
    opts[l],length=length,scale=scale);

joinspace = lambda l: " ".join([str(i) for i in l]);
def genlsp(**kw):
    def getkw(l,scale=None):
        if test(kw, l):
            if scale:
                return [scale*i for i in kw[l]];
            return kw[l];
        else:
            return defaults[l];
    E0 = np.sqrt(2*getkw('I')*1e4/(c*e0))*1e-5
    xmin,xmax, ymin,ymax = getkw('lim',scale=1e-4)
    fp = joinspace(getkw("fp"));
    components = joinspace(getkw("components"));
    phases = joinspace(getkw("phases"));
Esempio n. 8
0
    gzip = False;
elif opts['--zip']:
    gzip = True;
else:
    gzip = 'guess';
#####################################
#reading data
d = read_indexed(int(opts['<i>']),
    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];
Esempio n. 9
0
def _prepkw(opts):
    '''Prep from options'''
    inname = opts['<input>'];
    eunit  = opts['--energy-units'];
    if opts['--keV']:
        eunit='KeV';
    def getdef_kev(label):
        if kev:
            return defaults[label+'_kev'];
        else:
            return defaults[label];
    kw = {
        'angle_bins' : float(opts['--angle-bins']),
        'energy_bins': float(opts['--energy-bins']),
        'max_q': float(opts['--max-q']) if opts['--max-q'] else None,
        'min_q': float(opts['--min-q']) if opts['--min-q'] else None,
        'clabel' : opts['--clabel'],
        'colorbar' : not opts['--no-cbar'],
        'e_step' : float(opts['--e-step']) if opts['--e-step'] else None,
        'labels': 'tdefault' if opts['--polar'] else 'default',
        'rtitle':opts['--rtitle'],
        'ltitle':opts['--ltitle'],
        'oap': float(opts['--oap']) if opts['--oap'] != 'none' else None,
        'log_q': opts['--log10'],
        'normalize':opts['--normalize'],
        'F':float(opts['--factor']),
        'energy_units':eunit,
    };
    if opts['--angle-range']:
        kw['angle_range'] = [
            x*np.pi for x in parse_ftuple(opts['--angle-range'])];
    if opts['--max-e']:
        try:
            kw['max_e']=float(opts['--max-e']);
        except ValueError:
            kw['max_e']=opts['--max-e'];
    else:
        kw['max_e'] = getdef_kev('max_e');
    cmap = _str2cmap(opts['--cmap']);
    if not cmap:
        cmap = opts['--cmap'];
    kw['cmap'] = cmap;
    kw['rgridopts'] = {};
    if opts['--e-direction']:
        kw['rgridopts'].update({'angle':opts['--e-direction']});
    if opts['--e-units']:
        kw['rgridopts'].update({'unit':opts['--e-units']});
    if opts['--normalize']:
        kw['clabel'] += defaults['norm_units'];
    
    if opts['--efficiency']:
        massE=float(opts['--massE']);
        effs = opts['--efficiency'];
        if opts['--lsp']:
            I,w,l,T,dim = _getlsp();
            if effs == "wilks":
                ecut = 'wilks';
            else:
                ecut = float(effs);
        else:
            vs = parse_ftuple(effs, length=None);
            if len(vs) >= 5:
                I,w,l,T,dim = vs[:5];
                dim = "{}D".format(int(dim));
                if len(vs) >= 6:
                    ecut = vs[5];
                else:
                    ecut = 'wilks';
            else:
                raise ValueError(
                    "efficiency passed is incorrect. See --help.");
        kw['efficiency'] = dict(
            I=I,w=w,T=T,l=l,dim=dim,
            ecut=ecut, massE=massE);
    if opts['--polar']:
        kw['phi']='phi_n';
    return kw;
Esempio n. 10
0
def _prepkw(opts):
    '''Prep from options'''
    inname = opts['<input>']
    eunit = opts['--energy-units']
    if opts['--keV']:
        eunit = 'KeV'

    def getdef_kev(label):
        if kev:
            return defaults[label + '_kev']
        else:
            return defaults[label]

    kw = {
        'angle_bins': int(opts['--angle-bins']),
        'energy_bins': int(opts['--energy-bins']),
        'max_q': float(opts['--max-q']) if opts['--max-q'] else None,
        'min_q': float(opts['--min-q']) if opts['--min-q'] else None,
        'clabel': opts['--clabel'],
        'colorbar': not opts['--no-cbar'],
        'e_step': float(opts['--e-step']) if opts['--e-step'] else None,
        'labels': 'tdefault' if opts['--polar'] else 'default',
        'rtitle': opts['--rtitle'],
        'ltitle': opts['--ltitle'],
        'oap': float(opts['--oap']) if opts['--oap'] != 'none' else None,
        'log_q': opts['--log10'],
        'normalize': opts['--normalize'],
        'F': float(opts['--factor']),
        'energy_units': eunit,
    }
    if opts['--angle-range']:
        kw['angle_range'] = [
            x * np.pi for x in parse_ftuple(opts['--angle-range'])
        ]
    if opts['--max-e']:
        try:
            kw['max_e'] = float(opts['--max-e'])
        except ValueError:
            kw['max_e'] = opts['--max-e']
    else:
        kw['max_e'] = getdef_kev('max_e')
    cmap = _str2cmap(opts['--cmap'])
    if not cmap:
        cmap = opts['--cmap']
    kw['cmap'] = cmap
    kw['rgridopts'] = {}
    if opts['--e-direction']:
        kw['rgridopts'].update({'angle': opts['--e-direction']})
    if opts['--e-units']:
        kw['rgridopts'].update({'unit': opts['--e-units']})
    if opts['--normalize']:
        kw['clabel'] += defaults['norm_units']

    if opts['--efficiency']:
        massE = float(opts['--massE'])
        effs = opts['--efficiency']
        if opts['--lsp']:
            I, w, l, T, dim = _getlsp()
            if effs == "wilks":
                ecut = 'wilks'
            else:
                ecut = float(effs)
        else:
            vs = parse_ftuple(effs, length=None)
            if len(vs) >= 5:
                I, w, l, T, dim = vs[:5]
                dim = "{}D".format(int(dim))
                if len(vs) >= 6:
                    ecut = vs[5]
                else:
                    ecut = 'wilks'
            else:
                raise ValueError("efficiency passed is incorrect. See --help.")
        kw['efficiency'] = dict(I=I,
                                w=w,
                                T=T,
                                l=l,
                                dim=dim,
                                ecut=ecut,
                                massE=massE)
    if opts['--polar']:
        kw['phi'] = 'phi_n'
    return kw