lightkurve has a class specifically for dealing with periodograms of time series data. This can be useful for finding the periods of variable stars. Below is a quick example of how to find the period of an eclipsing binary star using lightkurve.
Firstly lets grab a light curve file from mast. We'll use KIC 10030943, which is an eclipsing binary observed by the original Kepler mission. We're just going to use one quarter for this demo.
% load_ext autoreload
% autoreload 2
from lightkurve import KeplerLightCurveFile # Import lightkurve
import astropy.units as u # We'll need this later.
# Obtain the data
lc = KeplerLightCurveFile.from_archive('10264202', quarter=10).PDCSAP_FLUX.remove_nans()
Let's plot the light curve to see what we're working with.
lc.scatter()
<matplotlib.axes._subplots.AxesSubplot at 0x1c18d7f630>
This light curve looks like it has some structure in it! Let's use the periodogram class to find the rotation period. You can create a periodogram from the KeplerLightCurve
object by using the periodogram
method.
pg = lc.periodogram()
Now we can plot the periodogram in the same way that we plot the original light curve.
pg.plot()
<matplotlib.axes._subplots.AxesSubplot at 0x10ce31e48>
This looks like there is a huge signal at a certain frequency! Let's plot it in period space, so that we can see what period the oscillation is occuring at.
pg.plot(format='period', scale='log')
<matplotlib.axes._subplots.AxesSubplot at 0x1c1b5a4630>
This looks like a very fast period. Let's find the period with the highest power and fold out light curve.
period = pg.period_at_max_power
print('Best period: {}'.format(period))
lc.fold(period.value).scatter()
Best period: 0.2587311606278735 d
<matplotlib.axes._subplots.AxesSubplot at 0x1c1c3b44e0>
As is quite common for eclisping binaries with deep secondary eclipses, we have found a harmonic of the period of the eclipsing binary. Let's plot it again with quadruple the period.
period = pg.period_at_max_power * 4
print('Best period: {}'.format(period))
lc.fold(period.value).scatter()
Best period: 1.034924642511494 d
<matplotlib.axes._subplots.AxesSubplot at 0x1c1c312438>
It looks like we could probably get a better fit than this. Let's try increasing the number of points in our periodogram.
# I've set min_period and max_period to slightly reduce the computational time
pg = lc.periodogram(min_period=0.9*u.day, max_period=1.2*u.day, oversample_factor=10)
period = pg.period_at_max_power
print('Best period: {}'.format(period))
lc.fold(period.value).scatter()
Best period: 1.0350971683913832 d
<matplotlib.axes._subplots.AxesSubplot at 0x1c1c97feb8>
That's improved out fit! It looks like this eclipsing binary has a period of approximately 1 day.