Kepler Data

The Data


In [1]:
# !curl -O http://archive.stsci.edu/pub/kepler/lightcurves/0071/007198959/kplr007198959-2009259160929_llc.fits

In [2]:
from astropy.io import fits
hdulist = fits.open('kplr007198959-2009259160929_llc.fits')
hdulist.info()


Filename: kplr007198959-2009259160929_llc.fits
No.    Name         Type      Cards   Dimensions   Format
  0  PRIMARY     PrimaryHDU      58   ()      
  1  LIGHTCURVE  BinTableHDU    155   4354R x 20C   [D, E, J, E, E, E, E, E, E, J, D, E, D, E, D, E, D, E, E, E]   
  2  APERTURE    ImageHDU        48   (12, 41)   int32   

In [3]:
hdulist[1].header


Out[3]:
XTENSION= 'BINTABLE'           / marks the beginning of a new HDU               
BITPIX  =                    8 / array data type                                
NAXIS   =                    2 / number of array dimensions                     
NAXIS1  =                  100 / length of first array dimension                
NAXIS2  =                 4354 / length of second array dimension               
PCOUNT  =                    0 / group parameter count (not used)               
GCOUNT  =                    1 / group count (not used)                         
TFIELDS =                   20 / number of table fields                         
TTYPE1  = 'TIME    '           / column title: data time stamps                 
TFORM1  = 'D       '           / column format: 64-bit floating point           
TUNIT1  = 'BJD - 2454833'      / column units: barycenter corrected JD          
TDISP1  = 'D14.7   '           / column display format                          
TTYPE2  = 'TIMECORR'           / column title: barycenter - timeslice correction
TFORM2  = 'E       '           / column format: 32-bit floating point           
TUNIT2  = 'd       '           / column units: day                              
TDISP2  = 'E13.6   '           / column display format                          
TTYPE3  = 'CADENCENO'          / column title: unique cadence number            
TFORM3  = 'J       '           / column format: signed 32-bit integer           
TDISP3  = 'I10     '           / column display format                          
TTYPE4  = 'SAP_FLUX'           / column title: aperture photometry flux         
TFORM4  = 'E       '           / column format: 32-bit floating point           
TUNIT4  = 'e-/s    '           / column units: electrons per second             
TDISP4  = 'E14.7   '           / column display format                          
TTYPE5  = 'SAP_FLUX_ERR'       / column title: aperture phot. flux error        
TFORM5  = 'E       '           / column format: 32-bit floating point           
TUNIT5  = 'e-/s    '           / column units: electrons per second (1-sigma)   
TDISP5  = 'E14.7   '           / column display format                          
TTYPE6  = 'SAP_BKG '           / column title: aperture phot. background flux   
TFORM6  = 'E       '           / column format: 32-bit floating point           
TUNIT6  = 'e-/s    '           / column units: electrons per second             
TDISP6  = 'E14.7   '           / column display format                          
TTYPE7  = 'SAP_BKG_ERR'        / column title: ap. phot. background flux error  
TFORM7  = 'E       '           / column format: 32-bit floating point           
TUNIT7  = 'e-/s    '           / column units: electrons per second (1-sigma)   
TDISP7  = 'E14.7   '           / column display format                          
TTYPE8  = 'PDCSAP_FLUX'        / column title: aperture phot. PDC flux          
TFORM8  = 'E       '           / column format: 32-bit floating point           
TUNIT8  = 'e-/s    '           / column units: electrons per second             
TDISP8  = 'E14.7   '           / column display format                          
TTYPE9  = 'PDCSAP_FLUX_ERR'    / column title: ap. phot. PDC flux error         
TFORM9  = 'E       '           / column format: 32-bit floating point           
TUNIT9  = 'e-/s    '           / column units: electrons per second (1-sigma)   
TDISP9  = 'E14.7   '           / column display format                          
TTYPE10 = 'SAP_QUALITY'        / column title: aperture photometry quality flag 
TFORM10 = 'J       '           / column format: signed 32-bit integer           
TDISP10 = 'B16.16  '           / column display format                          
TTYPE11 = 'PSF_CENTR1'         / column title: PSF-fitted column centroid       
TFORM11 = 'D       '           / column format: 64-bit floating point           
TUNIT11 = 'pixel   '           / column units: pixel                            
TDISP11 = 'F10.5   '           / column display format                          
TTYPE12 = 'PSF_CENTR1_ERR'     / column title: PSF-fitted column error          
TFORM12 = 'E       '           / column format: 32-bit floating point           
TUNIT12 = 'pixel   '           / column units: pixel (1-sigma)                  
TDISP12 = 'E14.7   '           / column display format                          
TTYPE13 = 'PSF_CENTR2'         / column title: PSF-fitted row centroid          
TFORM13 = 'D       '           / column format: 64-bit floating point           
TUNIT13 = 'pixel   '           / column units: pixel                            
TDISP13 = 'F10.5   '           / column display format                          
TTYPE14 = 'PSF_CENTR2_ERR'     / column title: PSF-fitted row error             
TFORM14 = 'E       '           / column format: 32-bit floating point           
TUNIT14 = 'pixel   '           / column units: pixel (1-sigma)                  
TDISP14 = 'E14.7   '           / column display format                          
TTYPE15 = 'MOM_CENTR1'         / column title: moment-derived column centroid   
TFORM15 = 'D       '           / column format: 64-bit floating point           
TUNIT15 = 'pixel   '           / column units: pixel                            
TDISP15 = 'F10.5   '           / column display format                          
TTYPE16 = 'MOM_CENTR1_ERR'     / column title: moment-derived column error      
TFORM16 = 'E       '           / column format: 32-bit floating point           
TUNIT16 = 'pixel   '           / column units: pixel (1-sigma)                  
TDISP16 = 'E14.7   '           / column display format                          
TTYPE17 = 'MOM_CENTR2'         / column title: moment-derived row centroid      
TFORM17 = 'D       '           / column format: 64-bit floating point           
TUNIT17 = 'pixel   '           / column units: pixel                            
TDISP17 = 'F10.5   '           / column display format                          
TTYPE18 = 'MOM_CENTR2_ERR'     / column title: moment-derived row error         
TFORM18 = 'E       '           / column format: 32-bit floating point           
TUNIT18 = 'pixel   '           / column units: pixel (1-sigma)                  
TDISP18 = 'E14.7   '           / column display format                          
TTYPE19 = 'POS_CORR1'          / column title: column position correction       
TFORM19 = 'E       '           / column format: 32-bit floating point           
TUNIT19 = 'pixels  '           / column units: pixel                            
TDISP19 = 'E14.7   '           / column display format                          
TTYPE20 = 'POS_CORR2'          / column title: row position correction          
TFORM20 = 'E       '           / column format: 32-bit floating point           
TUNIT20 = 'pixels  '           / column units: pixel                            
TDISP20 = 'E14.7   '           / column display format                          
INHERIT =                    T / inherit the primary header                     
EXTNAME = 'LIGHTCURVE'         / name of extension                              
EXTVER  =                    1 / extension version number (not format version)  
TELESCOP= 'Kepler  '           / telescope                                      
INSTRUME= 'Kepler Photometer'  / detector type                                  
OBJECT  = 'KIC 7198959'        / string version of target id                    
KEPLERID=              7198959 / unique Kepler target identifier                
RADESYS = 'ICRS    '           / reference frame of celestial coordinates       
RA_OBJ  =           291.366301 / [deg] right ascension                          
DEC_OBJ =            42.784367 / [deg] declination                              
EQUINOX =               2000.0 / equinox of celestial coordinate system         
EXPOSURE=          81.90687481 / [d] time on source                             
TIMEREF = 'SOLARSYSTEM'        / barycentric correction applied to times        
TASSIGN = 'SPACECRAFT'         / where time is assigned                         
TIMESYS = 'TDB     '           / time system is barycentric JD                  
BJDREFI =              2454833 / integer part of BJD reference date             
BJDREFF =           0.00000000 / fraction of the day in BJD reference date      
TIMEUNIT= 'd       '           / time unit for TIME, TSTART and TSTOP           
TELAPSE =          88.96781229 / [d] TSTOP - TSTART                             
LIVETIME=          81.90687481 / [d] TELAPSE multiplied by DEADC                
TSTART  =         169.51002764 / observation start time in BJD-BJDREF           
TSTOP   =         258.47783993 / observation stop time in BJD-BJDREF            
LC_START=       55002.01747542 / mid point of first cadence in MJD              
LC_END  =       55090.96492052 / mid point of last cadence in MJD               
DEADC   =           0.92063492 / deadtime correction                            
TIMEPIXR=                  0.5 / bin time beginning=0 middle=0.5 end=1          
TIERRELA=             5.78E-07 / [d] relative time error                        
TIERABSO=                      / [d] absolute time error                        
INT_TIME=       6.019802903270 / [s] photon accumulation time per frame         
READTIME=       0.518948526144 / [s] readout time per frame                     
FRAMETIM=       6.538751429414 / [s] frame time (INT_TIME + READTIME)           
NUM_FRM =                  270 / number of frames per time stamp                
TIMEDEL =     0.02043359821692 / [d] time resolution of data                    
DATE-OBS= '2009-06-20T00:10:27.146Z' / TSTART as UTC calendar date              
DATE-END= '2009-09-16T23:24:11.862Z' / TSTOP as UTC calendar date               
BACKAPP =                    T / background is subtracted                       
DEADAPP =                    T / deadtime applied                               
VIGNAPP =                    T / vignetting or collimator correction applied    
GAIN    =                111.9 / [electrons/count] channel gain                 
READNOIS=            80.176350 / [electrons] read noise                         
NREADOUT=                  270 / number of read per cadence                     
TIMSLICE=                    2 / time-slice readout sequence section            
MEANBLCK=                  728 / [count] FSW mean black level                   
LCFXDOFF=               419400 / long cadence fixed offset                      
SCFXDOFF=               219400 / short cadence fixed offset                     
CDPP3_0 =     4018.13134765625 / [ppm] RMS CDPP on 3.0-hr time scales           
CDPP6_0 =    3200.025146484375 / [ppm] RMS CDPP on 6.0-hr time scales           
CDPP12_0=     2240.04345703125 / [ppm] RMS CDPP on 12.0-hr time scales          
CROWDSAP=               0.9991 / Ratio of target flux to total flux in op. ap.  
FLFRCSAP=               0.9981 / Frac. of target flux w/in the op. aperture     
NSPSDDET=                    0 / Number of SPSDs detected                       
NSPSDCOR=                    0 / Number of SPSDs corrected                      
PDCVAR  =      8497.4873046875 / Target variability                             
PDCMETHD= 'regularMap'         / PDC algorithm used for target                  
NUMBAND =                    1 / Number of scale bands                          
FITTYPE1= 'prior   '           / Fit type used for band 1                       
PR_GOOD1=   0.9999999403953552 / Prior goodness for band 1                      
PR_WGHT1=           7.222428E7 / Prior weight for band 1                        
PDC_TOT =   0.9671307802200317 / PDC total goodness metric for target           
PDC_TOTP=    47.21249771118164 / PDC_TOT percentile compared to mod/out         
PDC_COR =   0.9740492701530457 / PDC correlation goodness metric for target     
PDC_CORP=    16.63991355895996 / PDC_COR percentile compared to mod/out         
PDC_VAR =   0.9556516408920288 / PDC variability goodness metric for target     
PDC_VARP=   25.864707946777344 / PDC_VAR percentile compared to mod/out         
PDC_NOI =   0.9995011687278748 / PDC noise goodness metric for target           
PDC_NOIP=     99.8350601196289 / PDC_NOI percentile compared to mod/out         
PDC_EPT =                  1.0 / PDC earth point goodness metric for target     
PDC_EPTP=    76.93851470947266 / PDC_EPT percentile compared to mod/out         
CHECKSUM= '5dE25ZB05bB05ZB0'   / HDU checksum updated 2015-09-07T00:10:06Z      

