Exemplo n.º 1
0
def plot_all_grid(num_stars, big_body, num):

    file_name = ''
    data = []

    big_data = rp.get_data(big_body)
    w_big = []
    M_big = []
    for x in range(len(big_data[0])):
        w_big.append(big_data[5][x])
        M_big.append(big_data[7][x])
    lambda_big = []
    for x in range(len(w_big)):
        lambda_big.append(w_big[x] + M_big[x])

    if num_stars % 9 == 0:
        counter = num_stars / 9
    else:
        counter = (num_stars / 9) + 1

    for x in range(1, counter + 1):

        plt.figure(x)
        plt.title("Resonant Argument over Time [-180, 180]")

    #get data from each star, plot phi for each star
    for x in range(1, num_stars + 1):
        file_name = 'S' + str(x) + '.aei'
        data = rp.get_data(file_name)
        lambda_little = []
        phi = []
        phi_mod = []
        w = data[5]
        M = data[7]
        color = [random.random(), random.random(), random.random()]
        for y in range(len(data[0])):
            lambda_little.append(w[y] + M[y])
            if num == 1:
                phi.append(
                    2 * lambda_big[y] - lambda_little[y] - w[y] + 180
                )  #from Table 8.1 ROW 1, add 180 to get between -180 and 180
            elif num == 2:
                phi.append(2 * lambda_big[y] - lambda_little[y] - w_big[y] +
                           180)  #from Table 8.1 ROW 2
            phi_mod.append(
                (phi[y] % 360) -
                180)  #phi mod 360 degrees, minus 180 to get correct frame
        num_fig = (x % counter) + 1
        plt.figure(num_fig)
        num_plot = '33' + str((x % 9) + 1)
        plt.subplot(num_plot)
        plt.xlabel("t (years)")
        plt.ylabel("phi (degrees)")
        plt.ylim(-180., 180.)
        plt.plot(data[0], phi_mod, '-o', c=color)

    plt.show()
Exemplo n.º 2
0
def get_resargs(num_stars, big_body, p, q, row):

    file_name = ''
    data = []

    big_data = rp.get_data(big_body)

    w_big = []
    M_big = []

    for x in range(len(big_data[0])):
        w_big.append(big_data[5][x])
        M_big.append(big_data[7][x])
    lambda_big = []
    for x in range(len(w_big)):
        lambda_big.append(w_big[x] + M_big[x])

    resargs = []

    for x in range(1, num_stars + 1):
        file_name = 'S' + str(x) + '.aei'
        data = rp.get_data(file_name)
        lambda_little = []
        phi = []
        phi_mod = []
        w = data[5]
        M = data[7]

        for y in range(len(data[0])):
            lambda_little.append(w[y] + M[y])
            if row == 1:
                phi.append(
                    (p + q) * lambda_big[y] + (1 - p - q) * lambda_little[y] -
                    w[y] + 180
                )  #from Table 8.1 ROW 1, add 180 to get between -180 and 180
            elif row == 2:
                phi.append(
                    (p + q) * lambda_big[y] + (1 - p - q) * lambda_little[y] -
                    w_big[y] + 180)  #from Table 8.1 ROW 2
            elif row == 3:
                phi.append((p + q) * lambda_big[y] +
                           (2 - p - q) * lambda_little[y] - 2 * w[y] + 180)
            elif row == 4:
                phi.append((p + q) * lambda_big[y] +
                           (2 - p - q) * lambda_little[y] - w_big[y] - w[y] +
                           180)
            phi_mod.append((phi[y] % 360) - 180)

        resargs.append(phi_mod)
    return resargs
Exemplo n.º 3
0
def plot_z_ang_mom(num_stars):

    file_name = ''
    data = []

    #get data from each star, plot z component of angular momentum
    for x in range(1, num_stars + 1):
        file_name = 'S' + str(x) + '.aei'
        data = rp.get_data(file_name)
        t = data[0]
        e = data[2]
        i = data[3]
        z_comp = []

        for n in range(len(t)):
            z_comp.append((1. - (e[n]**2))**0.5 * math.cos(math.radians(i[n])))

        color = [random.random(), random.random(), random.random()]
        plt.figure(x)
        plt.plot(t, z_comp, ':o', c=color)
        plt.xlabel("time t (years)")
        plt.ylabel(" (1-e^2) ^ (1/2) * cos(i) ")
        plt.show()
