__all__ = [] import time import numpy as np import matplotlib.pyplot as pl from george import GaussianProcess import bart from bart.data import GPLightCurve # Generate fake data. gp = GaussianProcess([5e-4, 20.0, 25.0]) t = np.arange(100, 120, 0.5 / 24.0) yerr = 1e-4 * np.ones_like(t) y = gp.sample_prior(t)[0] + yerr * np.random.randn(len(yerr)) + 1 # 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.
import numpy as np import matplotlib.pyplot as pl from george import GaussianProcess from george.kernels import ExpSquaredKernel, CosineKernel np.random.seed(123) kernel = ExpSquaredKernel(1.0, 2.3) gp = GaussianProcess(kernel) # Generate some fake data. period = 0.956 x = 10 * np.sort(np.random.rand(75)) yerr = 0.1 + 0.1 * np.random.rand(len(x)) y = gp.sample_prior(x) y += 0.8 * np.cos(2 * np.pi * x / period) y += yerr * np.random.randn(len(yerr)) # Set up a periodic kernel. pk = ExpSquaredKernel(np.sqrt(0.8), 1000.0) * CosineKernel(period) kernel2 = kernel + pk gp2 = GaussianProcess(kernel2) # Condition on this data. gp2.compute(x, yerr) # Compute the log-likelihood. print("Log likelihood = {0}".format(gp2.lnlikelihood(y))) # Compute the conditional predictive distribution.