# Calculate depth and duration of exoplanet's transit using Python, astropy or lightkurve

I am creating a program for the analysis of exoplanets in Python using Astropy and Lightkurve libraries. I have light curve of specified star and I would like to calculate depth and duration of planet transit. There is example for Kepler 10 bellow with these steps:

• Load target pixel image for Kepler 10,
• Convert it to flattened time series,
• Calculate period using periodogram,
• Create folded light curve.
import lightkurve as lk

target_pixel = lk.search_targetpixelfile("Kepler-10", quarter=1).download()
lightcurve = target_pixel.to_lightcurve(aperture_mask=target_pixel.pipeline_mask).flatten()
periodogram = lightcurve.to_periodogram(method="bls", period=np.arange(0.5, 10, 0.001))
period = periodogram.period_at_max_power

folded.scatter()
print(period)


The output is (I marked the depth and duration in red): Now, how can I calculate duration of transit (approximately from -0.15 to to 0 on x-axis)? Interval from -0.5 to 0.5 should be whole period (0.837 d), so transit duration should be +/- 0.13 d.

And what about transit depth? I was thinking about:

min = np.min(folded.flux)
median = np.median(folded.flux)
median / min - 1 # 0.00038


However, the minimum point is not the one in the middle of the transit due to noise, so transit depth may not be accurate.

## 1 Answer

Calculation of both, depth and duration, is usually done not on the raw data but derived from a fit to the data.

In your last three lines of code you also calculate the average / medium over all data while you should calculate the uneclipsed mean or median flux only for the non-transit time (with using median it possibly has only a tiny influence, yet it might).

As a first and crude step, I'd de-noise the data by applying a floating average filter over the data; you will have to test for its width and see what gives you best results: you don't want to average out features, but you want to average-out noise.

The better approach is to not smooth but actually fit a physical model to the data which takes into account the typical light curve behaviour of a transit. For an implementation I can point you to pytransit (reference paper). (Are you sure you are not re-inventing the wheel?). See also this paper by Maxted and Gill for a comparison of a few algorithms.