Beispiel #1
0
import numpy as np;
import re;

def hdfoutput(outname, frames, dozip=False):
    '''Outputs the frames to an hdf file.'''
    with h5.File(outname,'a') as f:
        for frame in frames:
            group=str(frame['step']);
            h5w(f, frame, group=group,
                compression='lzf' if dozip else None);

if __name__=='__main__':
    opts = docopt(__doc__,help=True);
    vprint = mkvprint(opts);
    #reading in using the reader.
    frames=rd.read(opts['<input>'], gzip='guess');
    if opts['--sort']:
        vprint("sorting...");
        frames[:] = [sortframe(frame) for frame in frames];
        vprint("done");
    #experimental hashing
    if opts['--firsthash'] or opts['--hash']:
        if opts['--firsthash']:
            d=firsthash(frames[0], removedupes=True);
            dump_pickle(opts['--firsthash'], d);
        else:
            d = load_pickle(opts['--hash']);
        frames[:] = [addhash(frame,d,removedupes=True) for frame in frames];
    #outputting.
    if opts['--hdf']:
        import fasteners;
Beispiel #2
0
def _vprint(s):
    print(s)


opts = docopt(__doc__, help=True)
vprint = _vprint if opts["--verbose"] else (lambda s: None)
outname = opts["<output>"]
names = opts["<names>"]
coords = {"x": opts["--X"], "y": opts["--Y"], "z": opts["--Z"]}
num_of_coords = len([i for i in coords.values() if i])
latetime = float(opts["--late-time"]) if opts["--late-time"] else None
if num_of_coords == 0:
    num_of_coords = 3
vprint("reading in files")
d = [rd.read(name) for name in names]
vprint("length of d={}".format(len(d)))
if opts["--verbose"]:
    vprint("printing d's")
    for i in d:
        vprint(i["t"].shape[0])
d = [i for i in d if i["t"].shape[0] > 0]
vprint("length of d={} after remove empties".format(len(d)))
vprint("cutting out duplicate times")
# make a mask of times less than the minimum of the next pexts
# only take those in the previous run
# only assign up to the last element of d.
d[:-1] = [i[i["t"] < j["t"].min()] for i, j in zip(d[:-1], d[1:])]
if len(d) > 1:
    d = np.concatenate(d)
else:
Beispiel #3
0
        for frame in frames:
            group=str(frame['step']);
            h5w(f, frame, group=group,
                compression='lzf' if dozip else None);

if __name__=='__main__':
    opts = docopt(__doc__,help=True);
    vprint = mkvprint(opts);
    dims=[]
    if opts['--x']: dims.append('xi');
    if opts['--y']: dims.append('yi');
    if opts['--z']: dims.append('zi');
    if len(dims)==0:
        dims=['xi','yi','zi'];
    #reading in using the reader.
    frames=rd.read(opts['<input>'], gzip=opts['--gzip']);
    
    if opts['--sort']:
        vprint("sorting...");
        frames[:] = [sortframe(frame) for frame in frames];
        vprint("done");
    #experimental hashing
    if opts['--firsthash']:
        d=firsthash(frames[0],dims, removedupes=True);
        dump_pickle(opts['--firsthash'], d);
        frames[:] = [addhash(frame,d,removedupes=True) for frame in frames];
    elif opts['--hash']:
        d = readfile(opts['--hash'],dumpfull=True);
        frames[:] = [addhash(frame,d,removedupes=True) for frame in frames];
    #outputting.
    if opts['--hdf']:
Beispiel #4
0
    if mn <= k <= mx]);
if opts['--lsp']:
    lspf=opts['--lsp'];
else:
    lspf=[f for f in files if re.search(".*\.lsp$",f)][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);
pexts = getpexts(lsp);
latetime = float(opts['--late-time']) if opts['--late-time'] else None;
vprint('reading in files');
d = [ rd.read(name)
      for name in pext ];

d[:] = [
    rfn.rec_append_fields(
        id, 'species',
        np.ones(len(id)).astype(int)*pexts[i]['species'])
    for id,i in zip(d,key) ];
vprint('length of d={}'.format(len(d)));

d = [ i for i in d if i['t'].shape[0] > 0];
vprint('length of d={} after remove empties'.format(len(d)));
vprint('cutting out duplicate times');
if len(d) > 1:
    d = np.concatenate(d);
elif d == []: