Ejemplo n.º 1
0
import numpy as np
import matplotlib.pyplot as plt
import fitsio
from plotstuff import params
reb = params()
from gatspy.periodic import LombScargle
import nufft
from K2pgram import K2pgram
import h5py
from stello import sigma_clipping, load_data


def load_data_new(id):
    print "loading data"
    fname = "ktwo%s-c01_lpd-lc.fits" % id
    data = fitsio.read(fname)
    aps = fitsio.read(fname, 2)
    y = data["flux"][:, np.argmin(aps["cdpp6"])]
    x = data["time"]
    q = data["quality"]
    l = np.isfinite(y) * np.isfinite(x) * (q == 0)
    with h5py.File("../data/c1.h5", "r") as f:
        basis = f["basis"][:150, l]
    return x[l], y[l], basis


def load_vbg(id):
    x, y, _ = np.genfromtxt("/Users/angusr/data/K2/c1lcsr4/ep%s.csv" % id,
                            delimiter=",").T
    return x, y
Ejemplo n.º 2
0
from __future__ import print_function
import numpy as np
import matplotlib.pyplot as plt
import h5py
from plotstuff import params, colours
reb = params()
cols = colours()
from gatspy.periodic import LombScargle
import sys
import multiprocessing as mp
from multiprocessing import Pool
from GProtation import make_plot, lnprob, Gprob, neglnlike
import emcee
import time
import george
from george.kernels import ExpSquaredKernel, ExpSine2Kernel
import scipy.optimize as spo

def periodograms(id, x, y, yerr, path, plot=False, savepgram=False):
    """
    takes id of the star, returns an array of period measurements and saves the
    results.
    id: star id.
    x, y, yerr: time, flux and error arrays.
    path: path where you want to save the output.
    """
    ps = np.linspace(2, 100, 1000)
    model = LombScargle().fit(x, y, yerr)
    pgram = model.periodogram(ps)

    # find peaks
Ejemplo n.º 3
0
import numpy as np
import matplotlib.pyplot as plt
import george
from george.kernels import ExpSquaredKernel
import fitsio
import glob
from plotstuff import params, colours
cols = colours()
params()

# Load the data
kid = "008311864"
fnames = \
    glob.glob("/Users/ruthangus/.kplr/data/lightcurves/{0}/*".format(kid))
x, y, yerr = [], [], []
for fname in fnames:
    data = fitsio.read(fname)
    time = data["TIME"]
    flux = data["PDCSAP_FLUX"]
    err = data["PDCSAP_FLUX_ERR"]
    m = np.isfinite(time) * np.isfinite(flux) * np.isfinite(err)
    x.append(time[m])
    med = np.median(flux[m])
    y.append(flux[m]/med - 1)
    yerr.append(err[m]/med)
x = [i for j in x for i in j]
y = [i for j in y for i in j]
yerr = [i for j in yerr for i in j]
x -= x[0]
m1, m2 = 2100, 7000
x, y, yerr = x[m1:m2], y[m1:m2], yerr[m1:m2]