Example #1
0
# Inject a transit.
t0_true = 110.0
planet = bart.Planet(r=0.02, period=400.0, t0=t0_true)
star = bart.Star(ldp=bart.ld.QuadraticLimbDarkening(0.3, 0.1))
ps = bart.PlanetarySystem(star)
ps.add_planet(planet)
model = ps.light_curve(t)
y *= model

# Plot the data.
pl.plot(t, y, ".k")
pl.savefig("data.png")

# Load the dataset using bart.
dataset = GPLightCurve(t, y, yerr, [1e-3, 10.0, 15.0])

# Do a grid search.
duration = 0.5
t0s = np.arange(t0_true - 10 * duration, t0_true + 10 * duration, 0.1 * duration)
lls = np.empty_like(t0s)
box_lls = np.empty_like(t0s)

strt = time.time()
null = dataset.lnlike(np.ones_like(dataset.eval_time))
print("Compute: ", time.time() - strt)

strt = time.time()
planet.r = 0.015
for i, t0 in enumerate(t0s):
    model = np.ones_like(dataset.eval_time)
Example #2
0
period, t0, dt, dts = koi.koi_period, koi.koi_time0bk, 1.3, 1.3
t0 = t0 % period
lcs = []
scs = []
hyperpars = [2.69e-4, 0.4868]  # Initial hyper parameters.
for lc in koi.get_light_curves(short_cadence=True):
    data = lc.read()
    m = data["SAP_QUALITY"] == 0

    if lc.sci_archive_class == "CLC":
        texp = kplr.EXPOSURE_TIMES[1]
    else:
        texp = kplr.EXPOSURE_TIMES[0]

    data = GPLightCurve(
        data["TIME"][m], data["SAP_FLUX"][m], data["SAP_FLUX_ERR"][m], hyperpars, texp=texp, jitter=1e-4
    )

    if lc.sci_archive_class == "CLC":
        lcs += data.active_window([period], [t0], [dt]).autosplit()
    else:
        scs += data.active_window([period], [t0], [dts]).autosplit(ttol=1.0)

print("Building initial model")

# Build the initial model.
mu1, mu2 = kplr.ld.get_quad_coeffs(6331.0, logg=4.195, feh=0.165)
if "-e" in sys.argv:
    star = bart.Star(mass=1.30, radius=1.45, mu1=mu1, mu2=mu2)
    planet = bart.Planet(r=6.2e-2 * star.radius, period=period, b=0.2, t0=t0, e=0.81, pomega=-0.67883)
    # e=0.81, pomega=1.75)
Example #3
0
# Load the datasets.
print("Downloading datasets")
client = kplr.API()
kic = client.koi("1574.01").star
kois = kic.kois
print([k.koi_time0bk for k in kois])

periods = [114.73635, 191.2318]
t0s = [165.1564, 286.0894 % periods[1]]
dts = [3.0, 4.0]
lcs = []
hyperpars = [1e-3, 2.0, 12.0]  # Initial hyper parameters.
for lc in kic.get_light_curves(short_cadence=False):
    data = lc.read()
    m = data["SAP_QUALITY"] == 0
    data = GPLightCurve(data["TIME"][m], data["SAP_FLUX"][m], data["SAP_FLUX_ERR"][m], hyperpars, K=5)
    lcs += data.active_window(periods, t0s, dts).autosplit()

print("Building initial model")
# Build the initial model.
mu1, mu2 = kplr.ld.get_quad_coeffs(5600.0, logg=3.96, feh=-0.17)
star = bart.Star(mass=1.1, radius=1.82, ldp=bart.ld.QuadraticLimbDarkening(mu1, mu2, 100))
planetary_system = bart.VariationalSystem(star)

times = np.sort(np.concatenate([lc.time for lc in lcs]))
for period, t0, r, b in zip(periods, t0s, [0.06855, 0.03123], [0.727, 0.579]):
    # Choose the kick times halfway between each transit.
    kicks = times[0] - t0 + 0.5 * period + period * np.arange(1, (times[-1] - times[0]) / period)

    planet = bart.Planet(r=r * star.radius, period=period, b=b, t0=t0 % period)
    planetary_system.add_planet(planet, kicks)