예제 #1
0
def rootfind_dimless_alt(m,
                         k,
                         qlist,
                         ecc=0.,
                         chi=0.,
                         gravfunc=grav.chi_gravity_deriv,
                         verbose=False,
                         inc=1.0033,
                         saving=False):
    """
    For a given m, k and qlist, and potentially for different radius, mass and
    period as well, determines the wave mode and calculates the eigenvalues
    from the asymptotically calculated values.
    """
    dlngrav = partial(gravfunc, chi)
    mode_admin = Property.Mode_admin(m, k)
    mode_admin.set_qlist(qlist)
    mode_admin.set_curvilinear(ecc, chi, dlngrav)

    qlist, found_lamlist = roots.multi_rootfind_fromguess_dimless(
        mode_admin, verbose=verbose, inc=inc)
    #    roots.multi_rootfind_fromguess_dimless(m, qlist, is_even, guesslist, ecc, dlngrav, verbose=verbose, inc=inc)
    if saving:
        savestring = "data/Curvilinear/range_{}_{}_steps_{}_kval_{}_ecc_{}_chi_{}.txt"\
                                    .format(qlist[0],qlist[-1],len(qlist),str(k), str(ecc), str(chi))
        print "\nSaving to: {}\n\n".format(savestring)
        np.savetxt(savestring, found_lamlist)
    if ecc == .25:
        ls = "dotted"
    elif ecc == .5:
        ls = "dashed"
    else:
        ls = "solid"
    plt.plot(qlist, found_lamlist, ls=ls)
예제 #2
0
def lambda_grid(m,
                k,
                size,
                qmin,
                qmax,
                lammin,
                lammax,
                ecc,
                chi,
                dlngrav,
                saving=False,
                force_func=False):
    qarr = np.linspace(qmin, qmax, size)
    lamarr = np.linspace(lammin, lammax, size)
    print lamarr

    mode_admin = Property.Mode_admin(m, k)
    mode_admin.validate_values()
    mode_admin.set_curvilinear(ecc, chi, dlngrav)
    mode_admin.set_qlist(qarr)
    if mode_admin.is_even:
        evenstr = "Even"
    else:
        evenstr = "Odd"
    direction = mode_admin.get_direction()
    wavemode = mode_admin.get_wavemode(direction)

    qdim = np.repeat(qarr, size)
    lamdim = np.tile(lamarr, size)

    values = []
    for q, lam in zip(qdim, lamdim):
        if force_func:
            mode_admin.wavemode = "kelvin mode"
        value = roots.shoot_curvi_dimless(lam, mode_admin, q)
        values.append(value)
        if lam in [lamdim[0]]:
            print q, lam, value
    heatmap = np.asarray(values).reshape(size, size).T

    all_data = np.asarray(zip(qdim, lamdim, values))
    if saving:
        folderloc = "data/lamgrid/m_{}/".format(m)
        if not os.path.exists(folderloc):
            os.makedirs(folderloc)
        savestring = folderloc + "qrange_{}_{}_lamrange_{}_{}_steps_{}_ecc_{}_chi_{}_{}.txt"\
                    .format(qarr[0],qarr[-1],lamarr[0],lamarr[-1],size,str(ecc),str(chi),evenstr)
        np.savetxt(savestring, all_data)
    return all_data
예제 #3
0
def create_grid(m, k, size, qmin, qmax, ecc, chi, dlngrav, saving=False):
    qarr = np.linspace(qmin, qmax, size)

    mode_admin = Property.Mode_admin(m, k)
    mode_admin.validate_values()
    is_even = mode_admin.check_is_even()
    l = mode_admin.get_l()
    mode_admin.set_curvilinear(ecc, chi, dlngrav)
    mode_admin.set_qlist(qarr)

    direction = mode_admin.get_direction()
    wavemode = mode_admin.get_wavemode(direction)
    print is_even, l, wavemode

    wavemode += "s"
    if wavemode[0] == "g":
        wavemode += "_list"
    wavemode = wavemode.replace(" ", "_")
    if wavemode[0] == "y" or wavemode[
            0] == "k":  # yanai and kelvin modes dont have k argument
        args = m, qarr, ecc, chi
    else:
        args = m, k, qarr, ecc, chi
    guesslist = getattr(curvasym, wavemode)(*args)
    lamarr = np.linspace(min(guesslist) * .9, max(guesslist) * 1.1, size)
    if max(guesslist) < 1.:
        lamarr = np.linspace(0.01, max(guesslist) * 1.1, size)

    qdim = np.repeat(qarr, size)
    lamdim = np.tile(lamarr, size)

    values = []
    for q, lam in zip(qdim, lamdim):
        value = roots.shoot_curvi_dimless(lam, mode_admin, q)
        values.append(value)
        if lam in [lamdim[0]]:
            print q, lam, value
    heatmap = np.asarray(values).reshape(size, size).T

    all_data = np.asarray(zip(qdim, lamdim, values))
    if saving:
        folderloc = "data/gridplot/"
        if not os.path.exists(folderloc):
            os.makedirs(folderloc)
        savestring = folderloc+"qrange_{}_{}_steps_{}_kval_{}_ecc_{}_chi_{}.txt"\
                            .format(qarr[0],qarr[-1],size,str(k), str(ecc), str(chi))
        np.savetxt(savestring, all_data)
    return all_data
