<jupyter_start><jupyter_text><jupyter_code>!pip install lightkurve
import lightkurve as lp
#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.
from lightkurve import search_lightcurvefile
lc = search_lightcurvefile('KIC 10264202', quarter=10).download().PDCSAP_FLUX.remove_nans()
lc.scatter();
#This light curve looks like it has some structure in it! 
# We can use the periodogram class to find the rotation period. 
# We can create a periodogram from the KeplerLightCurve object by using the to_periodogram method.
pg = lc.to_periodogram(oversample_factor=1)
#Plotting the periodogram
pg.plot();

#looks like there is a huge signal at a certain frequency
#Plotting it in period space, so that we can see what period the oscillation is occurring at
pg.plot(view='period', scale='log');
pg.period, pg.power
#In this case we simply want to know the period that corresponds to the highest peak in the periodogram. 
pg.period_at_max_power
#Using this period to fold our curve
lc.fold(pg.period_at_max_power).scatter();
#Multiplied it by 4 so the eclipies would line up better
lc.fold(4 * pg.period_at_max_power).scatter();
#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
lc.fold(pg.period_at_max_power).scatter();<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.07050528789659224, 'fraction_numerical': 0.011163337250293772, 'mean_word_length': 5.575289575289576, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '227476', 'license': 'MIT', 'n_tokens_mistral': 536, 'n_tokens_neox': 512, 'n_words': 210, 'path': 'Interns/Elise/What_are_Periodogram_objects?.ipynb', 'repo_name': 'elsiecolme/EscapeEarth', 'size': '1702'}