This is the development version of the TESS Science Support Center website. For the live website, visit https://heasarc.gsfc.nasa.gov/docs/tess

HowToFindAnExoplanet-UserVersion

How to find an Exoplanet with TESS data

When a planet passes in front of its host star, from a certain view point, it causes the light of that star to dim. This is known as a transit.

Many space missions have been specifically designed to detect planets using the transit method. One such mission is the Transiting Exoplanet Survey Satellite (TESS).

TESS is a NASA-sponsored Astrophysics Explorer-class mission that is performing a near all-sky survey to search for planets transiting nearby stars. The mission observes from a unique elliptical high Earth orbit (HEO) that provides an unobstructed view of its field to obtain continuous light curves and a more stable platform for precise photometry than a low Earth orbit.

TESS is equipped with four CCD cameras that have adjacent field-of-views to produce a 4 x 1 array, or ‘observing Sector’, yielding a combined field-of-view of 96 x 24 degrees, as illustrated below.

Each hemisphere is split into these observing Sectors, and each Sector is observed for ~27 days. Since 2018, TESS has observed approximately 80% of the sky, mapping both the northern and southern hemispheres, and detecting thousands of planet candidates.

Data from the TESS mission are publicly available from the Mikulski Archive for Space Telescopes (MAST). The main data products collected by the TESS mission are described below:

To learn more about the TESS mission and its data products, please visit the TESS GI pages.

Download the notebook

If you would like to download a copy of this notebook you can do so by clicking the link below

DOWNLOAD

Learning Goals

In this tutorial, we will teach the user how to access, analyze, and manipulate data from the TESS mission (this can also be applied to Kepler & K2). We will be utilizing a Python package called Lightkurve which offers a user-friendly way to analyze time series data on the brightness of planets, stars, and galaxies. The package is focused on supporting science with NASA’s Kepler and TESS space telescopes but can equally be used to analyze light curves obtained by your backyard telescope.

This tutorial assumes a basic knowledge of python and astronomy, and will walk the user through several of the concepts outlined below,

  • How to use Lightkurve to access the various data products and create time series.
  • How to account for instrumental and noise effects within your data.
  • How to recover a planet transit from your data.

Imports

This tutorial requires the use of specific packages: - Lightkurve to work with TESS data (v2.0.1) - Matplotlib for plotting. - Numpy for manipulating the data.

import lightkurve as lk
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline

First time users

If you are not experienced with Python, or cannot download Lightkurve, you can run this notebook as a Colab notebook. Colaboratory allows users to write and execute Python in your browser with zero configuration required.

All you need is a Google account and to copy and paste in the following command at the top of your colab notebook:

!pip install lightkurve --quiet

This downloads the Lightkurve package.

1. How to use Lightkurve to access the various data products and create a time series

You can search for the various data products for TESS using the following Lightkurve functions.

In this tutorial, we will be examining a nearby, bright target Pi Mensae (TIC ID 261136679), around which TESS scientists discovered a short period planet candidate on a 6.27 day orbit. See the ApJ paper by Huang et al (2018) for more details.

1.1 Accessing the data products

Let’s go through each one of the above functions and see what data is available.

search_ffi = lk.search_tesscut('Pi Mensae')
search_tpf = lk.search_targetpixelfile('Pi Mensae')
search_lcf = lk.search_lightcurve('Pi Mensae')
search_ffi
SearchResult containing 13 data products.
#missionyearauthorexptimetarget_namedistance
sarcsec
0TESS Sector 012018TESScut1426Pi Mensae0.0
1TESS Sector 042018TESScut1426Pi Mensae0.0
2TESS Sector 082019TESScut1426Pi Mensae0.0
3TESS Sector 112019TESScut1426Pi Mensae0.0
4TESS Sector 122019TESScut1426Pi Mensae0.0
5TESS Sector 132019TESScut1426Pi Mensae0.0
6TESS Sector 272020TESScut475Pi Mensae0.0
7TESS Sector 282020TESScut475Pi Mensae0.0
8TESS Sector 312020TESScut475Pi Mensae0.0
9TESS Sector 342021TESScut475Pi Mensae0.0
10TESS Sector 352021TESScut475Pi Mensae0.0
11TESS Sector 382021TESScut475Pi Mensae0.0
12TESS Sector 392021TESScut475Pi Mensae0.0

