#!/usr/bin/env python # coding: utf-8 # # What is the Periodogram class? # *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. # In[1]: import astropy.units as u # We'll need this later. # In[2]: # Obtain the data from lightkurve import search_lightcurvefile lc = search_lightcurvefile('10264202', quarter=10).download().PDCSAP_FLUX.remove_nans() # Let's plot the light curve to see what we're working with. # In[3]: 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 `periodogram` method. # In[4]: pg = lc.to_periodogram() # Now we can plot the periodogram in the same way that we plot the original light curve. # In[5]: pg.plot(); # 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. # In[6]: pg.plot(format='period', scale='log'); # This looks like a very fast period. Let's find the period with the highest power and fold out light curve. # In[7]: period = pg.period_at_max_power print('Best period: {}'.format(period)) lc.fold(period.value).scatter(); # 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. # In[8]: period = pg.period_at_max_power * 4 print('Best period: {}'.format(period)) lc.fold(period.value).scatter(); # It looks like we could probably get a better fit than this. Let's try increasing the number of points in our periodogram. # In[9]: # I've set min_period and max_period to slightly reduce the computational time pg = lc.to_periodogram(min_period=0.9*u.day, max_period=1.2*u.day, oversample_factor=10) # In[10]: period = pg.period_at_max_power print('Best period: {}'.format(period)) lc.fold(period.value).scatter(); # That's improved our fit! It looks like this eclipsing binary has a period of approximately 1 day.