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

TESS Intro

An introduction into the tools and tutorials available for the analysis of TESS data

Welcome everyone to our TESS Lightkurve tutorial!

Authors

Rebekah Hounsell - Support scientist for TESS in the NASA GSFC GI Office.

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 NASA Exoplanet mission TESS (this can also be applied to Kepler & K2). All tools presented will teach the user how to work with time series data for the purpose of scientific research.

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

  1. How to obtain TESS data products from the MAST archive
  2. How to use Lightkurve to access the various data products and create time series
  3. How to analyze and assess various data anomalies and how you might visualize them

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 that 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

This downloads the Lightkurve package.

Introduction to TESS:

The Transiting Exoplanet Survey Satellite (TESS) is a NASA-sponsored Astrophysics Explorer-class mission that is performing a near all-sky survey to search for planets transiting nearby stars. TESS completed its primary mission in July of 2020, and has now entered its extended mission. The current extended mission will last until September 2022, and will continue to scan the sky for exoplanets and transient events. The TESS mission is now more community focused with a larger guest investigator (GI) program.

Over the last three years TESS has observed both the northern and southern hemispheres, with each hemisphere being split into ~13 sectors. Each sector is observed for ~27 days by TESS’s four cameras.

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.

1. How to obtain TESS data products from the MAST archive

You can access TESS, Kepler, and K2 data via the Mikulksi Archive for Space Telescopes (MAST) archive or via the Lightkurve package (see Section 2).

Here, we are focusing on obtaining your data via the MAST portal. Using the portal, you can enter the name of your object, its TIC number, or position (i.e., R.A and Dec). If listed in the archive, the table containing each observation will be returned.

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

Lightkurve offers a user-friendly way to analyze time series data obtained by telescopes, in particular NASA’s Kepler and TESS exoplanet missions. You can search for the various data products for TESS on MAST using the following Lightkurve functions:

For the purpose of this tutorial, we will be examining L 98-59, a bright M dwarf star at a distance of 10.6 pc. This star is host to three terrestrial-sized planets and is also known in the TESS system as TIC 307210830.

