예제 #1
0
def lnlike(theta, x, y, yerr):
    P1, tau1, k1, w1, e1, P2, tau2, k2, w2, e2, P3, tau3, k3, w3, e3, offset = theta
    fit_curve   = Model(P1=P1, tau1=tau1, k1=k1, w1=w1, e1=e1, 
                        P2=P2, tau2=tau2, k2=k2, w2=w2, e2=e2, 
                        P3=P3, tau3=tau3, k3=k3, w3=w3, e3=e3, offset=offset)
    y_fit       = fit_curve.get_value(x)
    return -0.5*(np.sum( ((y-y_fit)/yerr)**2))
예제 #2
0
def lnlike(theta, x, y, yerr):
    P, tau, k, w, e0, offset1, offset2 = theta
    fit_curve = Model(P=P,
                      tau=tau,
                      k=k,
                      w=w,
                      e0=e0,
                      offset1=offset1,
                      offset2=offset2)
    y_fit = fit_curve.get_value(np.array(x))
    return -0.5 * (np.sum(((y - y_fit) / yerr)**2.))
예제 #3
0
def lnlike(theta, x, y, yerr):
    P1, tau1, k1, w1, e1, offset1, alpha = theta
    fit_curve = Model(P1=P1,
                      tau1=tau1,
                      k1=k1,
                      w1=w1,
                      e1=e1,
                      offset1=offset1,
                      alpha=alpha)
    y_fit = fit_curve.get_value(x)
    return -0.5 * (np.sum(((y - y_fit) / yerr)**2))
예제 #4
0
def lnlike(theta, x, y, yerr):
    P, tau, k, w, e0, off_aat, off_chiron, off_feros, off_mj1, off_mj3 = theta
    fit_curve = Model(P=P,
                      tau=tau,
                      k=k,
                      w=w,
                      e0=e0,
                      off_aat=off_aat,
                      off_chiron=off_chiron,
                      off_feros=off_feros,
                      off_mj1=off_mj1,
                      off_mj3=off_mj3)
    y_fit = fit_curve.get_value(np.array(x))
    return -0.5 * (np.sum(((y - y_fit) / yerr)**2.))
예제 #5
0
def lnlike(theta, x, y, yerr):
    P1, tau1, k1, w1, e1, P2, tau2, k2, w2, e2, offset, alpha = theta
    model = Model(P1=P1,
                  tau1=tau1,
                  k1=k1,
                  w1=w1,
                  e1=e1,
                  P2=P2,
                  tau2=tau2,
                  k2=k2,
                  w2=w2,
                  e2=e2,
                  offset=offset,
                  alpha=alpha)
    return -0.5 * (np.sum(((y - model.get_value(np.array(x))) / yerr)**2.))
예제 #6
0
def lnlike(theta, x, y, yerr):
    P1, tau1, k1, w1, e1, P2, tau2, k2, w2, e2, offset, alpha = theta
    fit_curve = Model(P1=P1,
                      tau1=tau1,
                      k1=k1,
                      w1=w1,
                      e1=e1,
                      P2=P2,
                      tau2=tau2,
                      k2=k2,
                      w2=w2,
                      e2=e2,
                      offset=offset,
                      alpha=alpha)
    y_fit = fit_curve.get_value(x)
    return -0.5 * (np.sum(((y - y_fit) / yerr)**2))
예제 #7
0
a0, a1, a2, a3, a4, a5, a6 = map(
    lambda v: (v[1], v[2] - v[1], v[1] - v[0]),
    zip(*np.percentile(real_samples, [16, 50, 84], axis=0)))
aa = np.zeros((len(guess), 3))
aa[0, :] = [a0[i] for i in range(3)]
aa[1, :] = [a1[i] for i in range(3)]
aa[2, :] = [a2[i] for i in range(3)]
aa[3, :] = [a3[i] for i in range(3)]
aa[4, :] = [a4[i] for i in range(3)]
aa[5, :] = [a5[i] for i in range(3)]
aa[6, :] = [a6[i] for i in range(3)]
np.savetxt('../../output/HD103720/103720pj_MCMC_result.txt', aa, fmt='%.6f')

