import numpy as np import matplotlib.pyplot as plt import pyfits import glob from scipy.signal.spectral import lombscargle import scipy.signal as sps from scaling_relations import nu_max, delta_nu from astero import astero from rc_params import plot_params reb, rfb = plot_params() from colours import plot_colours ocols = plot_colours() def testing(): x = np.arange(0, 10, .1) y = np.sin(2*x + np.pi/4.) yerr = np.ones_like(y)*.01 plt.clf() plt.plot(x, y) ys, A = fit_single_sine_err(x, y, yerr, 2) plt.plot(x, ys, 'r') plt.show() print find_phase(A)/np.pi # calculate the periodogram for plotting def pgram(x, y, peak1): fs = np.linspace(5, 45, 10000) # c/d ws = 2*np.pi*fs # lombscargle uses angular frequencies pgram = lombscargle(x, y, ws) plt.clf() plt.subplot(2, 1, 1)
import numpy as np import matplotlib.pyplot as plt import pyfits import glob import scipy.signal as sps from astero_modelling import gen_freqs_nm_dn import kplr client = kplr.API() from astero_modelling import model from sin_tests import fit_sine_err from rc_params import plot_params reb, fbt = plot_params() from colours import plot_colours ocols = plot_colours() # Attempting to perform asteroseismology on kepler data def download(KID): # load data, median normalise and join together lc_files = glob.glob("/Users/angusr/.kplr/data/lightcurves/%s/*_slc.fits" % str(KID).zfill(9)) # check to see whether you've already downloaded data... print len(lc_files), ' files' if len(lc_files) == 0: print 'downloading..' star = client.star("%s" % KID) lcs = star.get_light_curves(short_cadence=True, fetch=True) lc_files = glob.glob("/Users/angusr/.kplr/data/lightcurves/%s/*_slc.fits" % str(KID).zfill(9)) print lc_files
import numpy as np import matplotlib.pyplot as plt import george from george.kernels import ExpSquaredKernel, ExpSine2Kernel, WhiteKernel from colors import plot_colors ocols = plot_colors() from rc_params import plot_params reb = plot_params() from BGdata import BetaGem BG = BetaGem() from HD82074 import HD HD = HD() def sampling(t, xs, ys, rv_err): # try calculating different rms ppd = 1./(max(t) - min(t)) * 1000. # points per day ppt = np.array([24, 24*2, 24*3, 24*4, 24*5, 24*10, 24*20, 24*30, 24*60]) # pph, pphh, pptm, ppm rms = [] for pts in ppt[::-1]: l = int(ppd/pts) x, y, yerr = xs[::l], ys[::l], np.ones_like(ys[::l])*np.mean(rv_err) print np.std(y) rms.append(np.sqrt(sum((y)**2)/len(y))) return ppt, rms def prior_sample(t, rv, rv_err, theta, i): # sample from the prior k = theta[0] * ExpSquaredKernel(theta[1]) * \ ExpSine2Kernel(theta[2], theta[3])
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)
import numpy as np import matplotlib.pyplot as plt from rc_params import plot_params pp = plot_params() from astropy import constants from YREC import YREC yrec = YREC() L_sun = 3.846e26 R_sun = 6.955e8 def radius_sb(L, T): L *= L_sun sb = 5.67e-8 return np.sqrt(L / (sb * T**4)) / R_sun # for a given mass and teff, what is the radius? def rad(M, T): # load isochrones iso_M, iso_L, iso_T = yrec.mass, 10**yrec.logL, yrec.teff # find closest mass, closest teff and corresponding l m = min(iso_M, key=lambda x:abs(x-M)) teff = min(iso_T, key=lambda x:abs(x-T)) l = iso_L[iso_M==m] # warning: this is often degenerate! return radius_sb(l[0], teff), m, teff, l if __name__ == "__main__":