예제 #4
0
def eccentricity_compare(m, k, s, q, ecclist, chilist, gravfunc):
    if len(ecclist) != len(chilist):
        raise ValueError(
            "Warning: ecclist and chilist should be the same length!")
    N = 125

    mode_admin = Property.Mode_admin(m, k)
    mode_admin.set_qlist(np.asarray([q]))

    fig = plt.figure()
    ax1 = fig.add_subplot(3, 1, 1)
    ax2 = fig.add_subplot(3, 1, 2)
    ax3 = fig.add_subplot(3, 1, 3)
    ax1.set_xlim([0, 1])
    ax2.set_xlim([0, 1])
    ax3.set_xlim([0, 1])
    ax1.set_ylabel(r"$\Theta(\sigma)$")
    ax2.set_ylabel(r"$\hat\Theta(\sigma)$")
    ax3.set_ylabel(r"$\tilde\Theta(\sigma)$")
    ax3.set_xlabel(r"$\mu \equiv \cos(\theta)$")

    for ecc, chi in zip(ecclist, chilist):
        dlngrav = partial(gravfunc, chi)
        mode_admin.set_curvilinear(ecc, chi, dlngrav)
        guess, lam, wavename, direc = rootfind_dimless(mode_admin,
                                                       verbose=False,
                                                       inc=1.075,
                                                       rsearch=False)
        mu = np.linspace(1., 0., N)
        sigma = np.sqrt(1 - ((ecc**2.) * (1 - mu**2)))

        # Numeric values
        is_even = Curvilinear.check_is_even(m, k)
        num_hough, num_houghHat = numerics(Curvilinear, [mode_admin, q], lam,
                                           N)
        num_houghTilde = -m * num_hough - q * mu / sigma * num_houghHat

        ax1.set_title("m: {}, k: {}, s: {}, q: {}  ({}grade {})".format(
            m, k, s, q, direc, wavename))
        ax1.plot(mu, num_hough, label=r"ecc: {}, $\chi$: {}".format(ecc, chi))
        ax2.plot(mu, num_houghHat)
        ax3.plot(mu, num_houghTilde)

    ax1.tick_params(axis='y', which='both', left='on', right='on')
    ax2.tick_params(axis='y', which='both', left='on', right='on')
    ax3.tick_params(axis='y', which='both', left='on', right='on')
    ax1.legend()
    plt.show()
예제 #5
0
def rootfind_any(m,
                 k,
                 qlist,
                 r_eq=1e4,
                 mass=1.4 * 1.9885e30,
                 period=np.inf,
                 verbose=False,
                 inc=1.0033):
    """
    For a given m, k and qlist, and potentially for different radius, mass and
    period as well, determines the wave mode and calculates the eigenvalues
    from the asymptotically calculated values.
    """
    mode_admin = Property.Mode_admin(m, k)
    mode_admin.validate_values()
    is_even = mode_admin.is_even()
    l = mode_admin.get_l()

    if np.average(qlist) * m < 0:
        direction = "pro"
    else:
        direction = "retro"

    wavemode = mode_admin.get_wavemode(direction)
    print is_even, l, wavemode

    wavemode += "s"
    if wavemode[0] == "g":
        wavemode += "_list"
    wavemode = wavemode.replace(" ", "_")
    if wavemode[0] == "y" or wavemode[
            0] == "k":  # yanai and kelvin modes only have two arguments
        args = m, qlist
    else:
        args = m, k, qlist
    guesslist = getattr(asym, wavemode)(*args)

    qlist, found_lamlist = roots.multi_rootfind_fromguess(m,
                                                          qlist,
                                                          is_even,
                                                          guesslist,
                                                          r_eq,
                                                          mass,
                                                          period,
                                                          verbose=False,
                                                          inc=inc)
    plt.plot(qlist, found_lamlist)
