Exemple #1
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
# the 2nd K2pgram (periodogram of a 2nd frequency),
# the data conditioned on the best freqency and the top
# eigen light curves.

import numpy as np
import matplotlib.pyplot as plt
import fitsio
from K2pgram import K2pgram, eval_freq
from rotation_poster_child import max_peak_detect
import h5py
from gatspy.periodic import LombScargle
import wget
import subprocess
import scipy.signal as sps
from plotstuff import colours
cols = colours()


def read_data(epid, nbases):
    # read the data
    try:
        data = fitsio.read("../data/c1/ktwo%s-c01_lpd-lc.fits" % epid)
    except:
        e = str(int(epid))
        base_url = "http://bbq.dfm.io/ketu/lightcurves/c1"
        url = "%s/%s00000/%s000/ktwo%s-c01_lpd-lc.fits" \
                % (base_url, e[:4], e[4:6], e)
        print url
        wget.download(url)
        subprocess.call("mv ktwo%s-c01_lpd-lc.fits ../data/c1" % epid,
                        shell=True)