In [108]:
from __future__ import division, print_function
%matplotlib inline
In [109]:
import numpy as np
import matplotlib.pyplot as plt
from astropy.table import Table
In [110]:
from martinsff import martinsff
import extract_lc
In [111]:
#from os import listdir
#from os.path import isfile, join
#onlyfiles = [ f for f in listdir('/Users/bryanmann/Documents/NASA_Kepler_2.0/All_Light_Curves/Light_Curves/dat_files/') if isfile(join('/Users/bryanmann/Documents/NASA_Kepler_2.0/All_Light_Curves/Light_Curves/dat_files/',f)) ]
In [112]:
#for row in onlyfiles:
#fn = row
#time, flux, xbar, ybar = np.genfromtxt(fn, unpack = True)
fn = '/Users/bryanmann/Documents/NASA_Kepler_2.0/All_Light_Curves/Lightcurves_RADec_ap3.0_BJM/J06101557+2436535_xy_v2_ap3.0.dat'
time, flux, xbar, ybar = np.genfromtxt(fn, unpack = True)
DANCe = 'J06101557+2436535'
In [113]:
m1 = np.isfinite(flux)
time = time[m1]
flux = flux[m1]
xbar = xbar[m1]
ybar = ybar[m1]
flatlc = extract_lc.medfilt(time,flux,window=3)
zpt = len(time)%300
In [114]:
outflux, correction, thr_cad = extract_lc.run_C0_detrend(
time, flatlc, xbar, ybar, cadstep=300)
In [115]:
plt.plot(time,flatlc)
Out[115]:
In [118]:
not_thr = ~thr_cad
corflux = (flux[zpt:][not_thr]/
np.median(flux[zpt:][not_thr])/
correction[not_thr])
corflatflux = (flatlc[zpt:][not_thr]/
np.median(flatlc[zpt:][not_thr])/
correction[not_thr])
In [119]:
from astropy.stats import median_absolute_deviation as MAD
mad_cut = 1.4826*MAD(corflatflux-1.)*4
keep = np.abs(corflatflux-1.) < mad_cut
plt.plot(time[zpt:][not_thr],corflatflux,c='r')
plt.plot(time[zpt:][not_thr][keep],corflatflux[keep],c='b')
Out[119]:
In [120]:
from scipy import stats
# 2.5 hr cdpp function
def twohr_cdpp(flux):
bin_sigma = []
for k in range(len(flux)-5):
bin_sigma.append(stats.nanstd(flux[k:k+5])/np.sqrt(5.))
cdpp = stats.nanmedian(bin_sigma)
return cdpp
# 6.5 hr cdpp function
def sixhr_cdpp(flux):
bin_sigma = []
for k in range(len(flux)-13):
bin_sigma.append(stats.nanstd(flux[k:k+13])/np.sqrt(13.))
cdpp = stats.nanmedian(bin_sigma)
return cdpp
In [121]:
thr = twohr_cdpp(flux)
shr = sixhr_cdpp(flux)
In [122]:
plt.figure(figsize=[15,6])
plt.plot(time,flux/np.median(flux),'bo',markersize=1)
plt.plot(time[zpt:][not_thr][keep],corflux[keep],marker='.')
plt.xlabel('Time [d]')
plt.ylabel('Normalized Flux')
plt.title(str(DANCe) + ' 6.5_Hr_CDPP_' + str(shr) + ' | 2.5_Hr_CCPD_' + str(thr))
plt.savefig('/Users/bryanmann/Documents/NASA_Kepler_2.0/All_Light_Curves/Lightcurves_RADec_ap3.0_BJM/J06101557+2436535_xy_v2_ap3.0.png')
In [122]:
In [46]:
In [ ]: