11 November 2020

SPACEKIT Analyzer: plotting light curves

by Ru Kein

timeseries flux signal analysis

In the previous post, we downloaded a set of K2 confirmed planet Fits files into a local directory ‘./data/mast’. Now that we have our datasets, we can extract the time-series flux data and use this to generate some plots. Initially, we’ll plot some basic scatter and line plots. Next we’ll apply time-binned phase folding to identify periodicity and plot the normalized light curves in order to identify potential TCEs (threshold crossing events: when an object orbiting the star causes the light flux values (our data) to dip signicantly on a periodic basis). These events are highly indicative of a planet orbiting the star, making this a standard approach to identifying exoplanets.

First we’ll extract the long cadence signals then plot them as line and scatter plots. An exoplanet candidate will usually display regular (periodic) dips, though a long period may only include a single dip.

from spacekit.analyzer.explore import SignalPlots
sp = SignalPlots(show=True)
fits_file = os.path.join(data, 'ktwo206181769-c03_llc.fits')
timestamps, flux = sp.read_ts_signal(fits_file, signal_col="sap_flux")
sp.atomic_vector_plotter(flux, timestamps=timestamps, name="k2_llc_sap")
K2 timeseries SAP Flux

We can also look at an error-corrected and denoised version of the signal using the PDCSAP_FLUX values:

timestamps, pflux = sp.read_ts_signal(fits_file, signal_col="pdcsap_flux", bkjd=True, remove_nans=True)
sp.atomic_vector_plotter(flux, timestamps=timestamps, name="k2_llc_pdcsap")
K2 timeseries PDCSAP Flux

If we have a labeled dataset (e.g. first index in each array is a target label indicating 2=planet and 1=no planet), we can include that data in our plots as well:

sp = SignalPlots(show=True, target_cns={1: "No Planet", 2: "Planet"}, color_map={1: "red", 2: "blue"})
# if target class is at the first index of our timeseries array
sp.atomic_vector_plotter(flux[1:], label=flux[0], x_units="Time", y_units="PDC_SAP Flux")
atomic vector plotter lineplot
atomic vector plotter scatterplot

phase folded light curves

For a more robust analysis, we can calculate the period and plot a time-binned and phase-folded light curve. This can often (though not always) confirm the presence of at least one transiting exoplanet.

flist = ['ktwo206181769-c03_llc.fits']
df = sp.signal_phase_folder(flist)
sp.plot_phase_signals(df.iloc[0])
k2 folded light curve

Contact

If you want to contact me you can send a message on LinkedIn.

License

This project uses the following license: MIT License.

  
            /\    _       _                           _                      * 
   /\_/\___/  \__| |_____| |_________________________| |___________________*___
   [===]  / /\ \ | |  _  |  _  | _  \/ __/ -__|  \| \_  _/ _  \ \_/ | * _/| | |
    \./  /_/  \_\|_|  ___|_| |_|__/\_\ \ \____|_|\__| \__/__/\_\___/|_|\_\|_|_|
                   | /             |___/                                       
                   |/