예제 #6
0
def create_data(m,
                k,
                s,
                q,
                eccstart,
                eccend,
                frames,
                gravfunc,
                town_normalize=False):
    N = 125

    mode_admin = Property.Mode_admin(m, k)
    mode_admin.set_qlist(np.asarray([q]))
    ecclist = np.linspace(eccstart, eccend, frames)
    subdir = "data/moviedata/{}_{}_{}_{}_{}_{}_{}_{}".format(
        str(m), str(k), str(s), str(q), str(eccstart), str(eccend),
        str(frames), str(town_normalize))
    if not os.path.exists(subdir):
        os.makedirs(subdir)

    for i in range(len(ecclist)):
        ecc = ecclist[
            i]  # This way its ensured you read out the files in the proper order!
        chi = 2. * (ecc**2.)
        dlngrav = partial(gravfunc, chi)
        mode_admin.set_curvilinear(ecc, chi, dlngrav)
        lam, wavename, direc = rootfind_dimless(mode_admin,
                                                verbose=False,
                                                inc=1.075,
                                                rsearch=False)[1:]

        mu = np.linspace(1., 0., N)
        sigma = np.sqrt(1 - ((ecc**2.) * (1 - mu**2)))
        num_hough, num_houghHat = numerics(Curvilinear, [mode_admin, q], lam,
                                           N)
        num_houghTilde = -m * num_hough - q * mu / sigma * num_houghHat

        if town_normalize:
            num_hough, num_hougHat, num_houghTilde = townsendify(
                num_hough, num_houghHat, num_houghTilde, k, m)

        data = np.asarray([num_hough, num_houghHat, num_houghTilde])
        savestring = subdir + "/{}_{}_{}".format(str(ecc), str(chi),
                                                 str(gravfunc.__name__))
        np.savetxt(savestring, data)
예제 #7
0
def rootfind_dimless_alt(m, k, qlist, ecc=0., chi=0., gravfunc=grav.chi_gravity_deriv, verbose=False, inc=1.0033):
    """
    For a given m, k and qlist, and potentially for different radius, mass and
    period as well, determines the wave mode and calculates the eigenvalues
    from the asymptotically calculated values.
    """
    dlngrav=partial(gravfunc, chi)
    mode_admin = Property.Mode_admin(m, k)
    mode_admin.set_qlist(qlist)
    mode_admin.set_curvilinear(ecc, chi, dlngrav)

    if np.average(qlist)*m < 0:
        direction = "pro"
    else:
        direction = "retro"

    wavemode = mode_admin.get_wavemode(direction)
    print mode_admin.is_even, mode_admin.l, mode_admin.mode

    wavemode += "s"
    if wavemode[0] == "g":
        wavemode += "_list"
    wavemode = wavemode.replace(" ", "_")
    if wavemode[0] == "y" or wavemode[0] == "k":  # yanai and kelvin modes only have two arguments
        args = m, qlist, ecc, chi
    else:
        args = m, k, qlist, ecc, chi
    guesslist = getattr(curvasym, wavemode)(*args)

    qlist, found_lamlist = roots.multi_rootfind_fromguess_dimless(mode_admin, verbose=verbose, inc=inc)  # if the mode is an argument here it can figure out how to normalize in a proper way ...
    if ecc == .25:
        ls="dotted"
    elif ecc == .5:
        ls="dashed"
    else:
        ls="solid"
    plt.plot(qlist, found_lamlist, ls=ls)
