Example #1
0
def main(fns, eta, results_only=False, nsteps=50, nburn=50, fitrv=True):
    # Initial physical parameters from:
    #  http://kepler.nasa.gov/Mission/discoveries/kepler6b/
    #  http://arxiv.org/abs/1001.0333
    ldp = kepler.fiducial_ldp(teff=5647, logg=4.236, feh=0.34, bins=50)
    star = bart.Star(mass=.602, radius=.9, ldp=ldp, flux = 100.)
    planet = bart.Planet(a=162, r=11, mass=.0009551)
    system = bart.PlanetarySystem(star, iobs=86.8)
    system.add_planet(planet)
    tbin = .001
    t = np.arange(-200, 200, tbin)
    pl.clf()
    pl.plot(t, system.lightcurve(t))
    pl.savefig("lightcurve_bug_test_r<1")

    tbin = .001

    Teff = 5647.
    logg = 4.24
    feh = 0.34
    ldp = kepler.fiducial_ldp(teff=5647, logg=4.236, feh=0.34, bins=50)

    mass = .602
    radius =.01234
    #star = bart.Star(mass=.602, radius=.1006, ldp=ldp, flux = 100.)
    star = bart.Star(mass=.602, radius=1, ldp=ldp, flux = 100.)
    
    a = 10000*star.radius  # +0.11 -0.06 R_*
    Rp = star.radius*2
    mass = .0009551
    planet = bart.Planet(a=162, r=11, mass=.0009551)

    system = bart.PlanetarySystem(star, iobs=86.8)
    system.add_planet(planet)

    tbin = .001
    t = np.arange(-200, 200, tbin)
    times = system.get_photons(t)
    
    planet.parameters.append(LogParameter(r"$r$", "r"))
    '''
    planet.parameters.append(Parameter(r"$t_0$", "t0"))
    planet.parameters.append(LogParameter(r"$a$", "a"))
    kepler6.parameters.append(CosParameter(r"$i$", "iobs"))
    '''
    
    print(system.vector)
    if not results_only:
        system.run_mcmc(nsteps, thin=10, burnin=[], nwalkers=64) 
    
    results = system.results(thin=10, burnin=nburn)
    
    print(len(system.liketrace))
    print(np.max(system.liketrace))
    print(np.min(system.liketrace))
    pl.clf()
    pl.plot(range(len(system.liketrace)), system.liketrace)
    pl.savefig("likelihood_trace")
Example #2
0
def main(fns, eta, results_only=False, nsteps=2000, nburn=50, fitrv=True):
    # Initial physical parameters from:
    #  http://kepler.nasa.gov/Mission/discoveries/kepler6b/
    #  http://arxiv.org/abs/1001.0333

    rstar = 1.391  # +0.017 -0.034 R_sun
    Teff = 5647.
    logg = 4.24
    feh = 0.34

    P = 3.234723  # ± 0.000017 days
    a = 7.05  # +0.11 -0.06 R_*
    r = 0.09829  # +0.00014 -0.00050 R_*
    i = 86.8  # ± 0.3 degrees
    mass = 0.669 * 9.5492e-4  # Solar masses.

    # The reference "transit" time.
    t0 = 1.795  # 0.28  # Found by eye.

    # Set up the planet.
    planet = bart.Planet(r=r * rstar, a=a * rstar, t0=t0, mass=mass)

    # Set up the star.
    ldp = kepler.fiducial_ldp(Teff, logg, feh, bins=15, alpha=0.5)
    star = bart.Star(mass=planet.get_mstar(P), radius=rstar, ldp=ldp)

    # Set up the system.
    #system = bart.PlanetarySystem(star, iobs=i, rv0=-15.0,
    #                              basepath="kepler6-{0}".format(eta))
    system = bart.PlanetarySystem(star, iobs=i)
    system.add_planet(planet)

    # Fit parameters.
    planet.parameters.append(Parameter(r"$r$", "r"))
    planet.parameters.append(LogParameter(r"$a$", "a"))
    planet.parameters.append(Parameter(r"$t_0$", "t0"))
    system.parameters.append(CosParameter(r"$i$", "iobs"))
    
    # Read in the data.
    for fn in fns:
        system.add_dataset(KeplerDataset(fn))
        print(system.datasets[-1].time)

    # Add the RV data.
    rv = np.loadtxt("k6-rv.txt")
    ds = RVDataset(rv[:, 0], rv[:, 2], rv[:, 3], jitter=5.0)
    print(ds.time)
    if fitrv:
        ds.parameters.append(LogParameter(r"$\delta_v$", "jitter"))
        system.add_dataset(ds)
    
    print(planet.get_period(star.mass))

    # Plot initial conditions.
    pl.plot(system.datasets[0].time % P, system.datasets[0].flux, ".k",
            alpha=0.1)
    ts = np.linspace(0, P, 5000)
    pl.plot(ts, system.lightcurve(ts))
    pl.savefig("initial_lc.png")
    pl.clf()
    pl.errorbar(ds.time % P, ds.rv,
                yerr=np.sqrt(ds.rverr ** 2 + ds.jitter ** 2), fmt=".k")
    pl.plot(ts, system.radial_velocity(ts))
    pl.savefig("initial_rv.png")
    
    t = np.linspace(-0.2, 0.2, 5000)
    pl.clf()
    pl.plot(t, system.lightcurve(t))
    pl.savefig("lightcurve.png")

    print(system.vector)
    if not results_only:
        system.fit(nsteps, thin=10, burnin=[], nwalkers=64) 
    
    results = system.results(thin=10, burnin=nburn)
Example #3
0
np.random.seed(100)

'''
import matplotlib.mlab as mlab
delta = .025
x = np.arange(-3.0, 3.0, delta)
y = np.arange(-2.0, 2.0, delta)
X, Y = np.meshgrid(x, y)
Z1 = mlab.bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0)
print(X)
print(Y)
print(Z1)
'''


ldp = kepler.fiducial_ldp(teff=5647, logg=4.236, feh=0.34, bins=50)
star = bart.Star(mass=.602, radius=1, ldp=ldp, flux = 100.)
planet = bart.Planet(a=130, r=21, mass=.0009551)
system = bart.PlanetarySystem(star, iobs=86.8)
system.add_planet(planet)

tbin = .001
t = np.arange(-100, 100, tbin)
system.get_photons(t)

#set the parameter to check over
brightness_test = (np.arange(0, 10)+.5) *20
angle_test = np.arange(0, 7, .7) +.5
X, Y = np.meshgrid(brightness_test, angle_test)

Z = np.empty_like(X)