示例#1
0
    m = [m0, m1, m2, m3, mlp]
    print 'm = ', m
    print 'r0, r1 = ', r0, r1

    # load lightcurve
    strKIDs = []
    [strKIDs.append(str(KID).zfill(4)) for i in range(nstars)]
    data = np.genfromtxt("/Users/angusr/angusr/Suz_simulations/final/lightcurve_%s.txt" \
            %strKIDs[KID]).T
    x = data[0]
    y = data[1]
    yerr = y*2e-5 # one part per million #FIXME: this is made up!

    # normalise so range is 2 - no idea if this is the right thing to do...
    yerr = 2*yerr/(max(y)-min(y))
    y = 2*y/(max(y)-min(y))
    y = y-np.median(y)

    print 'subsample and truncate'
    x_sub, y_sub, yerr_sub = subs(x, y, yerr, mlp, 500.)
    pl.clf()
    pl.plot(x_sub, y_sub, 'k.')
    xs = np.linspace(min(x_sub), max(x_sub), 100)
    pl.plot(xs, predict(xs, x_sub, y_sub, yerr_sub, m, m[4])[0], 'r-')
    pl.savefig('test')

    # better initialisation
    m = [-5, m[1], 1.5, 9., np.log(m[-1])]

    MCMC(m, x_sub, y_sub, yerr_sub, np.log(r0), np.log(r1), "4")
示例#2
0
y = tbdata["PDCSAP_FLUX"]
yerr = tbdata["PDCSAP_FLUX_ERR"]
q = tbdata["SAP_QUALITY"]
# remove nans and bad flags
n = np.isfinite(x)*np.isfinite(y)*np.isfinite(yerr)*(q==0)
x = x[n]
y = y[n]
yerr = yerr[n]

# normalise so range is 2 - no idea if this is the right thing to do...
yerr = 2*yerr/(max(y)-min(y))
y = 2*y/(max(y)-min(y))
y = y-np.median(y)

# subsample and truncate
x_sub, y_sub, yerr_sub = subs(x, y, yerr, 1., 500, 100)

# A, l2, l1, s
P = np.log(.7)
theta = [-2., -2., -1.2, 1., P]

# plot data and prediction
pl.clf()
pl.errorbar(x_sub, y_sub, yerr=yerr_sub, fmt='k.', capsize=0)
xs = np.linspace(min(x_sub), max(x_sub), 100)
pl.plot(xs, predict(xs, x_sub, y_sub, yerr_sub, theta, P)[0], color='.7')
pl.savefig('single_binary_data')

# Compute initial likelihood
print 'initial lnlike = ', lnlike(theta, x, y, yerr)