In [4]:
from astropy.table import Table
data = Table(hdulist[1].data)
data


Out[4]:
<Table length=4354>
TIMETIMECORRCADENCENOSAP_FLUXSAP_FLUX_ERRSAP_BKGSAP_BKG_ERRPDCSAP_FLUXPDCSAP_FLUX_ERRSAP_QUALITYPSF_CENTR1PSF_CENTR1_ERRPSF_CENTR2PSF_CENTR2_ERRMOM_CENTR1MOM_CENTR1_ERRMOM_CENTR2MOM_CENTR2_ERRPOS_CORR1POS_CORR2
float64float32int32float32float32float32float32float32float32int32float64float32float64float32float64float32float64float32float32float32
169.5202447070.0027692929651.04089e+0780.651417445.86.81535nannan256nannannannan658.984905345.95852e-0648.31036798366.3673e-05-0.00062082-0.0417439
169.5406788850.0027698629661.02251e+0779.947917458.66.81904nannan256nannannannan658.9847560556.02055e-0648.36459534346.32755e-05-0.000859906-0.0414842
169.5611130620.0027704429671.00993e+0779.451317447.16.81976nannan256nannannannan658.9845890336.06324e-0648.39977506666.29868e-05-0.00104417-0.0411753
169.5815472390.0027710229681.01336e+0779.597417440.86.83005nannan8576nannannannan658.9844229046.04838e-0648.3904956936.31236e-05-0.00107995-0.0406672
169.6019814150.002771629691.02778e+0780.185817444.16.82776nannan393600nannannannan658.9841227555.99424e-0648.33588367746.35298e-05-0.00127112-0.0405857
169.6224154920.0027721729701.02574e+0780.07217459.86.82085nannan256nannannannan658.9845842295.99411e-0648.35141644866.3458e-05-0.00144995-0.0403933
169.6428497680.0027727529719.98968e+0679.095917483.76.82168nannan384nannannannan658.9843449266.09163e-0648.45324477076.3e-05-0.00170547-0.0402648
169.6632839440.0027733229729.77098e+0678.233417483.06.82184nannan384nannannannan658.984389836.17017e-0648.47744638066.24124e-05-0.00160952-0.0400706
169.683718020.002773929731.00747e+0779.349817492.06.82596nannan8576nannannannan658.9841649046.05106e-0648.40051357076.30872e-05-0.00186426-0.0400735
169.7041521950.0027744829741.16034e+0785.200817466.96.84612nannan384nannannannan658.983936995.57952e-0648.14918955956.69151e-05-0.00199162-0.0393474
............................................................
258.2837266320.0027085173091.31303e+0790.764717822.36.882461.31696e+0790.82420nannannannan658.9765662535.28842e-0648.5566222526.65606e-05-0.003386480.0333565
258.3041595140.0027078973101.29471e+0790.106417815.16.877751.29858e+0790.1590nannannannan658.9767851385.28611e-0648.54898299176.71985e-05-0.003622690.0343312
258.3245925950.0027072873111.27119e+0789.257717829.26.860931.27434e+0789.30910nannannannan658.976903185.31089e-0648.43554484836.73667e-05-0.003677310.0329374
258.3450255770.0027066673121.24702e+0788.385717808.96.863791.25071e+0788.45380nannannannan658.9769880515.34708e-0648.28089133156.72824e-05-0.003752140.0333151
258.3654584580.0027060473131.22394e+0787.539617795.86.867211.22863e+0787.60568192nannannannan658.9767205055.3801e-0648.13812361566.72635e-05-0.004391230.0352742
258.3858914390.002705427314nannannannannannan32800nannannannannannannannannannan
258.4063245190.002704873151.16802e+0785.47217810.26.847041.17144e+0785.53620nannannannan658.9780094675.4965e-0648.02390728026.65793e-05-0.003132380.0327484
258.42675740.0027041873161.13527e+0784.252717809.36.851941.1391e+0784.3110nannannannan658.9775393585.58907e-0648.10190070766.57001e-05-0.003678030.033705
258.447190380.0027035673171.10874e+0783.258417793.66.843241.11284e+0783.32450nannannannan658.9775337775.6692e-0648.17537403256.50243e-05-0.003643780.0347512
258.467623460.0027029473181.09189e+0782.619317790.16.851211.09536e+0782.68360nannannannan658.9771624065.72111e-0648.22628436846.45673e-05-0.00397660.0342977