2.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('L 98-59')
search_tpf = lk.search_targetpixelfile('L 98-59')
search_lcf = lk.search_lightcurve('L 98-59')
search_ffi
SearchResult containing 15 data products.
#missionyearauthorexptimetarget_namedistance
sarcsec
0TESS Sector 012018TESScut1426L 98-590.0
1TESS Sector 022018TESScut1426L 98-590.0
2TESS Sector 052018TESScut1426L 98-590.0
3TESS Sector 082019TESScut1426L 98-590.0
4TESS Sector 092019TESScut1426L 98-590.0
5TESS Sector 102019TESScut1426L 98-590.0
6TESS Sector 112019TESScut1426L 98-590.0
7TESS Sector 122019TESScut1426L 98-590.0
8TESS Sector 282020TESScut475L 98-590.0
9TESS Sector 292020TESScut475L 98-590.0
10TESS Sector 322020TESScut475L 98-590.0
11TESS Sector 352021TESScut475L 98-590.0
12TESS Sector 362021TESScut475L 98-590.0
13TESS Sector 372021TESScut475L 98-590.0
14TESS Sector 382021TESScut475L 98-590.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 years 1 and 2 (2018 & 2019) that the cadence of the FFI data was 30-min, but in year 3 (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 28 data products.
#missionyearauthorexptimetarget_namedistance
sarcsec
0TESS Sector 022018SPOC1203072108300.0
1TESS Sector 022018TESS-SPOC18003072108300.0
2TESS Sector 052018SPOC1203072108300.0
3TESS Sector 052018TESS-SPOC18003072108300.0
4TESS Sector 082019SPOC1203072108300.0
5TESS Sector 092019SPOC1203072108300.0
6TESS Sector 102019SPOC1203072108300.0
7TESS Sector 112019SPOC1203072108300.0
8TESS Sector 122019SPOC1203072108300.0
9TESS Sector 282020SPOC203072108300.0
.....................
18TESS Sector 352021SPOC203072108300.0
19TESS Sector 352021SPOC1203072108300.0
20TESS Sector 362021SPOC203072108300.0
21TESS Sector 362021SPOC1203072108300.0
22TESS Sector 372021SPOC203072108300.0
23TESS Sector 372021SPOC1203072108300.0
24TESS Sector 382021SPOC203072108300.0
25TESS Sector 382021SPOC1203072108300.0
26TESS Sector 392021SPOC203072108300.0
27TESS Sector 392021SPOC1203072108300.0
Length = 28 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 38 data products.
#missionyearauthorexptimetarget_namedistance
sarcsec
0TESS Sector2018DIAMANTE18003072108300.0
1TESS Sector 022018SPOC1203072108300.0
2TESS Sector 022018TESS-SPOC18003072108300.0
3TESS Sector 022018QLP18003072108300.0
4TESS Sector 022018TASOC1203072108300.0
5TESS Sector 022018TASOC18003072108300.0
6TESS Sector 052018SPOC1203072108300.0
7TESS Sector 052018TESS-SPOC18003072108300.0
8TESS Sector 052018QLP18003072108300.0
9TESS Sector 082019SPOC1203072108300.0
.....................
28TESS Sector 352021SPOC203072108300.0
29TESS Sector 352021SPOC1203072108300.0
30TESS Sector 362021SPOC203072108300.0
31TESS Sector 362021SPOC1203072108300.0
32TESS Sector 372021SPOC203072108300.0
33TESS Sector 372021SPOC1203072108300.0
34TESS Sector 382021SPOC203072108300.0
35TESS Sector 382021SPOC1203072108300.0
36TESS Sector 392021SPOC203072108300.0
37TESS Sector 392021SPOC1203072108300.0
Length = 38 rows

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

2.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 the purpose of 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('L 98-59', author="SPOC", exptime=120)
search_lcf_refined
SearchResult containing 15 data products.
#missionyearauthorexptimetarget_namedistance
sarcsec
0TESS Sector 022018SPOC1203072108300.0
1TESS Sector 052018SPOC1203072108300.0
2TESS Sector 082019SPOC1203072108300.0
3TESS Sector 092019SPOC1203072108300.0
4TESS Sector 102019SPOC1203072108300.0
5TESS Sector 112019SPOC1203072108300.0
6TESS Sector 122019SPOC1203072108300.0
7TESS Sector 282020SPOC1203072108300.0
8TESS Sector 292020SPOC1203072108300.0
9TESS Sector 322020SPOC1203072108300.0
10TESS Sector 352021SPOC1203072108300.0
11TESS Sector 362021SPOC1203072108300.0
12TESS Sector 372021SPOC1203072108300.0
13TESS Sector 382021SPOC1203072108300.0
14TESS Sector 392021SPOC1203072108300.0

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

lcf = search_lcf_refined.download_all()
lcf
LightCurveCollection of 15 objects:
    0: <TessLightCurve LABEL="TIC 307210830" SECTOR=2 AUTHOR=SPOC FLUX_ORIGIN=pdcsap_flux>
    1: <TessLightCurve LABEL="TIC 307210830" SECTOR=5 AUTHOR=SPOC FLUX_ORIGIN=pdcsap_flux>
    2: <TessLightCurve LABEL="TIC 307210830" SECTOR=8 AUTHOR=SPOC FLUX_ORIGIN=pdcsap_flux>
    3: <TessLightCurve LABEL="TIC 307210830" SECTOR=9 AUTHOR=SPOC FLUX_ORIGIN=pdcsap_flux>
    4: <TessLightCurve LABEL="TIC 307210830" SECTOR=10 AUTHOR=SPOC FLUX_ORIGIN=pdcsap_flux>
    5: <TessLightCurve LABEL="TIC 307210830" SECTOR=11 AUTHOR=SPOC FLUX_ORIGIN=pdcsap_flux>
    6: <TessLightCurve LABEL="TIC 307210830" SECTOR=12 AUTHOR=SPOC FLUX_ORIGIN=pdcsap_flux>
    7: <TessLightCurve LABEL="TIC 307210830" SECTOR=28 AUTHOR=SPOC FLUX_ORIGIN=pdcsap_flux>
    8: <TessLightCurve LABEL="TIC 307210830" SECTOR=29 AUTHOR=SPOC FLUX_ORIGIN=pdcsap_flux>
    9: <TessLightCurve LABEL="TIC 307210830" SECTOR=32 AUTHOR=SPOC FLUX_ORIGIN=pdcsap_flux>
    10: <TessLightCurve LABEL="TIC 307210830" SECTOR=35 AUTHOR=SPOC FLUX_ORIGIN=pdcsap_flux>
    11: <TessLightCurve LABEL="TIC 307210830" SECTOR=36 AUTHOR=SPOC FLUX_ORIGIN=pdcsap_flux>
    12: <TessLightCurve LABEL="TIC 307210830" SECTOR=37 AUTHOR=SPOC FLUX_ORIGIN=pdcsap_flux>
    13: <TessLightCurve LABEL="TIC 307210830" SECTOR=38 AUTHOR=SPOC FLUX_ORIGIN=pdcsap_flux>
    14: <TessLightCurve LABEL="TIC 307210830" SECTOR=39 AUTHOR=SPOC FLUX_ORIGIN=pdcsap_flux>

This has downloaded the light curve 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 2 as a table.

lcf[0]
TessLightCurve length=18300 LABEL="TIC 307210830" SECTOR=2 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
1354.10741134102452.4635420e+041.8856627e+01-8.0586493e-0491190664.04462338.976442.3127123e+041.7658133e+011.8465968e+035.2003989e+002.4635420e+041.8856627e+010nannannannan664.044626.2346959e-04338.976446.9568102e-043.1294446e-021.5483069e-01
1354.10880020247442.4656008e+041.8861403e+01-8.0589182e-0491191664.05609338.969002.3150639e+041.7662607e+011.8428802e+035.1911125e+002.4656008e+041.8861403e+010nannannannan664.056096.2315754e-04338.969006.9629494e-044.3172963e-021.4587776e-01
1354.1101890638662.4635619e+041.8864876e+01-8.0591877e-0491192664.07351338.958142.3137189e+041.7665859e+011.8525369e+035.2004828e+002.4635619e+041.8864876e+010nannannannan664.073516.2400498e-04338.958146.9669099e-046.0803384e-021.3428329e-01
1354.11296678676352.4621027e+041.8853863e+01-8.0597255e-0491194664.05132338.948852.3098303e+041.7655546e+011.8542960e+035.2071209e+002.4621027e+041.8853863e+010nannannannan664.051326.2639196e-04338.948856.9927127e-043.7734102e-021.2694269e-01
1354.11435564821342.4617400e+041.8859161e+01-8.0599944e-0491195664.09017338.975382.3127893e+041.7660507e+011.8433275e+035.1999226e+002.4617400e+041.8859161e+010nannannannan664.090176.2417402e-04338.975386.9604575e-047.8965843e-021.5301819e-01
1354.11574450972152.4630531e+041.8860582e+01-8.0602628e-0491196664.08357338.964492.3136076e+041.7661839e+011.8441443e+035.1992383e+002.4630531e+041.8860582e+010nannannannan664.083576.2411965e-04338.964496.9649977e-047.2042428e-021.4030553e-01
1354.1171333711712.4625502e+041.8855038e+01-8.0605317e-0491197664.08138338.962442.3130492e+041.7656647e+011.8393002e+035.1891294e+002.4625502e+041.8855038e+010nannannannan664.081386.2480610e-04338.962446.9642899e-046.8586096e-021.3917884e-01
1354.1185222326782.4619252e+041.8856379e+01-8.0608000e-0491198664.07300338.957762.3123014e+041.7657902e+011.8428878e+035.1969514e+002.4619252e+041.8856379e+010nannannannan664.073006.2365801e-04338.957766.9719343e-046.0448773e-021.3230386e-01
1354.11991109412752.4591127e+041.8846928e+01-8.0610689e-0491199664.07806338.960292.3098383e+041.7649052e+011.8459741e+035.1905088e+002.4591127e+041.8846928e+010nannannannan664.078066.2481815e-04338.960296.9739192e-046.4667158e-021.3584568e-01
........................................................................
1381.5000762208806nannan-1.1857160e-03110913664.02023338.822382.3102398e+041.8364481e+013.0264915e+036.2652044e+00nannan1000000000000000nannannannan664.020236.5423414e-04338.822387.4187893e-045.3329854e-03-1.7557999e-02
1381.5014650890794nannan-1.1857362e-03110914664.02570338.818282.3131156e+041.8370392e+013.0202869e+036.2575917e+00nannan1000000000000000nannannannan664.025706.5429986e-04338.818287.4093667e-041.0951885e-02-1.8822383e-02
1381.5028539571613nannan-1.1857564e-03110915664.02563338.821312.3093904e+041.8351555e+013.0234182e+036.2496614e+00nannan1000000000000000nannannannan664.025636.5500144e-04338.821317.4103329e-049.7870119e-03-1.7654052e-02
1381.50424282536nannan-1.1857765e-03110916664.01844338.826362.3070465e+041.8338472e+013.0037410e+036.2505035e+00nannan1000000000000000nannannannan664.018446.5486954e-04338.826367.4021460e-042.8580690e-03-1.0282305e-02
1381.5056316934429nannan-1.1857968e-03110917664.02351338.815382.3084883e+041.8339640e+013.0044412e+036.2367158e+00nannan1000000000000000nannannannan664.023516.5468432e-04338.815387.4014551e-048.9326696e-03-2.2021463e-02
1381.507020561642nannan-1.1858169e-03110918664.02287338.812232.3056941e+041.8327822e+013.0007908e+036.2351022e+00nannan1000000000000000nannannannan664.022876.5470359e-04338.812237.4105512e-047.0573296e-03-2.6359776e-02
1381.5084094298413nannan-1.1858371e-03110919664.02458338.810352.3082803e+041.8332623e+012.9834062e+036.2297935e+00nannan1000000000000000nannannannan664.024586.5470277e-04338.810357.4060517e-049.5733264e-03-2.9673917e-02
1381.5097982979241nannan-1.1858573e-03110920664.01752338.821692.3091609e+041.8332087e+012.9773435e+036.2250428e+00nannan1000000000000000nannannannan664.017526.5375940e-04338.821697.3996367e-043.0533469e-03-1.5633952e-02
1381.5111871661225nannan-1.1858775e-03110921664.02862338.813182.3086258e+041.8320450e+012.9649575e+036.2088137e+00nannan1000000000000000nannannannan664.028626.5425027e-04338.813187.3958829e-041.3605391e-02-2.5300540e-02
1381.5125760342053nannan-1.1858977e-03110922664.01887338.819822.3105682e+041.8324867e+012.9604985e+036.2097011e+00nannan1000000000000000nannannannan664.018876.5310486e-04338.819827.3841790e-043.2073301e-03-1.8903004e-02

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 in spite of 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 are caused by scattered light and other noise issues. For more information refer to these tutorials. For now, let’s think about how we can manipulate the light curves.

2.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 lets stick with the PDCSAP flux.

ax = lcf[0].plot()
ax.set_title("PDCSAP light curve of  L 98-59")
Text(0.5, 1.0, 'PDCSAP light curve of  L 98-59')
Flattening
flat_lc = lcf[0].flatten(window_length=401)
flat_lc.plot();
Folding the light curve

From the L 98-59 System paper, we know that planet c has a period of 3.690621 days. We can use the fold() function to find the transit in our data as shown below.

folded_lc = flat_lc.fold(period=3.690621)
folded_lc.plot();
Binning the light curve

Often, to see a trend, it can be beneficial to bin the data, this can be achieved via the bin() function.

binned_lc = folded_lc.bin(time_bin_size=0.01)
binned_lc.plot();

Great, we can now see our transit very clearly! Note that we can achieve the same plot from our data using one line of code instead of several, see below.

lcf[0].flatten(window_length=401).fold(period=3.690621).bin(time_bin_size=0.01).plot();

Interact with your light curve

There is also an interactive tool for light curves called .interact_bls. Box Least Squares (BLS), is a method for identifying transit signals in a light curve.

The .interact_bls method allows you to identify periodic transit signals in light curves by manually selecting the period and duration of the signal.

lcf[0].interact_bls()

The light curve in the top right panel is phase-folded with the highest power period. When you zoom in on a region of period space in the BLS periodogram, it will automatically update the phase plot with the new period-at-max-power. Changing the duration using the slider in the bottom left will also update the BLS periodogram and phase-folded light curve. Finally, the parameters of the BLS model can be found in the bottom right panel.

What if your object is not a target of interest but simply observed within the full framed images? You can still extract the data and create a 30-min or 10-min cadenced light curve.

2.3 Creating a light curve using FFI data:

In our previous FFI search, we found that L 98-59 was observed in Sector 2 with a 30-min cadence. This data is stored as the 2nd 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 2 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[1].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 0x7f84b36fd0d0>

The above figure indicates the pixels on the CCD camera, with which L 98-59 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=15, reference_pixel='center')
n_target_pixels = target_mask.sum()
n_target_pixels
9