예제 #8
0
def rootfind_dimless(m, k, qlist, ecc=0., dlngrav=partial(grav.chi_gravity_deriv, 0.), verbose=False, inc=1.0033):
    """
    For a given m, k and qlist, and potentially for different radius, mass and
    period as well, determines the wave mode and calculates the eigenvalues
    from the asymptotically calculated values.
    """
    mode_admin = Property.Mode_admin(m, k)
    mode_admin.validate_values()
    is_even = mode_admin.is_even()
    l = mode_admin.get_l()

    if np.average(qlist) < 0:
        direction = "retro"
    else:
        direction = "pro"

    wavemode = mode_admin.get_wavemode(direction)
    print is_even, l, wavemode

    wavemode += "s"
    if wavemode[0] == "g":
        wavemode += "_list"
    wavemode = wavemode.replace(" ", "_")
    if wavemode[0] == "y" or wavemode[0] == "k":  # yanai and kelvin modes only have two arguments
        args = m, qlist
    else:
        args = m, k, qlist
    guesslist = getattr(asym, wavemode)(*args)

    qlist, found_lamlist = roots.multi_rootfind_fromguess_dimless(m, qlist, is_even, guesslist, ecc, dlngrav, verbose=False, inc=inc)
    if ecc == .25:
        ls="dotted"
    elif ecc == .5:
        ls="dashed"
    else:
        ls="solid"
    plt.plot(qlist, found_lamlist, ls=ls)
예제 #9
0
def eccentricity_movie(m,
                       k,
                       s,
                       q,
                       eccstart,
                       eccend,
                       frames,
                       gravfunc,
                       fixframe=False,
                       moviesaving=False,
                       town_normalize=False):
    """
    Creates a movie at a set m, k and q for "frames" steps between eccstart and eccend.
    Will assume chi = 2*(ecc**2)
    """
    N = 125

    mode_admin = Property.Mode_admin(m, k)
    mode_admin.set_qlist(np.asarray([q]))
    direc = mode_admin.get_direction()
    mode = mode_admin.get_wavemode(direc)
    ecclist = np.linspace(eccstart, eccend, frames)
    subdir = "data/moviedata/{}_{}_{}_{}_{}_{}_{}_{}".format(
        str(m), str(k), str(s), str(q), str(eccstart), str(eccend),
        str(frames), str(town_normalize))

    fig = plt.figure()
    ax1 = fig.add_subplot(3, 1, 1)
    ax2 = fig.add_subplot(3, 1, 2)
    ax3 = fig.add_subplot(3, 1, 3)
    mu = np.linspace(1., 0., N)
    if fixframe:
        savestring = subdir + "/{}_{}_{}".format(0.0, 0.0,
                                                 str(gravfunc.__name__))
        data = np.loadtxt(savestring)
        num_hough_init, num_houghHat_init, num_houghTilde_init = data
        ax1lim = [min(num_hough_init) * 1.1, max(num_hough_init) * 1.2]
        ax2lim = [min(num_houghHat_init) * 1.1, max(num_houghHat_init) * 1.2]
        ax3lim = [
            min(num_houghTilde_init) * 1.1,
            max(num_houghTilde_init) * 1.2
        ]

    def update(i):
        ecc = ecclist[i]
        chi = 2. * (ecc**2.)
        savestring = subdir + "/{}_{}_{}".format(str(ecc), str(chi),
                                                 str(gravfunc.__name__))
        data = np.loadtxt(savestring)
        num_hough, num_houghHat, num_houghTilde = data

        # Clear the subplots
        ax1.cla()
        ax2.cla()
        ax3.cla()

        ax1.set_xlim([0, 1])
        ax2.set_xlim([0, 1])
        ax3.set_xlim([0, 1])
        ax1.set_ylabel(r"$\Theta(\sigma)$")
        ax2.set_ylabel(r"$\hat\Theta(\sigma)$")
        ax3.set_ylabel(r"$\tilde\Theta(\sigma)$")
        ax3.set_xlabel(r"$\mu \equiv \cos(\theta)$")
        if fixframe:
            ax1.plot(mu, num_hough_init, ls="--", label="Spherical")
            ax2.plot(mu, num_houghHat_init, ls="--")
            ax3.plot(mu, num_houghTilde_init, ls="--")
            ax1.set_ylim(ax1lim)
            ax2.set_ylim(ax2lim)
            ax3.set_ylim(ax3lim)

        ax1.set_title(
            "m: {}, k: {}, s: {}, q: {}  ({}grade {}), ecc: {:.4f}, $\chi$: {:.4f}"
            .format(m, k, s, q, direc, mode, ecc, chi))
        ax1.plot(mu, num_hough, label="Curvilinear")
        ax2.plot(mu, num_houghHat)
        ax3.plot(mu, num_houghTilde)
        ax1.legend()

    # Set up formatting for the movie files
    Writer = animation.writers['ffmpeg']
    writer = Writer(fps=30, metadata=dict(artist='Bart'), bitrate=750)

    ani = animation.FuncAnimation(fig,
                                  update,
                                  frames=frames,
                                  interval=20,
                                  repeat=False)
    if moviesaving:
        tardir = "data/movies/{}_{}".format(str(direc), mode.replace(" ", "_"))
        if not os.path.exists(tardir):
            os.makedirs(tardir)
        name = "/{}_{}_{}_{}_{}_{}_{}".format(str(eccstart), str(eccend),
                                              str(frames), str(m), str(k),
                                              str(q), str(town_normalize))
        print "Saving file to: {}.mp4".format(tardir + name)
        ani.save(tardir + "{}.mp4".format(name), writer=writer)
    else:
        plt.show()
