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.
First, let’s grab a light curve file from the Kepler data archive. We’ll use the object named KIC 10264202, which is an eclipsing binary observed by the original Kepler mission. We’re just going to use one quarter of data for this demo.
from lightkurve import search_lightcurve lc = search_lightcurve('KIC 10264202', author="Kepler", quarter=10, cadence="long").download().remove_nans()
Let’s plot the light curve to see what we’re working with.
%matplotlib inline lc.scatter();
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 to_periodogram method.
pg = lc.to_periodogram(oversample_factor=1)
Now we can plot the periodogram in the same way that we plot the original light curve.
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 occurring at.
This looks like a very fast period. We can access the full period and power data as follows:
In this case we simply want to know the period that corresponds to the highest peak in the periodogram. We can directly access this value using the convenient period_at_max_power property:
We can then use this period to fold our light curve:
Oops, the eclipses do not line up nicely. This does not look like the correct period of this eclipsing binary!
As is quite common for eclipsing 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.
That looks better, but the eclipses still don’t seem to line up as well as they could.
Let’s try to get a more precise period by increasing the number of points in our periodogram using the
oversample_factor parameter and by constraining the range of the period value:
import astropy.units as u pg = lc.to_periodogram(minimum_period=0.9*u.day, maximum_period=1.2*u.day, oversample_factor=10) pg.period_at_max_power
This has improved our fit. It looks like this eclipsing binary has a period of approximately 1 day.