This indicates that there are 9 pixels which are above our threshold and 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');

Nice! We see our target mask centered on the 9 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=1196 LABEL="" SECTOR=2
timefluxflux_errcentroid_colcentroid_rowcadencenoquality
electron / selectron / spixpix
objectfloat32float32float64float64int64int32
1354.135510003746520954.4316406253.968478202819824664.053236257685338.87095333074400
1354.156343038585920953.6406253.9688515663146973664.0529987132587338.8700375009414610
1354.17717607517120948.378906253.9678900241851807664.0535754626561338.869624026974820
1354.198009113502420953.167968753.9682953357696533664.053397969705338.8693846242112530
1354.21884215352220949.621093753.9680519104003906664.05334777157338.8684210544716440
1354.23967519517120950.8417968753.9680023193359375664.0529491917277338.868032471565950
1354.26050823842120944.6406253.9673573970794678664.0522733076061338.8666756235000460
1354.281341283271620952.730468753.9680874347686768664.0519973612013338.8666619072245770
1354.30217432966520949.457031253.9677042961120605664.0511057724311338.865922418186280
.....................
1381.301885439133521803.316406254.048139572143555664.009622243243338.780406684028311860
1381.322718514969421763.57031254.044528007507324664.0098234495485338.778343374661711870
1381.343551590224521740.9707031254.0420989990234375664.010488493472338.780330198590911880
1381.36438466489721700.60156254.038733005523682664.0101843813644338.7784446094704511890
1381.38521773904521676.363281254.036615371704102664.0108564056399338.778520735792111900
1381.406050812610821656.9218754.034541606903076664.0106157420802338.77729664817411910
1381.426883885711521613.628906254.0302863121032715664.0110574507974338.7774051257805511920
1381.44771695834721571.4042968754.026115417480469664.0115646734967338.7774478025786511930
1381.46855003057421527.718754.021993160247803664.0113081777426338.7761257470383511940
1381.489383102394621476.5156254.017423152923584664.0124305558461338.775308394634511950