예제 #10
0
def make_houghs(m, k, s, q, ecc, chi, gravfunc):
    N = 125

    dlngrav = partial(gravfunc, chi)
    mode_admin = Property.Mode_admin(m, k)
    mode_admin.set_qlist(np.asarray([q]))
    mode_admin.set_curvilinear(ecc, chi, dlngrav)

    guess, lam, wavename, direc = rootfind_dimless(mode_admin,
                                                   verbose=False,
                                                   inc=1.075,
                                                   rsearch=False)
    mu = np.linspace(1., 0., N)
    L = lam**.5
    Lnu = L * q  # it should just be q but that breaks if q is negative?
    sig = np.sqrt(Lnu) * mu
    guesssig = np.sqrt(guess**.5 * q) * mu

    print "Lnu: {}, guessLnu: {}".format(Lnu, (guess**.5) * q)
    print "k: {}, s: {}, q: {}".format(k, s, q)

    # Numeric values
    is_even = Curvilinear.check_is_even(m, k)
    num_hough, num_houghHat = numerics(Curvilinear, [mode_admin, q], lam, N)
    num_houghTilde = -m * num_hough - q * mu * num_houghHat

    ## Analytic values
    ana_houghHat = houghHat(s, guesssig)
    ana_hough = hough(s, guesssig, m, guess, q)
    ana_houghTilde = houghTilde(s, guesssig, m, guess, q)
    if wavename == "kelvin mode":
        ana_houghHat = kelvinhoughHat(mu, m, q)
        ana_hough = kelvinhough(mu, m, q)
        ana_houghTilde = kelvinhoughTilde(mu, m, q)

    num_hough, num_houghHat, num_houghTilde = townsendify(
        num_hough, num_houghHat, num_houghTilde, k, m)
    ana_hough, ana_houghHat, ana_houghTilde = townsendify(
        ana_hough, ana_houghHat, ana_houghTilde, k, m)

    fig = plt.figure()
    ax1 = fig.add_subplot(3, 1, 1)
    ax1.set_title(
        "m: {}, k: {}, s: {}, q: {}  ({}grade {}); ecc: {}, $\chi$: {}".format(
            m, k, s, q, direc, wavename, ecc, chi))
    ax1.plot(mu, num_hough, ls="--", label="Numeric")
    ax1.plot(mu, ana_hough, label="Analytic")
    ax1.set_ylabel(r"$\Theta(\sigma)$")
    ax1.set_xlim([0, 1])
    ax2 = fig.add_subplot(3, 1, 2)
    ax2.plot(mu, num_houghHat, ls="--")
    ax2.plot(mu, ana_houghHat)
    ax2.set_ylabel(r"$\hat\Theta(\sigma)$")
    ax2.set_xlim([0, 1])
    ax3 = fig.add_subplot(3, 1, 3)
    ax3.plot(mu, num_houghTilde, ls="--")
    ax3.plot(mu, ana_houghTilde)
    ax3.set_ylabel(r"$\tilde\Theta(\sigma)$")
    ax3.set_xlabel(r"$\mu \equiv \cos(\theta)$")
    ax3.set_xlim([0, 1])

    ax1.tick_params(axis='y', which='both', left='on', right='on')
    ax2.tick_params(axis='y', which='both', left='on', right='on')
    ax3.tick_params(axis='y', which='both', left='on', right='on')
    ax1.legend()
    plt.show()