In [5]:
df = data.to_pandas()[['TIME', 'SAP_FLUX', 'SAP_FLUX_ERR']]
df.shape


Out[5]:
(4354, 3)

In [6]:
df = df.dropna()
df.shape


Out[6]:
(4083, 3)

In [7]:
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
from astropy.stats import LombScargle

plt.style.use('seaborn-whitegrid')

Data and Window


In [8]:
from astropy.stats import LombScargle

In [9]:
ls = LombScargle(df['TIME'], 1, center_data=False, fit_mean=False)
freqW, powerW = ls.autopower(minimum_frequency=0,
                             maximum_frequency=200)


/Users/jakevdp/anaconda/envs/python3.5/lib/python3.5/site-packages/astropy/stats/lombscargle/implementations/fast_impl.py:123: RuntimeWarning: invalid value encountered in true_divide
  power = (YC * YC / CC + YS * YS / SS)

In [10]:
# Find the maximum near 2 hours
f, p = ls.autopower(minimum_frequency=1.95*24,
                    maximum_frequency=2.05*24,
                    samples_per_peak=100)
f_ny = f[np.argmax(p)]

In [11]:
t_sorted = np.sort(df['TIME'])
p_ny = 24 * 60 * 60 / f_ny
delta_t = (t_sorted[1:] - t_sorted[:-1]) * 24 * 60 * 60

