Ejemplo n.º 1
0
    d = np.concatenate(d)
else:
    d = d[0]
if latetime:
    print("cutting out times greater than {}".format(latetime))
    d = d[d["t"] <= latetime]
# calculating quantities
if num_of_coords == 2:
    # notice this only does x-y, y-z, and inverts the first.
    x = "x" if opts["--X"] else "y"
    y = "y" if opts["--Y"] else "z"
    coords = [x, y]
    if opts["--reverse"]:
        coords.reverse()
elif num_of_coords == 3:
    if opts["--reverse"]:
        coords = ["x", "z", "y"]
    else:
        coords = ["x", "y", "z"]

massE = float(opts["--massE"]) if opts["--massE"] else None

d = add_quantities(d, coords, massE=massE)
if opts["--dict"]:
    d = {k: d[k] for k in d.dtype.names}
    from pys import dump_pickle

    dump_pickle(outname, d)
else:
    np.save(outname, d)
Ejemplo n.º 2
0
      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 == []:
    print("empty pext");
    quit();
else:
    d = d[0];
vprint('sorting by times')
d.sort(order='t');
if latetime:
    print('cutting out times greater than {}'.format(latetime));
    d = d[ d['t'] <= latetime ];
#calculating quantities
if opts['--reverse']:
    dim = dim[:-2] + list(reversed(dim[-2:]))
massE = float(opts['--massE']) if opts['--massE'] else None;
d = add_quantities(d, dim, massE=massE);
np.save(outname, d);