예제 #11
0
def main():
    # Need to consider if I want the inputs as m, l or m, k - using k for now
    if len(sys.argv) != 3:
        raise RuntimeError("require m and l")

    m = int(sys.argv[1])
    k = int(sys.argv[2])

    mode_admin = Property.Mode_admin(m, k)
    mode_admin.validate_values()
    is_even = mode_admin.check_is_even()
    l = mode_admin.get_l()
    wavemode = mode_admin.get_wavemode()

    # Currently have split qpos and qneg since I know lambda for q=0 but not q=-10 or 10
    qneg = np.linspace(0, -10, 9.5e2+4)
    qpos = np.linspace(0, 10, 9.5e2+4)

    print is_even, l, wavemode

#    roots.multi_rootfind(m, l, qpos, is_even)  # Testing if the new function works

    qlists = [qneg, qpos]
    kvals = [0, 1, 2]  # l=2,3,4

#    plotting.plot_burstdistro()
#    exit()

#    fullrange_multi_rootfind(m, qlists, kvals, aympcompare=True)  # Mostly for plotting functionality
#    fullrange_multi_rootfind(m, [qneg], [2], aympcompare=True)  # Testing just for k=-1, negative part

    """
    To plot the different wavemodes all together for different eccentricities
    """
#    for ecc in [.0, .25, .5]:
#        chi = 2 * (ecc**2)
#        rootfind_dimless_alt(m, 2, np.linspace(-10., 0., 85), ecc=ecc, chi=chi, inc=1.0025)
#        rootfind_dimless_alt(m, 1, np.linspace(-10., 0., 85), ecc=ecc, chi=chi, inc=1.0075)
#        rootfind_dimless_alt(m, 0, np.linspace(-10., 0., 85), ecc=ecc, chi=chi, inc=1.0075)
#        rootfind_dimless_alt(m, 2, np.linspace(10., 0., 85), ecc=ecc, chi=chi, inc=1.0075)
#        rootfind_dimless_alt(m, 1, np.linspace(10., 0., 85), ecc=ecc, chi=chi, inc=1.0075)
#        rootfind_dimless_alt(m, 0, np.linspace(10., 0., 85), ecc=ecc, chi=chi, inc=1.0015)
#        rootfind_dimless_alt(m, -1, np.linspace(-10., -3.25, 50), ecc=ecc, chi=chi, inc=1.0075)
#        rootfind_dimless_alt(m, -2, np.linspace(-50., -6.5, 150), ecc=ecc, chi=chi, inc=1.05)
#    plt.yscale('log')
#    plt.show()
#    exit()

#    eccstart = 0.
#    eccend = .6
#    steps = 18
#    stepsize = (eccend-eccstart)/(steps-1)
#    for ecc in [.0, .2, .3, .375, .415, .435, .45, .46, .5, .55]:  # np.linspace(eccstart, eccend, steps)
#        chi = 2. * (ecc**2)  # 2 * (ecc**2)
#        print "\n\n\t\tecc: {:.3f}, chi: {:.3f}\n\n".format(ecc, chi)
#        rootfind_dimless_alt(m, -2, np.linspace(-350., -3., 600), ecc=ecc, chi=chi, inc=1.05)
#    plt.yscale('log')
#    plt.title("m: {}; Eigenvalue evolution for different ecc, from {} to {} ({} inc/step)".format(m, eccstart, eccend, stepsize))
#    plt.show()
#    exit()

    """
    To plot the input wavemode for different eccentrities
    """
#    qlist = np.linspace(-12., -10., 85)
#    mode_admin.set_qlist(qlist)
#    wavemode = mode_admin.get_wavemode()
#    print mode_admin.mode, mode_admin.l, mode_admin.is_even

#    for ecc in [.0, .25, .5]:
#        chi = 2 * (ecc**2)
#        dlngrav = partial(grav.chi_gravity_deriv, chi)
#        mode_admin.set_curvilinear(ecc=ecc, chi=chi, dlngrav=dlngrav)
#        rootfind_dimless_new(mode_admin, inc=1.05, verbose=True)
#    plt.yscale('log')
#    plt.show()
#    exit()


    """
    To make contour plots - either generate the data (create_grid) and plot or load
    previously generated data (load_grid) and plot
    """