Exemplo n.º 4
0
def plot_adiabatic(file_name, m_cen, p, q):

    data = rp.get_data(file_name)
    a = data[1]
    e = data[2]
    i = data[3]

    color = [random.random(), random.random(), random.random()]

    C_pq = []

    for t in range(len(data[0])):
        C_pq.append(
            (m_cen * a[t])**0.5 *
            ((p + q) - p * (1 - e[t]**2)**0.5 * math.cos(math.radians(i[t]))))

    plt.figure(1)

    plt.xlabel("t (years)")
    plt.ylabel("Adiabatic invariant C_pq")

    plt.plot(data[0], C_pq, 'o', c=color)

    plt.show()
Exemplo n.º 5
0
def get_res_arg1(file_name, big_file_name, p, q, sub_res, line_start,
                 line_end):  #SHOULD get row from p/q?

    #get necessary data about secondary black hole
    big_data = rp.get_data(big_file_name)

    w_big = big_data[5]
    M_big = big_data[7]

    lambda_big = []
    for x in range(len(w_big)):
        lambda_big.append(w_big[x] + M_big[x])

    #get data about the star/test particle
    data = []
    data = rp.get_data(file_name)
    lambda_little = []
    phi = []
    phi_mod = []
    time = []
    Om = data[4]
    w = data[5]
    M = data[7]

    for x in range(len(w)):
        lambda_little.append(w[x] + M[x])

    #to set row from Table 8.1 ------CORRECT THIS --- add row 6 for 2nd order
    if q == 1.:
        row = 1
    if q == 2.:
        if sub_res == 0.:
            row = 3  #--- also check Row 6 --- plot both for 2nd order
        elif sub_res == 1.:
            row = 6

    #to calculate resonant argument over time
    for y in range(line_end - line_start +
                   1):  #gets the proper number of lines to be considered
        t = ((int)(line_start + y))  #shifts to get the right interval
        time.append(data[0][t])  #will have indices 0 - y_max
        if row == 1:
            phi.append(
                (p + q) * lambda_big[t] + (1 - p - q) * lambda_little[t] -
                w[t] + 180
            )  #from Table 8.1 ROW 1, add 180 to get between -180 and 180
        elif row == 2:
            phi.append(
                (p + q) * lambda_big[t] + (1 - p - q) * lambda_little[t] -
                w_big[t] + 180)  #from Table 8.1 ROW 2
        elif row == 3:
            phi.append((p + q) * lambda_big[t] +
                       (2 - p - q) * lambda_little[t] - 2 * w[t] + 180)
        elif row == 4:
            phi.append((p + q) * lambda_big[t] +
                       (2 - p - q) * lambda_little[t] - w_big[t] - w[t] + 180)
        elif row == 6:
            phi.append(
                (p + q) * lambda_big[t] + (2 - p - q) * lambda_little[t] -
                2 * Om[t] + 180)  #ADDED -- VERIFY
        phi_mod.append(
            (phi[y] % 360) - 180
        )  #to go to correct index (y not t)          #phi mod 360 degrees, minus 180 to get correct frame
        #phi_mod.append(2*(lambda_big[t]%360) - (lambda_little[t]%360) - (w[t]%360))

    return [time, phi_mod]