P, tau, k, w, e0, offset, m = aa[:, 0]
fit_curve = Model(P=P, tau=tau, k=k, w=w, e0=e0, offset=offset, m=m)
y_fit = fit_curve.get_value(np.array(x))

plt.figure()
plt.errorbar(x, y_fit, yerr=yerr, fmt=".", capsize=0, label='MCMC fit')
plt.errorbar(x, y, yerr=yerr, fmt=".", capsize=0, label='HARPS')
plt.ylabel("RV [m/s]")
plt.xlabel("MJD")
plt.legend(loc="upper center")
plt.savefig('../../output/HD103720/103720pj_MCMC_fit.png')
plt.show()

residual = np.array(y) - fit_curve.get_value(np.array(x))
chi2 = sum(residual**2 / np.array(yerr)**2) / (len(x) - len(guess))
rms = np.sqrt(np.mean(residual**2))
wrms = np.sqrt(sum((residual / yerr)**2) / sum(1 / yerr**2))
예제 #8
0
    # fig, axes = plt.subplots(figsize=(16, 5))
    plt.rcParams.update({'font.size': 24})
    fig = plt.figure(figsize=(15, 7))
    plt.subplots_adjust(left=left,
                        bottom=bottom,
                        right=right,
                        top=top,
                        wspace=wspace,
                        hspace=hspace)

    fig.suptitle(r'$\epsilon$ Eridani time series', y=0.95)
    axes_1 = plt.subplot(211)
    axes_1.axhline(color="gray", ls='--')
    fit_curve = Model(P=P, tau=tau, k=k, w0=w0, e0=e0, offset=offset)
    plot_x = np.linspace(min(MJD), max(MJD), num=10000)
    plot_y = fit_curve.get_value(plot_x)
    wrms1 = np.sqrt(
        sum(((x - np.mean(x)) / RV_noise)**2) / sum(1 / RV_noise**2))
    rms1 = np.var(x)**0.5
    plt.errorbar(MJD,
                 x + 7,
                 yerr=RV_noise,
                 fmt="k.",
                 capsize=0,
                 alpha=alpha,
                 label=r'$RV_{HARPS}$')
    plt.plot(plot_x, plot_y, 'g-', linewidth=2.0, label='Model')
    plt.ylim(-21, 21)
    plt.ylabel('RV [m/s]')
    plt.legend(loc=2, prop={'size': fontsize})
    axes_1.set_xticklabels([])
예제 #9
0
fit_curve = Model(P=np.log(P),
                  tau=np.log(tau),
                  k=np.log(k),
                  w=w,
                  e0=e0,
                  off_aat=off_aat / 100,
                  off_chiron=off_chiron / 100,
                  off_feros=off_feros / 100,
                  off_mj1=off_mj1 / 100,
                  off_mj3=off_mj3 / 100,
                  off_fideos=off_fideos / 100)
t_fit = np.linspace(min(RV_ALL[:, 0]) - 300,
                    max(RV_ALL[:, 0] + 300),
                    num=10001,
                    endpoint=True)
y_fit = fit_curve.get_value(np.array(t_fit))

residual = fit_curve.get_value(np.array(x)) - np.array(y)
chi2 = sum(residual**2 / np.array(yerr)**2)
rms = np.sqrt(np.mean(residual**2))
yerr = np.array(yerr)
wrms = np.sqrt(sum((residual / yerr)**2) / sum(1 / yerr**2))
np.savetxt('residual_6set.txt', residual)