#    qmin, qmax, size = -10., -1.5, 100
#    ecc = 0.
#    chi = 2 * (ecc**2)
#    dlngrav = partial(grav.chi_gravity_deriv, chi)
#    filestring = "data/gridplot/qrange_{}_{}_steps_{}_kval_{}_ecc_{}_chi_{}.txt".format(qmin, qmax, size, k, ecc, chi)
#    titlestring = r"Evaluation in grid of $\lambda$ and q, for m: {}, k: {}, ecc: {}, $\chi$: {}".format(m, k, ecc, chi)
##    all_data = gridplot.create_grid(m, k, size, qmin, qmax, ecc, chi, dlngrav, saving=True)
#    all_data = gridplot.load_grid(filestring)
#    gridplot.plot_grid(all_data, title=titlestring, interpolation="spline36", logscale=True)
#    exit()
####


    """
    To generate or load a whole set of contour plots one after another
    """
#    m = -2
#    for k in [2, 1, 0]:
#        qmin, qmax, size = 1.5, 10., 100
#        ecc = 0.0
#        chi = 2 * (ecc**2)
#        dlngrav = partial(grav.chi_gravity_deriv, chi)
#        qlist = np.linspace(qmin, qmax, 200)
#    #    asymcompare = [qlist, curvasym.g_modes_list(m, 2, qlist, ecc=ecc, chi=chi)]

#        filestring = "data/gridplot/qrange_{}_{}_steps_{}_kval_{}_ecc_{}_chi_{}.txt".format(qmin, qmax, size, k, ecc, chi)
#        titlestr = r"Evaluation in grid of $\lambda$ and q, for m: {}, k: {}, ecc: {}, $\chi$: {}".format(m, k, ecc, chi)

##        all_data = gridplot.create_grid(m, k, size, qmin, qmax, ecc, chi, dlngrav, True)
#        all_data = gridplot.load_grid(filestring)
#        gridplot.plot_grid(all_data, title=titlestr, interpolation="spline36", logscale=True)  #, asymcompare=asymcompare
#    for k in [2, 1, 0]:
#        qmin, qmax, size = -10., -1.5, 100
#        ecc, chi = 0., 0.
#        dlngrav = partial(grav.chi_gravity_deriv, chi)
#        qlist = np.linspace(qmin, qmax, 200)

#        filestring = "data/gridplot/qrange_{}_{}_steps_{}_kval_{}_ecc_{}_chi_{}.txt".format(qmin, qmax, size, k, ecc, chi)
#        titlestr = r"Evaluation in grid of $\lambda$ and q, for m: {}, k: {}, ecc: {}, $\chi$: {}".format(m, k, ecc, chi)

##        all_data = gridplot.create_grid(m, k, size, qmin, qmax, ecc, chi, dlngrav, True)
#        all_data = gridplot.load_grid(filestring)
#        gridplot.plot_grid(all_data, title=titlestr, interpolation="spline36", logscale=True) 

#    k, qmin, qmax = -1, -10., -3.25
#    filestring = "data/gridplot/qrange_{}_{}_steps_{}_kval_{}_ecc_{}_chi_{}.txt".format(qmin, qmax, size, k, ecc, chi)
#    titlestr = r"Evaluation in grid of $\lambda$ and q, for m: {}, k: {}, ecc: {}, $\chi$: {}".format(m, k, ecc, chi)
##    all_data = gridplot.create_grid(m, k, size, qmin, qmax, ecc, chi, dlngrav, True)
#    all_data = gridplot.load_grid(filestring)
#    gridplot.plot_grid(all_data, title=titlestr, interpolation="spline36", logscale=True) 

#    k, qmin, qmax = -2, -10., -6.25
#    filestring = "data/gridplot/qrange_{}_{}_steps_{}_kval_{}_ecc_{}_chi_{}.txt".format(qmin, qmax, size, k, ecc, chi)
#    titlestr = r"Evaluation in grid of $\lambda$ and q, for m: {}, k: {}, ecc: {}, $\chi$: {}".format(m, k, ecc, chi)
##    all_data = gridplot.create_grid(m, k, size, qmin, qmax, ecc, chi, dlngrav, True)
#    all_data = gridplot.load_grid(filestring)
#    gridplot.plot_grid(all_data, title=titlestr, interpolation="spline36", logscale=True)

