-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathanalyze.py
27 lines (21 loc) · 1.03 KB
/
analyze.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# Make sure to replace "#insert link here" with the actual link (Use download helper)
tpf = TessTargetPixelFile("#insert link here")
# Display a single snapshot of the target pixel file
tpf.plot(frame_number=42)
# Convert the target pixel file to a light curve
light_curve = tpf.to_lightcurve(aperture_mask=tpf.pipeline_mask)
light_curve.plot()
# Flatten the light curve to remove trends
flattened_lc = light_curve.flatten()
flattened_lc.plot()
# Calculate the periodogram to find the dominant orbital period
periods = np.linspace(1, 5, 10000)
periodogram = light_curve.to_periodogram(method='bls', period=periods, frequency_factor=500)
periodogram.plot()
# Extract key parameters from the periodogram
orbital_period = periodogram.period_at_max_power
transit_midpoint = periodogram.transit_time_at_max_power
transit_duration = periodogram.duration_at_max_power
# Phase-fold the light curve using the discovered orbital period
folded_lc_ax = light_curve.fold(period=orbital_period, epoch_time=transit_midpoint).scatter()
folded_lc_ax.set_xlim(-3, 3)