<jupyter_start><jupyter_text><jupyter_code>!pip install lightkurve
import lightkurve as lk
import numpy as np
lk.__version__
lcfs = lk.search_lightcurvefile('KIC 757450', mission='Kepler').download_all()
period, t0, duration_hours = 8.88492, 134.452, 2.078
lc_raw = lcfs.PDCSAP_FLUX.stitch()
lc_raw.flux.shape
lc_clean = lc_raw.remove_outliers(sigma=20, sigma_upper=4)
temp_fold = lc_clean.fold(period, t0=t0)
fractional_duration = (duration_hours / 24.0) / period
phase_mask = np.abs(temp_fold.phase) < (fractional_duration * 1.5)
transit_mask = np.in1d(lc_clean.time, temp_fold.time_original[phase_mask])

lc_flat, trend_lc = lc_clean.flatten(return_trend=True, mask=transit_mask)
lc_fold = lc_flat.fold(period, t0=t0)
lc_global = lc_fold.bin(bins=2001, method='median').normalize() - 1
lc_global = (lc_global / np.abs(lc_global.flux.min()) ) * 2.0 + 1
lc_global.flux.shape
lc_global.scatter();
phase_mask = (lc_fold.phase > -4*fractional_duration) & (lc_fold.phase < 4.0*fractional_duration)
lc_zoom = lc_fold[phase_mask]
lc_local = lc_zoom.bin(bins=201, method='median').normalize() -1
lc_local = (lc_local / np.abs(lc_local.flux.min()) ) * 2.0 + 1
lc_local.flux.shape
lc_local.scatter();<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1432078559738134, 'fraction_numerical': 0.044189852700491, 'mean_word_length': 6.64375, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 6, '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': '87505', 'license': 'MIT', 'n_tokens_mistral': 550, 'n_tokens_neox': 496, 'n_words': 78, 'path': 'Interns/Elise/Machine_learning_style_preprocessing_with_lightkurve.ipynb', 'repo_name': 'elsiecolme/EscapeEarth', 'size': '1222'}