コード例 #1
0
ファイル: rotation.py プロジェクト: RuthAngus/KeplerGP
def before_and_after(theta, x, y, yerr, p1, p2, fname):
    xs = np.linspace(min(x), max(x), 100)
    ocols = plot_colors()

    # plot initial guess
    plt.subplot(2,1,1)
    plt.errorbar(x, y, yerr=yerr, fmt='k.', capsize=0, ecolor='.8')
    mu, cov = predict(theta, xs, x, y, yerr, p1)
    plt.plot(xs, mu, color=ocols.blue, label="$\mathrm{Period}=%s$" % p1)
    plt.xlabel('$\mathrm{Time~(days)}$')
    plt.ylabel('$\mathrm{RV~(ms}_{-1}\mathrm{)}$')
    plt.subplots_adjust(hspace=.2)
    plt.legend()

    # optimise hyperparameters
    new_theta = fmin(neglnlike, theta, args=(x, y, yerr, p2))

    # plot final guess
    plt.subplot(2,1,2)
    plt.errorbar(x, y, yerr=yerr, fmt='k.', capsize=0, ecolor='.8')
    mu, cov = predict(new_theta, xs, x, y, yerr, p2)
    plt.plot(xs, mu, color=ocols.orange, label="$\mathrm{Period}=%s$" % p2)
    plt.xlabel('$\mathrm{Time~(days)}$')
    plt.ylabel('$\mathrm{RV~(ms}_{-1}\mathrm{)}$')
    plt.subplots_adjust(hspace=.3)
    plt.legend()
    plt.savefig('%s_baa' % fname)
コード例 #2
0
ファイル: BG_sinefitting.py プロジェクト: RuthAngus/Subgiants
import numpy as np
import matplotlib.pyplot as plt
import george
from sin_tests import fit_sine
from rotation import before_and_after
from BGdata import BetaGem
import scipy.signal as sps
from scipy.misc import derivative
from scaling_relations import nu_max, delta_nu
from rc_params import plot_params
from colors import plot_colors
ocol = plot_colors()
BG = BetaGem()
from astero_modelling import MCMC

# load period04 fitted frequencies
# freq, amp, phase = \
#         np.genfromtxt('/Users/angusr/Python/Subgiants/data/period04_results.txt',
#                       skip_header=1).T

# load frequencies and amplitudes
freq_day, f_err, freq_mHz, amp, err = \
        np.genfromtxt('/Users/angusr/Python/Subgiants/data/BG_freqs.txt',
                      skip_header=1).T

BGm = 1.91
BGm_err = 0.09
BGr = 8.8
BGr_err = 0.1
BGteff = 4750
BGteff_err = 150
コード例 #3
0
ファイル: chiron_dwarfs.py プロジェクト: RuthAngus/Subgiants
import numpy as np
import matplotlib.pyplot as plt
import idlsave
from rc_params import plot_params
from colors import plot_colors
params = plot_params()
ocols = plot_colors()

# load star names
DIR = '/Users/angusr/Python/Subgiants'
stars = np.genfromtxt('%s/data/star_names.txt' % DIR)
rv_files = glob.glob('%s/data/vst*.dat' % DIR)

plt.clf()
for i, star in enumerate(stars):
    data = idlsave.read("%s/data/vst%s.dat" % (DIR, int(star)))

    t = data.cf3['JD']
    rv = data.cf3['MNVEL']
    rv_err = data.cf3['ERRVEL']

    plt.subplot(len(stars), 1, i+1)
    plt.errorbar(t, rv, yerr=rv_err, capsize=0, ecolor='.8', fmt='k.')

plt.savefig("%s/figures/all_stars" % DIR)
コード例 #4
0
ファイル: K2emcee.py プロジェクト: RuthAngus/KeplerGP
import numpy as np
import matplotlib.pyplot as plt
import george
from george.kernels import ExpSine2Kernel, ExpSquaredKernel, WhiteKernel
from scipy.optimize import minimize, fmin
import emcee
import triangle
import h5py
from rotation import multilnlike_emcee_comb, predict
from GPgrid import bin_data
from colors import plot_colors
ocols = plot_colors()


def lnprior(theta):
    #     and -20 < theta[6] < 20 and np.log(12) < theta[7] < np.log(15):
    if -20 < theta[0] < 16 and 0 < theta[1] < 10 and -10 < theta[2] < 10 \
    and -20 < theta[3] < 20 and -20 < theta[4] < 20 and -20 < theta[5] < 20 \
    and -20 < theta[6] < 20 and np.log(20) < theta[7] < np.log(50):
        return 0.
    return -np.inf


def lnprob(theta, x, y, yerr):
    return lnprior(theta) + multilnlike_emcee_comb(theta, x, y, yerr)


def MCMC(theta, x, y, yerr, fname, burn_in, nsteps, nruns):

    # setup sampler
    nwalkers, ndim = 32, len(theta)