Exemplo n.º 6
0
def plot_phi_phi_dot(num_stars, big_body, num):

    file_name = ''
    data = []

    big_data = rp.get_data(big_body)
    #print big_data
    w_big = []
    M_big = []
    #print len(big_data[0])
    for x in range(len(big_data[0])):
        w_big.append(big_data[5][x])
        M_big.append(big_data[7][x])
    lambda_big = []
    for x in range(len(w_big)):
        lambda_big.append(w_big[x] + M_big[x])

    #get data from each star, plot phi for each star
    for x in range(1, num_stars + 1):
        file_name = 'S' + str(x) + '.aei'
        data = rp.get_data(file_name)
        lambda_little = []
        phi = []
        phi_mod = []
        t = data[0]
        w = data[5]
        M = data[7]
        phi_dot = []
        #phi_dot_mod = []
        phi_prime = []
        phi_prime_mod = []
        t_prime = []
        color = [random.random(), random.random(), random.random()]
        for y in range(len(data[0])):
            lambda_little.append(w[y] + M[y])
            if num == 1:
                phi.append(2 * lambda_big[y] - lambda_little[y] - w[y] +
                           180.)  #from Table 8.1 ROW 1
            elif num == 2:
                phi.append(2 * lambda_big[y] - lambda_little[y] - w_big[y] +
                           180.)  #from Table 8.1 ROW 2
            phi_mod.append((phi[y] % 360.) - 180.)  #phi mod 360 degrees
        for y in range(len(data[0]) - 1):
            phi_dot.append((phi[y + 1] - phi[y]) / (t[y + 1] - t[y]))
            phi_prime.append((phi[y + 1] + phi[y]) / 2.)
            t_prime.append((t[y + 1] + t[y]) / 2.)
            phi_prime_mod.append((phi_prime[y] % 360.) - 180.)
        plt.figure(x)
        plt.subplot(211)
        plt.title("Phi (mod) vs. Phi Dot")  #unicode
        plt.xlabel("phi (degrees)")
        #plt.xlim(-180., 180.)
        plt.ylabel("phi dot (degrees)")
        plt.plot(phi_prime_mod, phi_dot, 'o', c=color)
        plt.subplot(212)
        plt.title("Phi (mod) over Time")
        plt.xlabel("t (years)")
        plt.ylabel("phi mod 360 (degrees)")
        plt.plot(t_prime, phi_prime_mod, '-o', c=color)

        plt.show()
Exemplo n.º 7
0
def plot_res_arg1(num_stars, big_body, p, q, row):

    file_name = ''
    data = []

    big_data = rp.get_data(big_body)
    #print big_data
    w_big = []
    M_big = []
    #print len(big_data[0])
    for x in range(len(big_data[0])):
        w_big.append(big_data[5][x])
        M_big.append(big_data[7][x])
    lambda_big = []
    for x in range(len(w_big)):
        lambda_big.append(w_big[x] + M_big[x])

    #astrofest_set = [1, 2, 7]       #sample set of 2:1 mJ = .001 stars with 1 librating 7 circulating and 2 somewhere in between
    #get data from each star, plot phi for each star
    for x in range(1, num_stars + 1):
        #for x in astrofest_set:
        file_name = 'S' + str(x) + '.aei'
        data = rp.get_data(file_name)
        lambda_little = []
        phi = []
        phi_mod = []
        w = data[5]
        M = data[7]
        color = [random.random(), random.random(), random.random()]
        '''colors = ['magenta', 'blue', 'green']       #
        if x == 1:
            c = colors[0]
        elif x == 2:
            c = colors[1]
        else:
            c = colors[2]        '''       #
        for y in range(len(data[0])):
            lambda_little.append(w[y] + M[y])
            if row == 1:
                phi.append(
                    (p + q) * lambda_big[y] + (1 - p - q) * lambda_little[y] -
                    w[y] + 180
                )  #from Table 8.1 ROW 1, add 180 to get between -180 and 180
            elif row == 2:
                phi.append(
                    (p + q) * lambda_big[y] + (1 - p - q) * lambda_little[y] -
                    w_big[y] + 180)  #from Table 8.1 ROW 2
            elif row == 3:
                phi.append((p + q) * lambda_big[y] +
                           (2 - p - q) * lambda_little[y] - 2 * w[y] + 180)
            elif row == 4:
                phi.append((p + q) * lambda_big[y] +
                           (2 - p - q) * lambda_little[y] - w_big[y] - w[y] +
                           180)
            phi_mod.append(
                (phi[y] % 360) -
                180)  #phi mod 360 degrees, minus 180 to get correct frame
            #phi_mod.append(2*(lambda_big[y]%360) - (lambda_little[y]%360) - (w[y]%360))
        plt.figure(x)
        #plt.subplot(211)
        #plt.title("Resonant Argument over Time")
        #plt.xlabel("t (years)")
        #plt.ylabel("phi (degrees)")
        #plt.plot(data[0], phi, '-o', c = color)

        #plt.subplot(212)
        #plt.title("Resonant Argument over Time [0, 360]")
        plt.xlabel("t (years)")
        plt.ylabel("phi mod 360 (degrees)")
        plt.ylim(-180., 180.)
        plt.plot(data[0], phi_mod, ':o', c=color)  #

        plt.show()