The above table provides several important pieces of information. - The sector in which the object was observed. - The year in which the object was observed. - The author of the data. This has multiple options, and each is a hyperlink that when clicked will provide you with more information. - The cadence of the observation. - The name of the target. - The distance of the observation from your target of interest. This is useful if you conduct a cone search around your objects co-ordinates.

The table above indicates that our object was observed in multiple Sectors. Note that in Sectors 1 - 13 (2018 & 2019) that the cadence of the FFI data was 30-min, but in Sectors 27 and above (2020 & 2021) it is 10-min.

Let’s see if any other data exists - i.e., was it observed as a target of interest and does it have a Target Pixel File.

search_tpf
SearchResult containing 30 data products.
#missionyearauthorexptimetarget_namedistance
sarcsec
0TESS Sector 012018SPOC1202611366790.0
1TESS Sector 012018TESS-SPOC18002611366790.0
2TESS Sector 042018SPOC1202611366790.0
3TESS Sector 042018TESS-SPOC18002611366790.0
4TESS Sector 082019SPOC1202611366790.0
5TESS Sector 082019TESS-SPOC18002611366790.0
6TESS Sector 112019SPOC1202611366790.0
7TESS Sector 112019TESS-SPOC18002611366790.0
8TESS Sector 122019SPOC1202611366790.0
9TESS Sector 122019TESS-SPOC18002611366790.0
.....................
20TESS Sector 312020TESS-SPOC6002611366790.0
21TESS Sector 342021SPOC202611366790.0
22TESS Sector 342021SPOC1202611366790.0
23TESS Sector 342021TESS-SPOC6002611366790.0
24TESS Sector 382021SPOC202611366790.0
25TESS Sector 382021SPOC1202611366790.0
26TESS Sector 382021TESS-SPOC6002611366790.0
27TESS Sector 392021SPOC202611366790.0
28TESS Sector 392021SPOC1202611366790.0
29TESS Sector 392021TESS-SPOC6002611366790.0
Length = 30 rows

Great! Our object was observed as a target of interest and has 2-min and 20-sec cadenced data. This means that there should be light curve files already on the archive. Let’s check those out.

search_lcf
SearchResult containing 41 data products.
#missionyearauthorexptimetarget_namedistance
sarcsec
0TESS Sector 012018SPOC1202611366790.0
1TESS Sector 012018TESS-SPOC18002611366790.0
2TESS Sector 012018QLP18002611366790.0
3TESS Sector 012018TASOC1202611366790.0
4TESS Sector 012018TASOC18002611366790.0
5TESS Sector 042018SPOC1202611366790.0
6TESS Sector 042018TESS-SPOC18002611366790.0
7TESS Sector 042018QLP18002611366790.0
8TESS Sector 082019SPOC1202611366790.0
9TESS Sector 082019TESS-SPOC18002611366790.0
.....................
31TESS Sector 312020QLP6002611366790.0
32TESS Sector 342021SPOC202611366790.0
33TESS Sector 342021SPOC1202611366790.0
34TESS Sector 342021TESS-SPOC6002611366790.0
35TESS Sector 382021SPOC202611366790.0
36TESS Sector 382021SPOC1202611366790.0
37TESS Sector 382021TESS-SPOC6002611366790.0
38TESS Sector 392021SPOC202611366790.0
39TESS Sector 392021SPOC1202611366790.0
40TESS Sector 392021TESS-SPOC6002611366790.0
Length = 41 rows

Wonderful! Light curves for our object of interest have already been created.

1.2 Creating a light curve using a Light Curve File

Now on to getting the light curve for our object of interest. From the above table, it looks like there are multiple authors for our target. For this tutorial, let’s stick to “SPOC” data products which have a 2-min cadence. We can return only these results using the following commands.

search_lcf_refined = lk.search_lightcurve('Pi Mensae', author="SPOC", exptime=120)
search_lcf_refined
SearchResult containing 12 data products.
#missionyearauthorexptimetarget_namedistance
sarcsec
0TESS Sector 012018SPOC1202611366790.0
1TESS Sector 042018SPOC1202611366790.0
2TESS Sector 082019SPOC1202611366790.0
3TESS Sector 112019SPOC1202611366790.0
4TESS Sector 122019SPOC1202611366790.0
5TESS Sector 132019SPOC1202611366790.0
6TESS Sector 272020SPOC1202611366790.0
7TESS Sector 282020SPOC1202611366790.0
8TESS Sector 312020SPOC1202611366790.0
9TESS Sector 342021SPOC1202611366790.0
10TESS Sector 382021SPOC1202611366790.0
11TESS Sector 392021SPOC1202611366790.0