Let’s now plot this.

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

Looking at the above light curve, we can see two dominant peaks and observe that the flux in the aperture is dominated by what is known as scattered light. We can tell this because TESS orbits Earth twice in each sector, thus patterns which appear twice within a sector are typically related to TESS’ orbit (such as the scattered light effect).

We will discuss this issue in more detail below.

3. How to analyze and assess various data anomalies and how you might visualize them

Lets take a look at the SAP light curves derived from our FFI data and the PDCSAP light curve derived from our Light Curve File.

ax = lcf[0].plot(column='pdcsap_flux', normalize=True, label="PDCSAP");
ffi_lc.plot(ax=ax, normalize=True, label="SAP FFI")
<matplotlib.axes._subplots.AxesSubplot at 0x7f849105ccd0>

Looking at the figure above, you can see that the SAP light curve has a long-term change in brightness that has been removed in the PDCSAP light curve, while keeping the transits at the same depth. For most inspections, a PDCSAP light curve is what you want to use, but when looking at astronomical phenomena that aren’t planets (e.g. long-term variability), the SAP flux may be preferred.

The primary source of noise removed from the SAP light curve is that of scattered light. Each of TESS’s cameras has a lens hood to reduce the scattered light from the Earth and the Moon. Due to TESS’s wide field of view and the physical restrictions of the Sun shade, the lens hood is not 100% efficient. The effect of the scattered light on the CCD’s can be seen in this video.