In [12]:
ls = LombScargle(df['TIME'], df['SAP_FLUX'], df['SAP_FLUX_ERR'])
freq, power = ls.autopower(minimum_frequency=0,
                           maximum_frequency=200)

fmax = freq[np.argmax(power)] / 24

In [13]:
fig, ax = plt.subplots(2, 2, figsize=(12, 5))

fig.suptitle('Kepler object ID 007198959', size=14)
fig.subplots_adjust(hspace=0.35, wspace=0.15, left=0.07, right=0.97)

# upper left
ax[0, 0].plot(df['TIME'], df['SAP_FLUX'] / 1E6, 'ok', markersize=2, rasterized=True)
ax[0, 0].set(ylabel='SAP flux ($10^6 e^-/s$)',
             title='Observed light curve',
             xlim=(168, 260))

# bottom left
left, bottom, width, height = ax[1, 0].get_position().bounds
ax[1, 0].set_position([left, bottom + 0.15, width, height-0.15])
inset = fig.add_axes([left, bottom, width, 0.1])

ax[1, 0].plot(t_sorted[:-1], delta_t / 60, 'ok', markersize=2, rasterized=True)
ax[1, 0].axhline(p_ny / 60, color='gray', linestyle='--')
ax[1, 0].set(xlim=ax[0, 0].get_xlim(),
             ylim=(10, 10000),
             yscale='log',
             ylabel='$\Delta t$ (min)',
             title='Time between observations')
