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

<p>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).</p>

<p>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.</p>

<p>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 <a href="http://hpparvi.github.io/PyTransit/" rel="nofollow noreferrer">pytransit</a> (<a href="https://ieeexplore.ieee.org/document/8212395" rel="nofollow noreferrer">reference paper</a>). (Are you sure you are not re-inventing the wheel?). See also <a href="https://www.aanda.org/articles/aa/pdf/2019/02/aa34563-18.pdf" rel="nofollow noreferrer">this paper</a> by Maxted and Gill for a comparison of a few algorithms.</p>

CC BY-SA 4.0
2020-06-12T09:21:15.710Z
2020-06-12T12:17:59.837Z
2020-06-12T12:17:59.837Z
planetmaker
<p>I am creating a program for the analysis of exoplanets in Python using <a href="https://www.astropy.org/" rel="nofollow noreferrer">Astropy</a> and <a href="https://docs.lightkurve.org/" rel="nofollow noreferrer">Lightkurve</a> 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:</p>

<ul>
<li>Load target pixel image for Kepler 10,</li>
<li>Convert it to flattened time series,</li>
<li>Calculate period using periodogram,</li>
<li>Create folded light curve.</li>
</ul>

<pre><code>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)
</code></pre>

<p>The output is (I marked the depth and duration in red):</p>

<p><a href="https://i.sstatic.net/xXe8d.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/xXe8d.png" alt="enter image description here"></a></p>

<p>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.</p>

<p>And what about transit depth? I was thinking about:</p>

<pre><code>min = np.min(folded.flux)
median = np.median(folded.flux)
median / min - 1 # 0.00038
</code></pre>

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

<astrophysics><python><planetary-transits><astropy><light-curve>
Calculate depth and duration of exoplanet's transit using Python, astropy or lightkurve
Michal
# Calculate depth and duration of exoplanet's transit using Python, astropy or lightkurve

(Asked by: username_0 on 2020-06-12)

I am creating a program for the analysis of exoplanets in Python using [Astropy](https://www.astropy.org/) and [Lightkurve](https://docs.lightkurve.org/) 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):

[![enter image description here](https://i.sstatic.net/xXe8d.png)](https://i.sstatic.net/xXe8d.png)

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.

**Tags:** astrophysics, python, planetary-transits, astropy, light-curve


---

## 1 answers

### Answer by username_1 on 2020-06-12. Score: 2 | Accepted 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](http://hpparvi.github.io/PyTransit/) ([reference paper](https://ieeexplore.ieee.org/document/8212395)). (Are you sure you are not re-inventing the wheel?). See also [this paper](https://www.aanda.org/articles/aa/pdf/2019/02/aa34563-18.pdf) by Maxted and Gill for a comparison of a few algorithms.


---