Interactive inspection:

By interactively inspecting the area around your object of interest, you can see when scattered light comes into play, and also how it effects the light curve. To do this, we use the interact() function.

ffi_data.interact()

You can move the large bottom left slider to change the location of the vertical red bar, which indicates which cadence is being shown in the TPF postage stamp image. The slider beneath the TPF postage stamp image controls the screen stretch, which defaults to logarithmic scaling initialized to 1% and 95% lower and upper limits respectively.

You can move your cursor over individual data points to show hover-over tooltips indicating additional information about that datum. Currently, the tooltips list the cadence, time, flux, and quality flags. The tools on the right hand side of the plots enable zooming and pixel selection.

Interaction modes:

  • Clicking on a single pixel shows the time series light curve of that pixel alone.
  • Shift-clicking on multiple pixels shows the light curve using that pixel mask.
  • Shift-clicking on an already selected pixel will deselect that pixel.
  • Clicking and dragging a box will make a rectangular aperture mask — individual pixels can be deselected from this mask by shift-clicking (box deselecting does not work).
  • The screen stretch high and low limits can be changed independently by clicking and dragging each end, or simultaneously by clicking and dragging in the middle.
  • The cadence slider updates the postage stamp image at the position of the vertical red bar in the light curve.
  • Clicking on a position in the light curve automatically seeks to that cadence number.
  • The left and right arrows can be clicked to increment the cadence number by one.
  • The interact() tool works for TESS data and Kepler/K2.