####


    """
    To generate contour plots in a range of q's and lambda's, rather than from the 
    asymptotically guessed lambda values - to search for weird things in specific
    lambda cases. Can either generate (lambda_grid) or load (load_grid) to plot
    """
    qmin, qmax, lammin, lammax, size = -400., -100., -1.2, .2, 500
    ecc = 0.5
    chi = 2. * (ecc**2)
    dlngrav = partial(grav.chi_gravity_deriv, chi)

    if is_even:
        evenstr="Even"
        force_func = False
    else:
        evenstr="Odd"
        force_func = True  # To force other normalization function, useful for some wavemodes
    filestring = "data/lamgrid/m_{}/qrange_{}_{}_lamrange_{}_{}_steps_{}_ecc_{}_chi_{}_{}.txt".format(m, qmin, qmax, lammin, lammax, size, ecc, chi, evenstr)

    titlestr = r"m: {}, Evaluation of grid of $\lambda$ and q, for {} modes, at ecc: {}, $\chi$: {}".format(m, evenstr, ecc, chi)
    lamdata = gridplot.lambda_grid(m, k, size, qmin, qmax, lammin, lammax, ecc, chi, dlngrav, saving=False, force_func=force_func)
#    lamdata = gridplot.load_grid(filestring)
    gridplot.plot_grid(lamdata, title=titlestr, interpolation="spline36", logscale=True)
    exit()


    compare_curvasym(m)
    compare_curvrmode(m)
    """
    To compare analytical values to numerical ones, for given eccentricity/chi
    Note: data has to already exist!
    """
#    ecc = 0.0
#    chi = 2 * (ecc**2)
#    plotting.curvi_plotting(ecc="ecc_{}".format(ecc), chi="chi_{}".format(chi))
#    plt.title(r"Numerics (dashed) and Analytics (solids) for ecc: {} and $\chi$: {}".format(ecc, chi))
#    curvasymplot_analytical(m, ecc=ecc, chi=chi)



    """
예제 #12
0
def main():
    # Need to consider if I want the inputs as m, l or m, k - using k for now
    if len(sys.argv) != 3:
        raise RuntimeError("require m and l")

    m = int(sys.argv[1])
    k = int(sys.argv[2])

    mode_admin = Property.Mode_admin(m, k)
    mode_admin.validate_values()  # Mode_admin now checks this upon init!
    is_even = mode_admin.check_is_even()
    l = mode_admin.get_l()
    wavemode = mode_admin.get_wavemode()

    # Currently have split qpos and qneg since I know lambda for q=0 but not q=-10 or 10
    qneg = np.linspace(0, -10, 9.5e2 + 4)
    qpos = np.linspace(0, 10, 9.5e2 + 4)

    print is_even, l, wavemode

    #    roots.multi_rootfind(m, l, qpos, is_even)  # Testing if the new function works

    qlists = [qneg, qpos]
    kvals = [0, 1, 2]  # l=2,3,4

    ecc = 0.0  # do in ecc=0, ecc=.25 and ecc=.5
    #    for ecc in [0., .25, .5]:
    chi = 2 * (ecc**2)
    saving = True
    verbose = False
    rootfind_dimless_alt(m,
                         2,
                         np.linspace(-10., 0., 170),
                         ecc=ecc,
                         chi=chi,
                         saving=saving,
                         verbose=verbose)
    rootfind_dimless_alt(m,
                         1,
                         np.linspace(-10., 0., 170),
                         ecc=ecc,
                         chi=chi,
                         saving=saving,
                         verbose=verbose)
    rootfind_dimless_alt(m,
                         0,
                         np.linspace(-10., 0., 170),
                         ecc=ecc,
                         chi=chi,
                         saving=saving,
                         verbose=verbose)
    rootfind_dimless_alt(m,
                         2,
                         np.linspace(10., 0., 170),
                         ecc=ecc,
                         chi=chi,
                         saving=saving,
                         verbose=verbose)
    rootfind_dimless_alt(m,
                         1,
                         np.linspace(10., 0., 170),
                         ecc=ecc,
                         chi=chi,
                         saving=saving,
                         verbose=verbose)
    rootfind_dimless_alt(m,
                         0,
                         np.linspace(10., 0., 170),
                         ecc=ecc,
                         chi=chi,
                         saving=saving,
                         verbose=verbose)
    rootfind_dimless_alt(m,
                         -1,
                         np.linspace(-10., -3.5, 100),
                         ecc=ecc,
                         chi=chi,
                         saving=saving,
                         verbose=verbose)
    rootfind_dimless_alt(m,
                         -2,
                         np.linspace(-10., -8.25, 50),
                         ecc=ecc,
                         chi=chi,
                         saving=saving,
                         inc=1.05,
                         verbose=verbose)
    plt.yscale('log')
    plt.show()