We now see 11 search results. Let’s download these and see what the light curve looks like.

lcf = search_lcf_refined.download_all()
lcf
LightCurveCollection of 12 objects:
    0: <TessLightCurve LABEL="TIC 261136679" SECTOR=1 AUTHOR=SPOC FLUX_ORIGIN=pdcsap_flux>
    1: <TessLightCurve LABEL="TIC 261136679" SECTOR=4 AUTHOR=SPOC FLUX_ORIGIN=pdcsap_flux>
    2: <TessLightCurve LABEL="TIC 261136679" SECTOR=8 AUTHOR=SPOC FLUX_ORIGIN=pdcsap_flux>
    3: <TessLightCurve LABEL="TIC 261136679" SECTOR=11 AUTHOR=SPOC FLUX_ORIGIN=pdcsap_flux>
    4: <TessLightCurve LABEL="TIC 261136679" SECTOR=12 AUTHOR=SPOC FLUX_ORIGIN=pdcsap_flux>
    5: <TessLightCurve LABEL="TIC 261136679" SECTOR=13 AUTHOR=SPOC FLUX_ORIGIN=pdcsap_flux>
    6: <TessLightCurve LABEL="TIC 261136679" SECTOR=27 AUTHOR=SPOC FLUX_ORIGIN=pdcsap_flux>
    7: <TessLightCurve LABEL="TIC 261136679" SECTOR=28 AUTHOR=SPOC FLUX_ORIGIN=pdcsap_flux>
    8: <TessLightCurve LABEL="TIC 261136679" SECTOR=31 AUTHOR=SPOC FLUX_ORIGIN=pdcsap_flux>
    9: <TessLightCurve LABEL="TIC 261136679" SECTOR=34 AUTHOR=SPOC FLUX_ORIGIN=pdcsap_flux>
    10: <TessLightCurve LABEL="TIC 261136679" SECTOR=38 AUTHOR=SPOC FLUX_ORIGIN=pdcsap_flux>
    11: <TessLightCurve LABEL="TIC 261136679" SECTOR=39 AUTHOR=SPOC FLUX_ORIGIN=pdcsap_flux>

The above indicates that we have downloaded the light curves for each Sector and stored the data in arrays. You can look at the data for a specific Sector by specifying an array number as indicated below. This displays the data for Sector 1 as a table.

