def plot_lb(i, ts, plot_extreme=False, save_name='fwd', zorder=1, **kargs):
    # integrate orbit
    if RUN:
        vxvv = [ra[i], dec[i], d[i], pmra[i], pmde[i], rv[i]]
        o = Orbit(vxvv=vxvv, radec=True, ro=ro, vo=vo, solarmotion=solarmotion)
        o.integrate(ts, pot, method='leapfrog')

        # get orbit l and b
        ll = o.ll(ts)
        bb = o.bb(ts)

        np.save("./Orbits/{}/l{}150Myr.npy".format(star_id[i], save_name), ll)
        np.save("./Orbits/{}/b{}150Myr.npy".format(star_id[i], save_name), bb)

    else:
        ll = np.load("./Orbits/{}/l{}150Myr.npy".format(star_id[i], save_name))
        bb = np.load("./Orbits/{}/b{}150Myr.npy".format(star_id[i], save_name))

    Npoints = len(ll)

    # Find boundary breaks at -180 and 180
    boundary_breaks = []

    # crossings for 180
    for j in range(1, Npoints):
        # crossings for 180+
        if (ll[j - 1] <= 180) and (ll[j] > 180):
            boundary_breaks.append(j)
        # crossings for 180-
        elif (ll[j - 1] >= 180) and (ll[j] < 180):
            boundary_breaks.append(j)

    boundary_breaks.append(Npoints)

    # fix ll > 180
    ll[ll > 180] = ll[ll > 180] - 360

    # plots
    j0 = 0
    for k in range(len(boundary_breaks)):
        jf = boundary_breaks[k]
        plt.plot(ll[j0:jf] * radconv,
                 bb[j0:jf] * radconv,
                 zorder=zorder,
                 **kargs)
        j0 = jf

    # plot extremes
    if plot_extreme == 'lower':
        lower = plt.plot(ll[-1] * radconv,
                         bb[-1] * radconv,
                         marker='x',
                         markersize=4,
                         color=colors[i],
                         alpha=1,
                         zorder=zorder + 1)
        return lower

    elif plot_extreme == 'upper':
        upper = plt.plot(ll[-1] * radconv,
                         bb[-1] * radconv,
                         marker='o',
                         markersize=4,
                         markeredgecolor=colors[i],
                         color="#FFFFFF",
                         alpha=1,
                         zorder=zorder + 1)
        return upper
示例#2
0
if 'z' in o_data.keys(): o_data['z'] = o.z(ts)
if 'r' in o_data.keys(): o_data['r'] = o.R(ts)
if 'phi' in o_data.keys(): o_data['phi'] = o.phi(ts)

if 'vx' in o_data.keys(): o_data['vx'] = o.vx(ts)
if 'vy' in o_data.keys(): o_data['vy'] = o.vy(ts)
if 'vz' in o_data.keys(): o_data['vz'] = o.vz(ts)
if 'vr' in o_data.keys(): o_data['vr'] = o.vR(ts)
if 'vphi' in o_data.keys(): o_data['vphi'] = o.vT(ts)

if 'U' in o_data.keys(): o_data['U'] = o.U(ts)
if 'V' in o_data.keys(): o_data['V'] = o.V(ts)
if 'W' in o_data.keys(): o_data['W'] = o.W(ts)

if 'l' in o_data.keys(): o_data['l'] = o.ll(ts)
if 'b' in o_data.keys(): o_data['b'] = o.bb(ts)
if 'pml' in o_data.keys(): o_data['pml'] = o.pmll(ts)
if 'pmb' in o_data.keys(): o_data['pmb'] = o.pmbb(ts)

################################################################################

# SAVE DATA ####################################################################

savefiles = not args.notsave

# Prepare savefile
savedir = args.savedir
ensure_dir(savedir)

dframe = pd.DataFrame(o_data)