Esempio n. 1
0
# -*- coding: utf-8 -*-

from __future__ import division, print_function

import os
import sys
sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)),
                "..", ".."))

import bart
from bart import _george
from bart.injection import kepler_injection
import numpy as np
import matplotlib.pyplot as pl

datasets, ps = kepler_injection(2301306, 400.0, 0.0)
pars, data = bart.utils.estimate_gp_hyperpars(datasets)
print(pars)

# Plot predictions.
nx = 5
ny = int(np.ceil(len(data) / nx))
print(nx, ny, len(data))
fig = pl.figure(figsize=(nx * 2, ny * 2))

for i, ds in enumerate(data):
    ax = fig.add_subplot(nx, ny, i + 1)
    t = np.linspace(ds[0].min(), ds[0].max(), 100)
    mu, cov = _george.predict(ds[0], ds[1], ds[2], pars[0], pars[1], t)
    model = np.random.multivariate_normal(mu, cov, size=100)
    ax.plot(ds[0], ds[1], ".k", ms=2)
Esempio n. 2
0
import time
import numpy as np
import matplotlib.pyplot as pl
from george import GaussianProcess

from bart.injection import kepler_injection

# Choose a Kepler target.
# kicid = 10979438
kicid = 3641858

# Inject a transit with known parameters.
truth = 300.0, 0.01, 20.0
# truth = 278.1045694, 0.01, 20.0
datasets, ps = kepler_injection(kicid, truth[0], truth[1], b=0.0, t0=truth[2])

# Discard any datasets that are too small.
datasets = [ds for ds in datasets if len(ds.time) > 10]
print(len(datasets))

[pl.plot(ds.time % truth[0], ds.flux + i * 1e-4, ".k")
 for i, ds in enumerate(datasets)]
pl.xlim(10., 30.)
pl.savefig("data.png")

# Concatenate the time array.
dsmask, times = zip(*np.concatenate([np.array((i+np.zeros(len(ds.time)),
                                               ds.time)).T
                                     for i, ds in enumerate(datasets)]))
dsmask = np.array(dsmask, dtype=int)
Esempio n. 3
0
                os.path.abspath(__file__)))))

import bart
from bart.utils import estimate_gp_hyperpars
from bart.ld import LimbDarkening
from bart.injection import kepler_injection


period, size, t0 = 278.1045694, 0.01, 20.0
# kicid = 10398739
# kicid = 7673496
kicid = 10979438
# kicid = 10592770
# kicid = 3641858
# kicid = 9468112
datasets, ps = kepler_injection(kicid, period, size, t0=t0)

# pars, data = estimate_gp_hyperpars(datasets)
# print(pars, datasets[0].hyperpars)

dt = 3

ps.star.ldp = LimbDarkening(1.0, 1.0)
null_ps = bart.PlanetarySystem(bart.Star())

# phases = np.linspace(t0 - 1, t0 + 1, 101)
phases = np.sort(np.concatenate([np.linspace(0, period, 501), [t0]]))
dlp = np.zeros_like(phases)
count = np.zeros_like(phases)
for i, phase in enumerate(phases):
    ps.planets[0].t0 = phase
Esempio n. 4
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from __future__ import (division, print_function, absolute_import,
                        unicode_literals)

from bart.injection import kepler_injection
from bart._turnstile import period_search
import numpy as np
import matplotlib.pyplot as pl

period, size = 278.1045694, 0.05
datasets, ps = kepler_injection(2301306, period, size, t0=20.0)

[pl.plot(d.time, d.flux, ".k") for d in datasets]
pl.savefig("data.png")

periods, epochs, depths, dvar = period_search(datasets,
                                              period - 0.01, period + 0.01, 5,
                                              100.0, 4.0)

mu = [np.mean(d) for d in depths]
print(mu)
pl.clf()
[pl.errorbar(p * np.ones_like(d), d, yerr=np.sqrt(e), fmt=".k")
 for p, d, e in zip(periods, depths, dvar)]
pl.plot(periods, mu, ".r")
pl.gca().axhline(size * size)
pl.gca().axvline(period)
pl.savefig("periods.png")
Esempio n. 5
0
import sys
sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)),
                "..", ".."))
from itertools import product
import bart
from bart import _george
from bart.data import GPLightCurve
from bart.injection import kepler_injection
import numpy as np
import matplotlib.pyplot as pl

# Inject a transit.
t0 = 25.0
period = 330.0
size = 0.01
data0, ps = kepler_injection(9468112, period, size, t0=t0)
# data0, ps = kepler_injection(2301306, period, size, t0=t0)

dt = 3.0
datasets = []
for ds in data0:
    t = np.abs((ds.time - t0 + 0.5 * period) % period - 0.5 * period)
    m = t < dt
    if np.any(m):
        datasets.append(GPLightCurve(ds.time[m], ds.flux[m], ds.ferr[m],
                                     alpha=1e-3, l2=1e5))

model = bart.Model(ps, datasets=datasets)
model.planetary_system.planets[0].r = 0.01
pl.clf()
offset = 1e-4