lcf[0]
TessLightCurve length=18279 LABEL="TIC 261136679" SECTOR=1 AUTHOR=SPOC FLUX_ORIGIN=pdcsap_flux
timefluxflux_errtimecorrcadencenocentroid_colcentroid_rowsap_fluxsap_flux_errsap_bkgsap_bkg_errpdcsap_fluxpdcsap_flux_errqualitypsf_centr1psf_centr1_errpsf_centr2psf_centr2_errmom_centr1mom_centr1_errmom_centr2mom_centr2_errpos_corr1pos_corr2
electron / selectron / sdpixpixelectron / selectron / selectron / selectron / selectron / selectron / spixpixpixpixpixpixpixpixpixpix
objectfloat32float32float32int32float64float64float32float32float32float32float32float32int32float64float32float64float32float64float32float64float32float32float32
1325.29696049506041.4641956e+061.3036719e+021.2319778e-03704451630.67624260.675401.4354926e+061.2776145e+023.9114688e+031.5351995e+011.4641956e+061.3036719e+020nannannannan1630.676248.4099076e-05260.675401.3968609e-049.0913408e-02-7.2966635e-02
1325.29834936453271.4643365e+061.3035809e+021.2319590e-03704461630.64880260.633921.4357199e+061.2775254e+023.8596919e+031.5269516e+011.4643365e+061.3035809e+020nannannannan1630.648808.4054744e-05260.633921.3961994e-046.2022530e-02-1.0871942e-01
1325.2997382340051.4643485e+061.3035931e+021.2319401e-03704471630.64806260.628401.4356588e+061.2775373e+023.8692920e+031.5291610e+011.4643485e+061.3035931e+020nannannannan1630.648068.4062471e-05260.628401.3959571e-046.1673984e-02-1.1394957e-01
1325.3011271034771.4643674e+061.3035008e+021.2319213e-03704481630.64752260.614341.4356190e+061.2774468e+023.8398132e+031.5262703e+011.4643674e+061.3035008e+020nannannannan1630.647528.4045743e-05260.614341.3958366e-046.0909923e-02-1.2573890e-01
1325.30251597306571.4642560e+061.3034836e+021.2319025e-03704491630.64057260.614121.4355810e+061.2774299e+023.8384204e+031.5262712e+011.4642560e+061.3034836e+020nannannannan1630.640578.4043444e-05260.614121.3952980e-045.3837594e-02-1.2532526e-01
1325.3039048425381.4644681e+061.3035623e+021.2318837e-03704501630.63971260.613261.4358005e+061.2775071e+023.8069717e+031.5240330e+011.4644681e+061.3035623e+020nannannannan1630.639718.4056861e-05260.613261.3949080e-045.2977830e-02-1.2562653e-01
1325.30529371212651.4643586e+061.3035381e+021.2318649e-03704511630.64385260.607081.4356219e+061.2774834e+023.8431169e+031.5283619e+011.4643586e+061.3035381e+020nannannannan1630.643858.4062158e-05260.607081.3951714e-045.7222184e-02-1.3051888e-01
1325.30668258159861.4643564e+061.3035527e+021.2318461e-03704521630.64220260.612151.4356771e+061.2774977e+023.8419392e+031.5270525e+011.4643564e+061.3035527e+020nannannannan1630.642208.4041087e-05260.612151.3955019e-045.5443291e-02-1.2712292e-01
1325.30807145118731.4645452e+061.3035765e+021.2318273e-03704531630.63883260.608311.4357862e+061.2775210e+023.8407632e+031.5274895e+011.4645452e+061.3035765e+020nannannannan1630.638838.4034349e-05260.608311.3950600e-045.1877767e-02-1.2947108e-01
........................................................................
1353.16456619477051.4646795e+061.3039951e+027.9329044e-04905101630.64438260.735401.4358860e+061.2779312e+024.0466931e+031.5422539e+011.4646795e+061.3039951e+020nannannannan1630.644388.4074054e-05260.735401.3953059e-045.5579260e-02-1.1038263e-02
1353.16595505062331.4649392e+061.3041254e+027.9325796e-04905111630.64849260.736251.4361424e+061.2780590e+024.0677520e+031.5430614e+011.4649392e+061.3041254e+020nannannannan1630.648498.4072431e-05260.736251.3956340e-046.0031198e-02-1.2474478e-02
1353.1673439064771.4646214e+061.3039377e+027.9322548e-04905121630.64657260.737131.4357276e+061.2778750e+024.0519436e+031.5423266e+011.4646214e+061.3039377e+020nannannannan1630.646578.4076637e-05260.737131.3951116e-045.7689309e-02-9.8480135e-03
1353.16873276227171.4647834e+061.3040990e+027.9319294e-04905131630.65187260.735591.4359665e+061.2780331e+024.0945930e+031.5460280e+011.4647834e+061.3040990e+020nannannannan1630.651878.4072963e-05260.735591.3958018e-046.3572161e-02-1.4975319e-02
1353.1701216181241.4644656e+061.3038603e+027.9316046e-04905141630.64304260.715031.4355525e+061.2777991e+024.0659807e+031.5433553e+011.4644656e+061.3038603e+020nannannannan1630.643048.4104897e-05260.715031.3954782e-045.4697301e-02-3.3739604e-02
1353.17151047391961.4647081e+061.3039996e+027.9312793e-04905151630.64598260.733591.4358651e+061.2779357e+024.0584336e+031.5429242e+011.4647081e+061.3039996e+020nannannannan1630.645988.4103733e-05260.733591.3949537e-045.7749905e-02-1.5640877e-02
1353.17289932977341.4646606e+061.3040236e+027.9309545e-04905161630.65524260.737181.4357864e+061.2779591e+024.0737170e+031.5449224e+011.4646606e+061.3040236e+020nannannannan1630.655248.4154504e-05260.737181.3958884e-046.7496188e-02-1.1539744e-02
1353.17428818556871.4648560e+061.3041582e+027.9306291e-04905171630.65059260.748471.4360880e+061.2780910e+024.0896948e+031.5452563e+011.4648560e+061.3041582e+020nannannannan1630.650598.4090752e-05260.748471.3948027e-046.1896853e-023.0782772e-03
1353.17567704142171.4646049e+061.3039998e+027.9303043e-04905181630.64159260.717631.4359089e+061.2779358e+024.0475869e+031.5419288e+011.4646049e+061.3039998e+020nannannannan1630.641598.4079904e-05260.717631.3953699e-045.2571520e-02-3.2142449e-02
1353.17706589721571.4646141e+061.3040526e+027.9299789e-04905191630.65089260.747161.4358994e+061.2779876e+024.0689077e+031.5450690e+011.4646141e+061.3040526e+020nannannannan1630.650898.4083091e-05260.747161.3951387e-046.2483948e-02-7.1828649e-04

