<jupyter_start><jupyter_text><jupyter_code>!pip install lightkurve

import lightkurve as lp
# Creating a Lightkurve Object from TragetPixelFile
from lightkurve import search_targetpixelfile
# First we open a Target Pixel File from MAST, this one is already cached from our previous tutorial!
tpf = search_targetpixelfile('KIC 6922244', quarter=4).download()

# Then we convert the target pixel file into a light curve using the pipeline-defined aperture mask.
lc = tpf.to_lightcurve(aperture_mask=tpf.pipeline_mask)
# Mission and Quarter
lc.mission, lc.quarter
# Time and Flux attributes
lc.time, lc.flux
# Checking the “CDPP” noise metric of the lightcurve 
lc.estimate_cdpp()
#Now we can use the built in plot function on the KeplerLightCurve object to plot the time series. 
#You can pass plot any keywords you would normally pass to matplotlib.pyplot.plot.

%matplotlib inline
lc.plot();
#Functions we can use in LightKurve objects, to work with the data
#flatten(): Remove long term trends using a Savitzky–Golay filter
#remove_outliers(): Remove outliers using simple sigma clipping
#remove_nans(): Remove infinite or NaN values (these can occur during thruster firings)
#fold(): Fold the data at a particular period
#bin(): Reduce the time resolution of the array, taking the average value in each bin.
flat_lc = lc.flatten(window_length=401)
flat_lc.plot();
folded_lc = flat_lc.fold(period=3.5225)
folded_lc.plot();
binned_lc = folded_lc.bin(binsize=10)
binned_lc.plot();
# Doing the same exact thing all at once in a long line
lc.remove_nans().flatten(window_length=401).fold(period=3.5225).bin(binsize=10).plot();<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.08166969147005444, 'fraction_numerical': 0.01693889897156685, 'mean_word_length': 5.863070539419087, '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': '408366', 'license': 'MIT', 'n_tokens_mistral': 549, 'n_tokens_neox': 511, 'n_words': 195, 'path': 'Interns/Elise/What_are_LightCurve_objects?.ipynb', 'repo_name': 'elsiecolme/EscapeEarth', 'size': '1653'}