ax[1, 0].xaxis.set_major_formatter(plt.NullFormatter())

inset.plot(t_sorted[:-1], 1000 * (delta_t - p_ny), 'ok', markersize=2, rasterized=True)
inset.axhline(0, color='gray', linestyle='--')
inset.set(xlim=ax[0, 0].get_xlim(),
          ylim=(-100, 100),
          xlabel='Observation time (days)',
          ylabel='$\Delta t - p_{W}$ (ms)')
inset.yaxis.set_major_locator(plt.MaxNLocator(3));

# Upper right
ax[0, 1].plot(freqW / 24, powerW, '-k', rasterized=True);
ax[0, 1].set(xlim=(0, 6.5),
             ylim=(-0.1, 1.1),
             ylabel='Lomb-Scargle power',
             title='Window Power Spectrum');
ax[0, 1].annotate('', (0, 0.6), (f_ny / 24, 0.6),
                  arrowprops=dict(arrowstyle='<->', color='gray'));
ax[0, 1].text(f_ny / 48, 0.6, r'$({0:.1f}\ {{\rm minutes}})^{{-1}}$'.format(24 * 60 / f_ny),
              size=12, ha='center', va='bottom');

# Lower right
ax[1, 1].plot(freq / 24, power, '-k', rasterized=True)
ax[1, 1].fill_between([0.5 * f_ny / 24, 1.5 * f_ny / 24], -0.05, 1,
                      color='gray', alpha=0.3)
ax[1, 1].text(2.25, 0.95, r"(Aliased Region)", size=14, color='gray', ha='right', va='top')
ax[1, 1].text(fmax, 0.85, r"$f_{{max}}=({0:.2f}\ {{\rm hours}})^{{-1}}$".format(1 / fmax),
              size=12)
ax[1, 1].set(xlim=(0, 2.3),
             ylim=(-0.05, 1.0),
             xlabel='frequency (hours$^{-1}$)',
             ylabel='Lomb-Scargle power',
             title='Light Curve Power Spectrum');

fig.savefig('fig16_kepler_data.pdf')


Size of required grid


In [14]:
n_o = 5
T = df['TIME'].max() - df['TIME'].min()
delta_f = 1. / n_o / T

print("f_ny =", f_ny)
print("T =", T)
print("n_grid =", f_ny / delta_f)


f_ny = 48.9393547811
T = 88.947378753
n_grid = 21765.1366282