# How to combine lightcurves from different Kepler quarters¶

The Kepler mission took 17 quarters of continuous observations on the same targets. For applications such as finding long period planets or asteroseismology it is useful to be able to turn these quarters into one long light curve. We can do this using lightkurve’s append function. The append function is called by doing

stitched_lc = lc1.append(lc2)


It works in the same way as appending a list in python.

Below is an example of how to stitch together all the quarters for the exoplanet target Kepler-8b. (Note: We’ll use the jupyter notebook magic command %%capture to supress the output for the cell so that it doesn’t print a long download message)

In [1]:

from lightkurve import KeplerLightCurveFile
target = 'Kepler-8b'

In [2]:

%%capture
lc = KeplerLightCurveFile.from_archive(target, quarter=1).PDCSAP_FLUX
for q in range(2,17):
lc = lc.append(KeplerLightCurveFile.from_archive(target, quarter=q).PDCSAP_FLUX)


Above we have created a KeplerLightCurve object from the first quarter of the data, choosing to use the PDCSAP_FLUX. Then we have looped through all the quarters, appending each new light curve to the fist one. We can plot this new KeplerLightCurve using the plot function (and all the other functions from previous tutorials will work too!)

In [3]:

lc.plot();


Unfortunately, as the light fell on difference pixels in each quarter and the spacecraft changed temperature during observation, these light curves all have difference offsets. We can remove them by normalizing each light curve before we append it. We can do this with the lightkurve function normalize.

In [4]:

%%capture
lc = KeplerLightCurveFile.from_archive(target, quarter=1).PDCSAP_FLUX.normalize()
for q in range(2,8):
lc = lc.append(KeplerLightCurveFile.from_archive(target, quarter=q).PDCSAP_FLUX.normalize())

In [5]:

lc.plot();


Now that the light curves are normalized they don’t have significant offsets. However, there are clear long term trends in some of the early quarters of the data. We can remove this using lightkurve’s flatten method before appending each object.

In [6]:

%%capture
lc = KeplerLightCurveFile.from_archive(target, quarter=1).PDCSAP_FLUX.normalize().flatten(window_length=401)
for q in range(2,8):
lc = lc.append(KeplerLightCurveFile.from_archive(target, quarter=q).PDCSAP_FLUX.normalize().flatten(window_length=401))

In [7]:

lc.plot();


Now all of the light curves stitch together with no visible join. We can use the fold and bin methods to form a planet transit out of all of the data for Kepler-8b.

In [8]:

lc.fold(3.52254, phase=0.38).bin().plot();