In this table, you are given the time and the flux for your object of interest. There does however seem to be three entries for flux: flux, sap_flux, and pdcsap_flux. By default, the flux = pdcsap_flux, but what do these entries mean?

  • Simple Aperture Photometry (SAP): The SAP light curve is calculated by summing together the brightness of pixels that fall within an aperture set by the TESS mission. This is often referred to as the optimal aperture, but despite its name, it can sometimes be improved upon! Because the SAP light curve is a sum of the brightness in chosen pixels, it is still subject to systematic artifacts of the mission.
  • Pre-search Data Conditioning SAP flux (PDCSAP) flux: SAP flux from which long-term trends have been removed using so-called Co-trending Basis Vectors (CBVs). PDCSAP flux is usually cleaner data than the SAP flux and will have fewer systematic trends.

You can switch between fluxes using the following commands,

pdcsap = lcf[0].pdcsap_flux

sapflux = lcf[0].sap_flux

Let’s now plot both the PDCSAP and SAP light curves and see what they look like.

ax = lcf[0].plot(column='sap_flux', normalize=True, label="SAP");
lcf[0].plot(ax=ax, column='pdcsap_flux', normalize=True, label="PDCSAP");

There are some big differences between these two light curves, specifically the dips in the SAP light curve and its overall gradent. These differences will be discussed later in the tutorial. For now, let’s think about how we can manipulate the light curves.

1.2.1 Manipulating a light curve

There are a set of useful functions in Lightkurve which you can use to work with the data. These include:

  • 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.

We can use these simply on a light curve object. For this tutorial, let’s stick with the PDCSAP flux.

ax = lcf[0].plot()
ax.set_title("PDCSAP light curve of  Pi Mensae")
Text(0.5, 1.0, 'PDCSAP light curve of  Pi Mensae')

We can kind of make out a possible transit but let us manipulate the light curve some more to see if we can pull it out.

Flattening

flat_lc = lcf[0].flatten(window_length=1001)
flat_lc.plot();

The light curve looks much flatter. Unfortunately, there is a portion of the light curve that is very noisy, due to a jitter in the TESS spacecraft. We can remove this simply by masking the light curve. First, we’ll select the times that had the jitter.

# Flag the times that are good quality
mask = (flat_lc.time.value < 1346) | (flat_lc.time.value > 1350)
masked_lc = flat_lc[mask]
masked_lc.plot()
<matplotlib.axes._subplots.AxesSubplot at 0x7fb070571ed0>

We can use Lightkurve to plot these two light curves over each other to see the difference.

# First define the `matplotlib.pyplot.axes`
ax = flat_lc.plot()

# Pass that axis to the next plot
masked_lc.plot(ax=ax, label='masked');

This looks much better. Now we might want to clip out some outliers from the light curve. We can do that with a simple Lightkurve function remove_outliers().

Remove outliers

clipped_lc = masked_lc.remove_outliers(sigma=6)
clipped_lc.plot();

Finally, let’s use Lightkurve to fold the data at the exoplanet orbital period and see if we can detect the transit.

Folding the light curve and finding the transit

From the Pi Mensae paper, we know that planet c has a period of 6.27 days. We can use the fold() function to find the transit in our data as shown below.

folded_lc = clipped_lc.fold(period=6.27, epoch_time=1325.504)
folded_lc.plot();

It looks like there’s something there, but it’s hard to see. Let’s bin the light curve to reduce the number of points, but also reduce the uncertainty of those points.

Binning the light curve

import astropy.units as u
binned_lc = folded_lc.bin(time_bin_size=5*u.minute)
binned_lc.errorbar();

And now we can see the transit of Pi Mensae c!

2. Creating a light curve using FFI data