plt.figure()
ax = plt.subplot(111)
ax.axhline(y=0, color='k', ls='--', alpha=.5)
plt.plot(t_fit, y_fit, alpha=.5)
plt.errorbar(RV_AAT[:, 0],
             RV_AAT[:, 1] - off_aat,
             yerr=RV_AAT[:, 2],
예제 #10
0
aa[2, :] = [a2[i] for i in range(3)]
aa[3, :] = [a3[i] for i in range(3)]
aa[4, :] = [a4[i] for i in range(3)]
aa[5, :] = [a5[i] for i in range(3)]
aa[6, :] = [a6[i] for i in range(3)]
np.savetxt('../../output/HD36051/36051_MCMC_result.txt', aa, fmt='%.6f')

P, tau, k, w, e0, offset1, offset2 = aa[:, 0]
fit_curve = Model(P=P / 100,
                  tau=tau,
                  k=k,
                  w=w,
                  e0=e0,
                  offset1=offset1,
                  offset2=offset2)
y_fit = fit_curve.get_value(np.array(x))

plt.figure()
plt.errorbar(x, y_fit, yerr=yerr, fmt=".", capsize=0, label='MCMC fit')
plt.errorbar(x, y, yerr=yerr, fmt=".", capsize=0, label='HARPS')
plt.ylabel("RV [m/s]")
plt.xlabel("MJD")
plt.legend(loc="upper center")
plt.savefig('../../output/HD36051/36051_MCMC_fit.png')
plt.show()

companion = fit_curve.get_value(np.array(x))
residual = np.array(y) - companion
chi2 = sum(residual**2 / np.array(yerr)**2) / (len(x) - len(guess))
rms = np.sqrt(np.mean(residual**2))
wrms = np.sqrt(sum((residual / yerr)**2) / sum(1 / yerr**2))
예제 #11
0
np.savetxt('HD85390_fit.txt', aa, fmt='%.6f')

P1, tau1, k1, w1, e1, P2, tau2, k2, w2, e2, offset, alpha = aa[:, 0]
fit_curve = Model(P1=np.log(P1) / 10,
                  tau1=tau1 / 100,
                  k1=k1 / 100,
                  w1=w1,
                  e1=e1,
                  P2=np.log(P2) / 10,
                  tau2=tau2 / 100,
                  k2=k2 / 100,
                  w2=w2,
                  e2=e2,
                  offset=offset,
                  alpha=alpha)
y_fit = fit_curve.get_value(x)

fit_curve2 = Model2(P1=np.log(P1) / 10,
                    tau1=tau1 / 100,
                    k1=k1 / 100,
                    w1=w1,
                    e1=e1,
                    P2=np.log(P2) / 10,
                    tau2=tau2 / 100,
                    k2=k2 / 100,
                    w2=w2,
                    e2=e2,
                    offset=offset)
t_fit = np.linspace(min(x), max(x), num=10001, endpoint=True)
y_fit2 = fit_curve2.get_value(t_fit)
예제 #12
0
def lnlike(theta, x, y, yerr):
    P, tau, k, w, e0, offset, alpha = theta
    model = Model(P=P, tau=tau, k=k, w=w, e0=e0, offset=offset, alpha=alpha)
    return -0.5*(np.sum( ((y-model.get_value(np.array(x)))/yerr)**2. ))
예제 #13
0
aa[8,:] = [a8[i] for i in range(3)]
aa[9,:] = [a9[i] for i in range(3)]
aa[10,:]= [a10[i] for i in range(3)]
aa[11,:]= [a11[i] for i in range(3)]
np.savetxt('HD85390_fit.txt', aa, fmt='%.6f')


P1, tau1, k1, w1, e1, P2, tau2, k2, w2, e2, offset1, offset2 = aa[:,0]
fig = plt.figure(figsize=(10, 7))
frame1 = fig.add_axes((.15,.3,.8,.6))
frame1.axhline(y=0, color='k', ls='--', alpha=.3)
t_sample    = np.linspace(min(x), max(x), num=10001, endpoint=True)
# Planet 1 #
Planet1     = Model(P1=P1/100, tau1=tau1/1000, k1=k1/100, w1=w1, e1=e1, 
                    P2=P2/100, tau2=tau2/1000, k2=0, w2=w2, e2=e2, offset1=offset1, offset2=0)
y1          = Planet1.get_value(t_sample)
plt.plot(t_sample, y1, 'b-.', alpha=.3, label='Planet1')
# Planet 2 #
Planet2     = Model(P1=P1/100, tau1=tau1/1000, k1=0, w1=w1, e1=e1, 
                    P2=P2/100, tau2=tau2/1000, k2=k2/100, w2=w2, e2=e2, offset1=0, offset2=offset2)
y2          = Planet2.get_value(t_sample)
plt.plot(t_sample, y2, 'b--', alpha=.3, label='Planet2')
# Planet1 + Planet2 #
y12         = y1 + y2
plt.plot(t_sample, y12, 'b-', alpha=.5, label='Planet1+Planet2')
plt.errorbar(x, y, yerr=yerr, fmt=".k", capsize=0, label='HARPS RV')
plt.legend()
plt.ylabel("Radial velocity [m/s]")

fit_curve   = Model(P1=P1/100, tau1=tau1/1000, k1=k1/100, w1=w1, e1=e1, 
                    P2=P2/100, tau2=tau2/1000, k2=k2/100, w2=w2, e2=e2, offset1=offset1, offset2=offset2)
예제 #14
0
P, tau, k, w, e0, off_aat, off_chiron, off_feros, off_mj1, off_mj3 = aa[:, 0]
fit_curve = Model(P=np.log(P),
                  tau=np.log(tau),
                  k=np.log(k),
                  w=w,
                  e0=e0,
                  off_aat=off_aat / 100,
                  off_chiron=off_chiron / 100,
                  off_feros=off_feros / 100,
                  off_mj1=off_mj1 / 100,
                  off_mj3=off_mj3 / 100)
t_fit = np.linspace(min(RV_ALL[:, 0]) - 20,
                    max(RV_ALL[:, 0] + 20),
                    num=10001,
                    endpoint=True)
y_fit = fit_curve.get_value(np.array(t_fit))

# I need to add the offset into the data before plotting
RV_AAT[:, 1] -= off_aat
RV_CHIRON[:, 1] -= off_chiron
RV_FEROS[:, 1] -= off_feros
RV_MJ1[:, 1] -= off_mj1
RV_MJ3[:, 1] -= off_mj3

plt.figure()
plt.plot(t_fit, y_fit, label='MCMC fit')
plt.errorbar(RV_AAT[:, 0],
             RV_AAT[:, 1],
             yerr=RV_AAT[:, 2],
             fmt=".",
             capsize=0,
예제 #15
0
                  k1=k1 / 100,
                  w1=w1,
                  e1=e1,
                  P2=P2 / 100,
                  tau2=tau2 / 100,
                  k2=k2 / 100,
                  w2=w2,
                  e2=e2,
                  P3=P3 / 100,
                  tau3=tau3 / 100,
                  k3=k3 / 100,
                  w3=w3,
                  e3=e3,
                  offset=offset)
t_fit = np.linspace(min(x), max(x), num=10001, endpoint=True)
y_fit = fit_curve.get_value(np.array(t_fit))

residual = fit_curve.get_value(x) - y
chi2 = sum(residual**2 / yerr**2)
rms = np.sqrt(np.mean(residual**2))
wrms = np.sqrt(sum((residual / yerr)**2) / sum(1 / yerr**2))

fig = plt.figure(figsize=(10, 7))
frame1 = fig.add_axes((.15, .3, .8, .6))
frame1.axhline(y=0, color='k', ls='--', alpha=.3)
plt.plot(t_fit, y_fit, alpha=.5)
plt.errorbar(x, y, yerr=yerr, fmt=".k", capsize=0)
plt.ylabel("Radial velocity [m/s]")

frame2 = fig.add_axes((.15, .1, .8, .2))
frame2.axhline(y=0, color='k', ls='--', alpha=.3)
예제 #16
0
aa[2,:] = [a2[i] for i in range(3)]
aa[3,:] = [a3[i] for i in range(3)]
aa[4,:] = [a4[i] for i in range(3)]
aa[5,:] = [a5[i] for i in range(3)]
aa[6,:] = [a6[i] for i in range(3)]
aa[7,:] = [a7[i] for i in range(3)]
aa[8,:] = [a8[i] for i in range(3)]
aa[9,:] = [a9[i] for i in range(3)]
aa[10,:]= [a10[i] for i in range(3)]
np.savetxt('HD85390_fit.txt', aa, fmt='%.6f')


P1, tau1, k1, w1, e1, P2, tau2, k2, w2, e2, offset = aa[:,0]
fit_curve   = Model(P1=P1/100, tau1=tau1/100, k1=k1/100, w1=w1, e1=e1, 
                    P2=P2/100, tau2=tau2/100, k2=k2/100, w2=w2, e2=e2, offset=offset)
y_fit       = fit_curve.get_value(x)

residual    = y_fit - y
chi2        = sum(residual**2 / yerr**2)
rms         = np.sqrt(np.mean(residual**2))

t_sample    = np.linspace(min(x), max(x), num=10001, endpoint=True)
y_sample    = fit_curve.get_value(np.array(t_sample))
fig = plt.figure(figsize=(10, 7))
frame1 = fig.add_axes((.15,.3,.8,.6))
frame1.axhline(y=0, color='k', ls='--', alpha=.3)
plt.plot(t_sample, y_sample, 'b-', alpha=.5, label='two planets + smoothed jitter')
plt.errorbar(x, y, yerr=yerr, fmt=".k", capsize=0, label='HARPS RV')
plt.legend()
plt.ylabel("Radial velocity [m/s]")
예제 #17
0
frame1 = fig.add_axes((.15, .3, .8, .6))
frame1.axhline(y=0, color='k', ls='--', alpha=.3)
t_sample = np.linspace(min(x), max(x), num=10001, endpoint=True)
# Planet 1 #
Planet1 = Model(P1=P1 / 100,
                tau1=tau1 / 100,
                k1=k1 / 100,
                w1=w1,
                e1=e1,
                P2=P2 / 100,
                tau2=tau2 / 100,
                k2=0,
                w2=w2,
                e2=e2,
                offset=0)
y1 = Planet1.get_value(t_sample)
plt.plot(t_sample, y1, 'b-.', alpha=.3, label='Planet1')
# Planet 2 #
Planet2 = Model(P1=P1 / 100,
                tau1=tau1 / 100,
                k1=0,
                w1=w1,
                e1=e1,
                P2=P2 / 100,
                tau2=tau2 / 100,
                k2=k2 / 100,
                w2=w2,
                e2=e2,
                offset=offset)
y2 = Planet2.get_value(t_sample)
plt.plot(t_sample, y2, 'b--', alpha=.3, label='Planet2')
예제 #18
0
aa[4, :] = [a4[i] for i in range(3)]
aa[5, :] = [a5[i] for i in range(3)]
aa[6, :] = [a6[i] for i in range(3)]
np.savetxt('../../output/' + star + '/' + star + '_MCMC_result.txt',
           aa,
           fmt='%.6f')

P, tau, k, w, e0, offset1, offset2 = aa[:, 0]
fit_curve = Model(P=P,
                  tau=tau,
                  k=k,
                  w=w,
                  e0=e0,
                  offset1=offset1,
                  offset2=offset2)
y_fit = fit_curve.get_value(np.array(x))

plt.figure()
plt.errorbar(x, y, yerr=yerr, fmt=".", capsize=0, label='HARPS')
plt.errorbar(x, y_fit, yerr=yerr, fmt=".", capsize=0, label='MCMC fit')
plt.ylabel("RV [m/s]")
plt.xlabel("MJD")
plt.legend(loc="upper center")
plt.savefig('../../output/' + star + '/' + star + '_MCMC_fit.png')
plt.show()

companion = fit_curve.get_value(np.array(x))
residual = np.array(y) - companion
chi2 = sum(residual**2 / np.array(yerr)**2) / (len(x) - len(guess))
rms = np.sqrt(np.mean(residual**2))
wrms = np.sqrt(sum((residual / yerr)**2) / sum(1 / yerr**2))
예제 #19
0
P1, tau1, k1, w1, e1, P2, tau2, k2, w2, e2, offset, alpha = aa[:, 0]
fit_curve = Model(P1=np.log(P1) / 10,
                  tau1=np.log(tau1),
                  k1=np.log(k1),
                  w1=w1,
                  e1=e1,
                  P2=np.log(P2) / 10,
                  tau2=np.log(tau2),
                  k2=np.log(k2),
                  w2=w2,
                  e2=e2,
                  offset=offset,
                  alpha=0)
t_fit = np.linspace(min(x), max(x), num=10001, endpoint=True)
y_fit = fit_curve.get_value(np.array(x))

residual = y_fit - y
chi2 = sum(residual**2 / yerr**2)
rms = np.sqrt(np.mean(residual**2))

fig = plt.figure(figsize=(10, 7))
frame1 = fig.add_axes((.15, .3, .8, .6))
frame1.axhline(y=0, color='k', ls='--', alpha=.3)
plt.plot(x, y_fit, 'bo', alpha=.5)
plt.errorbar(x, y, yerr=yerr, fmt=".k", capsize=0)
plt.ylabel("Radial velocity [m/s]")

frame2 = fig.add_axes((.15, .1, .8, .2))
frame2.axhline(y=0, color='k', ls='--', alpha=.3)
plt.errorbar(x, residual, yerr=yerr, fmt=".k", capsize=0)
예제 #20
0
                     offset2=offset2)
    y1 = Planet1.get_value(t_sample)
    plt.plot(t_sample, y1, 'b-.', alpha=.3, label='Planet1')
    plt.errorbar(t, xx, yerr=yerr, fmt=".k", capsize=0, label='HARPS RV')
    plt.legend()
    plt.ylabel("Radial velocity [m/s]")
    # Jitter#
    Jitter = Model(P1=np.log(P1) / 10,
                   tau1=tau1 / 1000,
                   k1=0,
                   w1=w1,
                   e1=e1,
                   offset1=0,
                   offset2=0,
                   alpha=np.log(alpha))
    y_jitter = Jitter.get_value(t)
    plt.plot(t, y_jitter, 'ro', alpha=.5, label='smoothed jitter')

    Fit = Model(P1=np.log(P1) / 10,
                tau1=tau1 / 1000,
                k1=k1 / 100,
                w1=w1,
                e1=e1,
                offset1=offset1,
                offset2=offset1,
                alpha=np.log(alpha))
    y_fit = Fit.get_value(t)
    plt.plot(t, y_fit, 'bo', alpha=.5, label='Planet 1 + smoothed jitter')
    # plt.plot(x[x<57300], alpha*jitter_smooth, 'ro', alpha=.5, label='smoothed jitter')
    plt.legend()
    plt.ylabel("Radial velocity [m/s]")
예제 #21
0
if 0:  # I need to add the offset into the data before plotting
    P1, tau1, k1, w1, e1, P2, tau2, k2, w2, e2, m, offset = aa[:, 0]
    fit_curve = Model(P1=np.log(P1),
                      tau1=np.log(tau1),
                      k1=np.log(k1),
                      w1=w1,
                      e1=e1,
                      P2=np.log(P2),
                      tau2=np.log(tau2),
                      k2=np.log(k2),
                      w2=w2,
                      e2=e2,
                      m=m,
                      offset=offset)
    y_fit = fit_curve.get_value(x)
    plt.figure()
    plt.plot(x, y_fit, 'o', label='MCMC fit')
    plt.errorbar(BJD,
                 RV_HARPS,
                 yerr=RV_HARPS_err,
                 fmt=".",
                 capsize=0,
                 label='HARPS')
    plt.title("RV time series")
    plt.ylabel("RV [m/s]")
    plt.xlabel("Shifted JD [d]")
    plt.legend()
    plt.savefig('CoRot-7_MCMC-3-fit.png')
    # plt.show()