def sigK_LHS1140(N=1e3, P=24.73712, T0=2456915.6997): '''From Dittmann et al 2017''' # get time-series #bjd, rv, erv = np.loadtxt('Nrv_tests/LHS1140old.dat').T bjd, rv, erv = np.loadtxt('Nrv_tests/LHS1140.dat').T Pc, T0c, Kc = 3.777931, 2458226.343169 + .5, 2.35 kepc = get_rv1((Pc, T0c, 0, Kc, 0, 0), bjd) rv -= kepc # sample parameter posteriors approximating the PDFs as Gaussian N = int(N) Krvs = _random_normal_draws(4.85, .55, N, positive=True) As = _random_normal_draws(2.7, .81, N, positive=True) # 9,5 ls = _random_normal_draws(49.8, 38, N, positive=True) Gs = _random_normal_draws(1.44, .2, N, positive=True) Ps = _random_normal_draws(132.9, 10, N, positive=True) # median of posterior ss = _random_normal_draws(2.7, .3, N, positive=True) # 3,1 # Monte-Carlo computation of sigKs sigKs = np.zeros(N) for i in range(N): print float(i) / N theta = P, T0, Krvs[i], As[i], ls[i], Gs[i], Ps[i], ss[i] sigKs[i] = compute_sigmaK_GP(theta, bjd, rv, erv) print sigKs[i] # save output _save_draws('LHS1140', Krvs, As, ls, Gs, Ps, ss, sigKs)
def sigK_Kep78(N=1e3, P=.35500744, T0=2454953.95995): '''From Grunblatt et al 2015''' # get time-series bjd, rv, erv = np.loadtxt('Nrv_tests/Kepler78_HARPSN.dat').T # sample parameter posteriors approximating the PDFs as Gaussian N = int(N) Krvs = _random_normal_draws(1.86, .25, N, positive=True) As = _random_normal_draws(5.6, 1.7, N, positive=True) ls = _random_normal_draws(26.1 / np.sqrt(2), 15 / np.sqrt(2), N, positive=True) Gs = _random_normal_draws(1 / np.sqrt(2 * .28**2), 1 / np.sqrt(2 * .28**2) / 5.6, N, positive=True) Ps = _random_normal_draws(13.26, .12, N, positive=True) ss = _random_normal_draws(1.1, .5, N, positive=True) # Monte-Carlo computation of sigKs sigKs = np.zeros(N) for i in range(N): theta = P, T0, Krvs[i], As[i], ls[i], Gs[i], Ps[i], ss[i] sigKs[i] = compute_sigmaK_GP(theta, bjd, rv, erv) sigKs[i] *= np.sqrt( 109. / 193 ) # correct for lack of HIRES RVs to compare to measured sigK = 0.25 m/s # save output _save_draws('Kep78HARPSN', Krvs, As, ls, Gs, Ps, ss, sigKs)
def sigK_CoRoT7(N=1e3, P=.85359165, T0=2454398.0769): '''From Haywood et al 2015''' # get time-series bjd, rv, erv = np.loadtxt('Nrv_tests/CoRoT7.dat').T kepc = get_rv1((3.7, 2455953.54, 0, 6.01, 0, 0), bjd) rv -= kepc # sample parameter posteriors approximating the PDFs as Gaussian N = int(N) Krvs = _random_normal_draws(3.42, .66, N, positive=True) As = _random_normal_draws(7, 2, N, positive=True) ls = _random_normal_draws(20.6, 2.5, N, positive=True) Gs = _random_normal_draws(1, .1, N, positive=True) Ps = _random_normal_draws(23.81, .03, N, positive=True) rmsRVrot, rmsRVconv, rmsRVtot = .46, 1.82, 3.92 # FF' contributions ss = _random_normal_draws(np.sqrt(rmsRVtot**2 - rmsRVrot**2 - rmsRVconv**2), 0, N, positive=True) # Monte-Carlo computation of sigKs sigKs = np.zeros(N) for i in range(N): theta = P, T0, Krvs[i], As[i], ls[i], Gs[i], Ps[i], ss[i] sigKs[i] = compute_sigmaK_GP(theta, bjd, rv, erv) # save output _save_draws('CoRoT7', Krvs, As, ls, Gs, Ps, ss, sigKs)
def sigK_Kep21(N=1e3, P=2.78578, T0=2456798.7188): '''From Lopez-Morales et al 2016''' # get time-series bjd, rv, erv = np.loadtxt('Nrv_tests/Kepler21_HARPSN.dat').T # sample parameter posteriors approximating the PDFs as Gaussian N = int(N) Krvs = _random_normal_draws(2.12, .66, N, positive=True) As = _random_normal_draws(6.7, 1.4, N, positive=True) ls = _random_normal_draws(24.04 / np.sqrt(2), .09 / np.sqrt(2), N, positive=True) Gs = _random_normal_draws(1 / .42, .12 / .42, N, positive=True) Ps = _random_normal_draws(12.6, .02, N, positive=True) rmsinst, rmsgran = unp.uarray(.9, .1), unp.uarray(1.76, .04) s = unp.sqrt(rmsinst**2 + rmsgran**2) ss = _random_normal_draws(float(unp.nominal_values(s)), float(unp.std_devs(s)), N, positive=True) # Monte-Carlo computation of sigKs sigKs = np.zeros(N) for i in range(N): theta = P, T0, Krvs[i], As[i], ls[i], Gs[i], Ps[i], ss[i] sigKs[i] = compute_sigmaK_GP(theta, bjd, rv, erv) # save output _save_draws('Kep21HARPSN', Krvs, As, ls, Gs, Ps, ss, sigKs)
def compute_nRV_GP(GPtheta, keptheta, sigRV_phot, sigK_target, duration=100): assert len(GPtheta) == 5 assert len(keptheta) == 2 a, l, G, Pgp, s = GPtheta P, K = keptheta # search for target sigma by iterating over Nrv coarsely Nrvs = np.arange(10, 1001, 90) sigKs = np.zeros(Nrvs.size) for i in range(Nrvs.size): # get rv activity model gp = george.GP(a*(george.kernels.ExpSquaredKernel(l) + \ george.kernels.ExpSine2Kernel(G,Pgp))) t = _uniform_window_function(duration, Nrvs[i]) erv = np.repeat(sigRV_phot, t.size) gp.compute(t, np.sqrt(erv**2 + s**2)) rv_act = gp.sample(t) # get planet model rv_kep = -K*np.sin(2*np.pi*foldAt(t, P)) # get total rv signal with noise rv = rv_act + rv_kep + np.random.randn(t.size) * sigRV_phot # compute sigK theta = P, 0, K, a, l, G, Pgp, s sigKs[i] = compute_sigmaK_GP(theta, t, rv, erv) # fit powerlaw in log space to estimate Nrv for the target sigK g = np.isfinite(sigKs) p = np.poly1d(np.polyfit(np.log(sigKs[g]), np.log(Nrvs[g]), 1)) Nrv = np.exp(p(np.log(sigK_target))) return Nrv
def compare_WFs(N): '''Compute a set of sigKs using a GP with the K2-18 HARPS WF and a uniform WF to test the sensitivity of sigK on the assumed WF.''' GPtheta, keptheta, sig_phot = set_thetas() a, l, G, Pgp, s = GPtheta P, K = keptheta sigK_target = K / 3. N = int(N) sigKs_uni, sigKs_harps = np.zeros(N), np.zeros(N) for i in range(N): print float(i) / N gp = george.GP(a*(george.kernels.ExpSquaredKernel(l) + \ george.kernels.ExpSine2Kernel(G,Pgp))) t1 = get_uniform_WF() t2 = get_true_WF() assert t1.size == t2.size erv = np.repeat(sig_phot, t1.size) gp.compute(t1, np.sqrt(erv**2 + s**2)) rv_act1 = gp.sample(t1) gp.compute(t2, np.sqrt(erv**2 + s**2)) rv_act2 = gp.sample(t2) # get planet model rv_kep1 = -K*np.sin(2*np.pi*foldAt(t1, P)) rv_kep2 = -K*np.sin(2*np.pi*foldAt(t2, P)) # get total rv signal with noise rv1 = rv_act1 + rv_kep1 + np.random.randn(t1.size) * sig_phot rv2 = rv_act2 + rv_kep2 + np.random.randn(t1.size) * sig_phot # compute sigK theta = P, 0, K, a, l, G, Pgp, s sigKs_uni[i] = compute_sigmaK_GP(theta, t1, rv1, erv) sigKs_harps[i] = compute_sigmaK_GP(theta, t2, rv2, erv) return sigKs_uni, sigKs_harps
def sigK_K218(N=1e3, P=32.93963, T0=2457264.39157): '''From Cloutier et al 2017''' # get time-series bjd, rv, erv = np.loadtxt('Nrv_tests/K218.dat').T kepc = get_rv1((8.962, 2457264.55, 0, 4.63, 0, 0), bjd) rv -= kepc # sample parameter posteriors approximating the PDFs as Gaussian N = int(N) Krvs = _random_normal_draws(3.18, .71, N, positive=True) As = _random_normal_draws(.67, 1.8, N, positive=True) ls = _random_normal_draws(64.49, 15, N, positive=True) Gs = _random_normal_draws(1.2, .45, N, positive=True) Ps = _random_normal_draws(38.6, .9, N, positive=True) ss = _random_normal_draws(.25, .4, N, positive=True) # Monte-Carlo computation of sigKs sigKs = np.zeros(N) for i in range(N): theta = P, T0, Krvs[i], As[i], ls[i], Gs[i], Ps[i], ss[i] sigKs[i] = compute_sigmaK_GP(theta, bjd, rv, erv) # save output _save_draws('K218', Krvs, As, ls, Gs, Ps, ss, sigKs)
def compute_nRV_GP(GPtheta, keptheta, sig_phot, sigK_target, fname='', duration=100): ''' Compute nRV for TESS planets including a GP activity model (i.e. non-white noise model. ''' assert len(GPtheta) == 5 assert len(keptheta) == 2 a, l, G, Pgp, s = GPtheta P, K = keptheta # search for target sigma by iterating over Nrv coarsely at first Nrvs = np.arange(10, 1001, 90) sigKs = np.zeros(Nrvs.size) for i in range(Nrvs.size): # get rv activity model gp = george.GP(a*(george.kernels.ExpSquaredKernel(l) + \ george.kernels.ExpSine2Kernel(G,Pgp))) t = _uniform_window_function(duration, Nrvs[i]) erv = np.repeat(sig_phot, t.size) gp.compute(t, np.sqrt(erv**2 + s**2)) rv_act = gp.sample(t) ##if rv_act.std() > 0: ## rv_act *= a / rv_act.std() # get planet model rv_kep = -K * np.sin(2 * np.pi * foldAt(t, P)) # get total rv signal with noise rv = rv_act + rv_kep + np.random.randn(t.size) * sig_phot # compute sigK theta = P, 0, K, a, l, G, Pgp, s sigKs[i] = compute_sigmaK_GP(theta, t, rv, erv) # fit powerlaw to Nrv vs sigK ##g = np.isfinite(sigKs) ##alpha0 = np.polyfit(np.log10(sigKs[g]), np.log10(Nrvs[g]), 1)[0] ##A0 = Nrvs.max() / sigKs[g].min()**alpha0 ##bounds = [-np.inf,-np.inf,0], [np.inf]*3 ##popt,_ = curve_fit(powerlawfunc, sigKs[g], Nrvs[g], p0=[A0, alpha0, 0], ## bounds=bounds) ##Nrv1 = float(powerlawfunc(sigK_target, *popt)) # fit power in log space g = np.isfinite(sigKs) p = np.poly1d(np.polyfit(np.log(sigKs[g]), np.log(Nrvs[g]), 1)) Nrv = np.exp(p(np.log(sigK_target))) # save diagnostic plot if fname != '': label = fname.split('/')[-1].split('.')[0] starnum = label.split('_')[0].split('t')[-1] try: os.mkdir('plots/star%s' % starnum) except OSError: pass sigKs_temp = np.logspace(np.log10(sigKs.min()), np.log10(sigKs.max()), 100) # dont plot!! #plt.scatter(sigKs, Nrvs), plt.plot(sigKs_temp, np.exp(p(np.log(sigKs_temp))), '-') #plt.xlabel('sigK (m/s)'), plt.ylabel('nRV'), plt.xscale('log'), plt.yscale('log') #plt.savefig('plots/star%s/%s.png'%(starnum, label)), plt.close('all') np.savetxt('plots/star%s/%s_datapoints.dat' % (starnum, label), np.array([sigKs, Nrvs]).T, fmt='%.5e', delimiter='\t') np.savetxt('plots/star%s/%s_fit.dat' % (starnum, label), np.array([sigKs_temp, np.exp(p(np.log(sigKs_temp)))]).T, fmt='%.5e', delimiter='\t') return Nrv