In our previous FFI search, we found that Pi Men was observed in Sector 1 with a 30-min cadence. This data is stored as the 1st argument of the search_ffi array.

To create the light curve from the FFI data, we must first download the relevant images. Note that we do not want the entirety of the Sector 1 FFI, only a small region surrounding our object of interest. We can specify the size of the region we want to cut out using the commands below, in this case we want a 10x10 pixel region.

ffi_data = search_ffi[0].download(cutout_size=10)

Let’s now see what this cut out looks like and also check that our object is at the center of it.

ffi_data.plot()
<matplotlib.axes._subplots.AxesSubplot at 0x7fb0945b2190>

The above figure indicates the pixels on the CCD camera, with which Pi Men was observed. The color indicates the amount of flux in each pixel, in electrons per second. The y-axis shows the pixel row, and the x-axis shows the pixel column. The title tells us the TESS Input Catalogue (TIC) identification number of the target, and the observing cadence of this image. By default, plot() shows the first observation cadence in the Sector.

It looks like our star is isolated, so we can extract a light-curve by simply summing up all the pixel values in each image. To do this, we need to first define an aperture mask.

Many decisions go into the choice of aperture mask, including the significant blending of the large TESS pixels. In this tutorial, we are going to define an aperture by defining a median flux value and only selecting pixels at a certain sigma above that threshold.

In most situations, a threshold mask will be the best choice for custom aperture photometry, as it doesn’t involve trial and error beyond finding the best sigma value. You can define a threshold mask using the following code:

target_mask = ffi_data.create_threshold_mask(threshold=10, reference_pixel='center')
n_target_pixels = target_mask.sum()
n_target_pixels
18

This indicates that there are 18 pixels which are above our threshold and so in our mask. We can now check to make sure that our target is covered by this mask using plot.

ffi_data.plot(aperture_mask=target_mask, mask_color='r')
<matplotlib.axes._subplots.AxesSubplot at 0x7fb0d19c3e90>

Nice! We see our target mask centered on the 18 brightest pixels in the center of the image. Let’s see what the light curve looks like. Note that this light curve will be uncorrected for any anomalies or noise, and that the flux is therefore based upon “Simple Aperture Photometry” (SAP).

To create our light curve, we will pass our aperture_mask to the `to_lightcurve <https://docs.lightkurve.org/reference/api/lightkurve.KeplerTargetPixelFile.to_lightcurve.html?highlight=to_lightcurve>`__ function.

ffi_lc = ffi_data.to_lightcurve(aperture_mask=target_mask)

Once again, we can examine the light curve data as a table, but note this time that there is only one flux value and that as default, this is the SAP flux.

ffi_lc
TessLightCurve length=1267 LABEL="" SECTOR=1
timefluxflux_errcentroid_colcentroid_rowcadencenoquality
electron / selectron / spixpix
objectfloat32float32float64float64int64int32
1325.3242611834361316430.7531.3038902282714841630.6385441885782260.6140000474531500
1325.3450943096891316496.031.3046169281005861630.63890532941260.61405826824110
1325.36592743739581316588.12531.305624008178711630.6395243879658260.6136365032178320
1325.3867605664991316589.031.3056488037109381630.6392641770467260.6132488909907530
1325.4075936971316634.12531.3062973022460941630.6403961686917260.6133312424588640
1325.42842682884021316664.87531.3066101074218751630.6403907997208260.6116854318425550
1325.44925996196161316503.2531.3046283721923831630.6404545748724260.610578549298160
1325.4700930964211316347.12531.302801132202151630.6417255479462260.6107426474798770
1325.4909262321021316419.87531.3037490844726561630.6415727513183260.6103441131149380
.....................
1352.9697912637541315211.7531.2922744750976561630.6482825671299260.7321358183268712570
1352.99062424209391315086.2531.290554046630861630.6484335940063260.7330748951589512580
1353.0114572198521315193.7531.291809082031251630.646707975239260.73150081707312590
1353.03229019705711315158.7531.2914199829101561630.648037172556260.7359122238213412600
1353.05312317379551315296.531.2930049896240231630.647094118251260.733320637863312610
1353.07395615006861315088.12531.2903957366943361630.6473270669005260.735159343230812620
1353.09478912593611315222.12531.292188644409181630.6474165571676260.734891574457912630
1353.11562210145141315163.87531.291374206542971630.6464359975553260.734046863907912640
1353.1364550766481315184.12531.2916831970214841630.6479758585133260.734301400514412650
1353.15728805161231315330.87531.2933921813964841630.6465981702963260.7370103590617412660