This tool can also be used to see how crowded the field of your sources is and if anything else unusual happened during observation.

Interact Sky:

Lightkurve has an additional tool to interactively inspect target pixel files — .interact_sky. This method brings up a single frame of the target pixel file with targets identified by Gaia marked by red circles. The size of the circle scales with the magnitude of the target, where brighter sources are larger and fainter sources are smaller. Using your cursor, you can hover over the red circles to display useful information from Gaia, including its Gaia ID, G band magnitude, and coordinates.

ffi_data.interact_sky()
/Users/rhounsel/opt/anaconda3/envs/astroconda/lib/python3.7/site-packages/lightkurve/interact.py:517: LightkurveWarning: Proper motion correction cannot be applied to the target, as none is available. Thus the target (the cross) might be noticeably away from its actual position, if it has large proper motion.
  category=LightkurveWarning)

This tool is useful for crowded sources.

Cadence Quality Flags:

The TESS pipeline populates a series of quality flags to indicate when a cadence may have been taken during an anomalous event. These flags are available in the Light Curve Files, the Target Pixel Files, and a subset are available for the FFIs.

Aperture Mask Image Flags:

The Light Curve Files and Target Pixel Files contain an image in the APERTURE FITS extension that describes how each pixel was used in the processing.

Tables of these flags can be found here, where a description of each flag is provided.

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 techniques for the advanced user.