Let’s now plot this,

ffi_lc.scatter(label="SAP FFI")
<matplotlib.axes._subplots.AxesSubplot at 0x7fb0d1babc50>

We can see that there are problematic data points in this light curve which are probably due to jitter. Once again, we can remove these data points via creating and applying a mask.

mask_ffi = (ffi_lc.time.value < 1346) | (ffi_lc.time.value > 1350)
masked_lc_ffi = ffi_lc[mask_ffi]
masked_lc_ffi.plot()
<matplotlib.axes._subplots.AxesSubplot at 0x7fb0d1bab050>

OK, this looks a bit better but we should also clip the data again.

clipped_ffi = masked_lc_ffi.remove_outliers(sigma=6)
clipped_ffi.plot();

Looking at the above light curve, we can see that there are still a few odd trends that need to be addressed, but there is also strong evidence for the previously observed transit! We can try to clean up our data a little using Lightkurve’s built in corrector class functions. These functions are very useful for removing scattered light and other effects. You can learn more about them here.

In this example, we are going to use the Pixel Level Decorrelation (PLD) Corrector (PLDCorrect). The PLD method has primarily been used to remove systematic trends introduced by small spacecraft motions during observations and has been shown to be successful at improving the precision of data taken by the Spitzer space telescope. PLD works by identifying a set of trends in the pixels surrounding the target star and performing linear regression to create a combination of these trends that effectively models the systematic noise introduced by spacecraft motion. This noise model is then subtracted from the uncorrected light curve. We can apply it to our data using the code shown below.

from lightkurve.correctors import PLDCorrector
pld = PLDCorrector(ffi_data[mask_ffi], aperture_mask=target_mask)
pld.correct(pca_components=3)
pltAxis = pld.diagnose()

corrected_ffi = pld.correct(pca_components=3)

The above plots indicate the corrections applied to our light curve. It removed a background and applied a spline; outliers are also presented. Let’s now plot up our corrected light curve and compare to the corrected flux to the non-corrected flux.

ax = ffi_lc.plot(normalize=True, label="SAP FFI");
corrected_ffi.remove_outliers().plot(ax=ax,normalize=True,label="SAP FFI corrected")
plt.ylim(0.9975,1.0025)
(0.9975, 1.0025)

We can see that the corrector removed a lot of the trends that we were seeing. Let’s now proceed as we did before and compare the results. First we need to flatten().

ffi_flat_lc = corrected_ffi.flatten(window_length=1001)
ffi_flat_lc.plot()
<matplotlib.axes._subplots.AxesSubplot at 0x7fb09473f4d0>

Now we need to fold().

folded_ffi = ffi_flat_lc.fold(period=6.27, epoch_time=1325.504)
folded_ffi.plot()
plt.ylim(0.999,1.001)
(0.999, 1.001)

It is a little noiser than before and a bit more difficult to see due to the longer cadence (30-min), but we can clearly make out the transit again. Let’s compare this to our earlier light curve.

ax = folded_lc.plot(label="LightCurve Object")
folded_ffi.plot(ax=ax, label="FFI")
<matplotlib.axes._subplots.AxesSubplot at 0x7fb0a1d59890>

Great! The transit is shown in both cases. It is clear more work needs to be done on the FFI to remove noise and instrumental trends from the data, but this is a good start!

Additional Resources

In this tutorial, we have covered the basics of how to obtain, reduce and analyze TESS data using Lightkurve. We have, however, only skimmed the surface of what Lightkurve can do and how to investigate the data. For more detailed tutorials as well as other useful tools, please visit the following pages.

  • Lightkurve Tutorials page: A set of 21 tutorials dealing with Kepler/K2 and TESS data
  • TESS GI data products page: A set of 7 TESS specific tutorials.
  • STScI Kepler K3 notebooks: A set of notebooks produced by a collaboration between NumFocus, MAST, Lightkurve, and TESS GI office. They make use of python astronomical data packages to demonstrate how to analyze time series data from these NASA missions. New tools are presented here and also techniques for the advanced user.

Authors

Rebekah Hounsell (with help from the Lightkurve Collaboration, 2018) - Support scientist for TESS in the NASA GSFC GI Office. For more help with TESS data, please contact us at tesshelp@bigbang.gsfc.nasa.gov.