LightCurveFile Objects

Understanding LightCurveFile objects

Learning goals

In our LightCurve object tutorial we looked at how to obtain an object of interests light curve from its TargetPixelFile (TPF; see our TargetPixelFile tutorial) using Simple Aperture Photometry (SAP).

In this tutorial we will demonstrate the difference between a TESSLightCurve and a TESSLightCurveFile, and will cover the following, - What is a LightCurveFile. - What is Pre-search Data Conditioning SAP flux (PSDCSAP). - How can we examine its metadata. - How we use it to create and examine an objects light curve.

What is a LightCurveFile object?

Rather than being generated via a TPF, TESSLightCurveFile objects have been pre-generated using NASA’s Data Processing Pipeline. Usually, you will access these files through the MAST archive.

What is Pre-search Data Conditioning SAP flux?

TESSLightCurveFile objects have some level of processing (more details here) and allow you to access the two kinds of flux; the Simple Aperture Photometry flux (SAP) flux as discussed in the LightCurve object tutorial, and the Pre-search Data Conditioning SAP flux (PDCSAP) flux. With PDCSAP flux long term trends have been removed from the data using so-called Co-trending Basis Vectors (CBVs). PDCSAP flux is usually cleaner data than the SAP flux and will have fewer systematic trends.

Imports

This tutorial requires that you import lightkurve

%matplotlib inline
import lightkurve as lk

Defining terms

  • Target Pixel File (TPF): A file containing the original CCD pixel observations from which light curves are extracted.
  • LightCurve Object: Obtained from a TPF and contains light curve information derived using simple aperture photometry.
  • LightCurveFile Object: Obtained from MAST and contains both SAP flux and PSDCSAP flux.
  • Cadence: The rate at which TESS photometric observations are stored.
  • Sector: One of TESS’s 27 (to date) observing periods, approximately ~27 days in duration.
  • Simple Aperture Photometry (SAP): The act of summing all pixel values in a pre-defined aperture as a function of time.
  • 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.

Downloading the data

We can read in a light curve file from the TESS mission using TESSLightCurveFile. We can use the search_lightcurve() function to fetch the files from the data archive.

To demonstrate, lets use the L 98-59 System again, focusing on planet c.

search_result = lk.search_lightcurve('TIC 307210830 c')
search_result
SearchResult containing 7 data products.
#observationauthortarget_nameproductFilenamedistance
0TESS Sector 2SPOC307210830tess2018234235059-s0002-0000000307210830-0121-s_lc.fits0.0
1TESS Sector 5SPOC307210830tess2018319095959-s0005-0000000307210830-0125-s_lc.fits0.0
2TESS Sector 8SPOC307210830tess2019032160000-s0008-0000000307210830-0136-s_lc.fits0.0
3TESS Sector 9SPOC307210830tess2019058134432-s0009-0000000307210830-0139-s_lc.fits0.0
4TESS Sector 10SPOC307210830tess2019085135100-s0010-0000000307210830-0140-s_lc.fits0.0
5TESS Sector 11SPOC307210830tess2019112060037-s0011-0000000307210830-0143-s_lc.fits0.0
6TESS Sector 12SPOC307210830tess2019140104343-s0012-0000000307210830-0144-s_lc.fits0.0

The search_lightcurve function takes several additional arguments, such as the sector number or the mission name. You can find examples of its use in the online documentation.

Like search_targetpixelfile the search_lightcurve function returns a SearchResult object which has several convenient operations. For example, we can select the first data product in the list as follows,

search_result[0]
SearchResult containing 1 data products.
#observationauthortarget_nameproductFilenamedistance
0TESS Sector 2SPOC307210830tess2018234235059-s0002-0000000307210830-0121-s_lc.fits0.0

We can download this data product using the download() method:

lcf = search_result[0].download()

The lcf variable we have obtained in this way is a TessLightCurve object. This object contains time, flux and flux error information, as well as a whole lot of data about spacecraft systematics. We can view all of them by calling the object by itself:

lcf
TessLightCurve targetid=307210830 length=18317
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.10882312724272.4311873e+041.8769577e+01-8.0589490e-0491191664.10903338.976422.1566352e+041.6472113e+011.3385229e+033.5451272e+002.4311873e+041.8769577e+010nannannannan664.109035.8178976e-04338.976426.0455920e-044.8032869e-021.4890091e-01
1354.11021198889942.4297582e+041.8773235e+01-8.0592179e-0491192664.12611338.968392.1563889e+041.6475323e+011.3444882e+033.5518360e+002.4297582e+041.8773235e+010nannannannan664.126115.8167754e-04338.968396.0535187e-046.5402389e-021.3844931e-01
1354.1129897121532.4282812e+041.8741255e+01-8.0597564e-0491194664.10668338.960492.1475160e+041.6447256e+011.3468779e+033.5524495e+002.4282812e+041.8741255e+010nannannannan664.106685.8500003e-04338.960496.0745567e-044.0374711e-021.3017291e-01
1354.11437857380972.4275164e+041.8781441e+01-8.0600253e-0491195664.14148338.983282.1583307e+041.6482523e+011.3438405e+033.5524592e+002.4275164e+041.8781441e+010nannannannan664.141485.8221997e-04338.983286.0431601e-048.0888584e-021.5741505e-01
1354.11576743552432.4288371e+041.8776447e+01-8.0602936e-0491196664.13548338.973582.1575641e+041.6478142e+011.3419084e+033.5480881e+002.4288371e+041.8776447e+010nannannannan664.135485.8233330e-04338.973586.0483697e-047.4183472e-021.4472328e-01
1354.11715629718042.4280523e+041.8768578e+01-8.0605625e-0491197664.13351338.972142.1563102e+041.6471235e+011.3378163e+033.5436206e+002.4280523e+041.8768578e+010nannannannan664.133515.8274117e-04338.972146.0512009e-047.1515344e-021.4336312e-01
1354.11854515889472.4286711e+041.8765480e+01-8.0608309e-0491198664.12517338.966752.1552936e+041.6468515e+011.3372028e+033.5442295e+002.4286711e+041.8765480e+010nannannannan664.125175.8198441e-04338.966756.0517463e-046.5269679e-021.3618952e-01
1354.11993402055152.4255619e+041.8757978e+01-8.0610998e-0491199664.13023338.969952.1532902e+041.6461933e+011.3415085e+033.5453105e+002.4255619e+041.8757978e+010nannannannan664.130235.8275240e-04338.969956.0552283e-046.8680957e-021.3969450e-01
1354.12132288226672.4262840e+041.8758078e+01-8.0613681e-0491200664.12622338.965542.1533828e+041.6462021e+011.3382404e+033.5454845e+002.4262840e+041.8758078e+010nannannannan664.126225.8211992e-04338.965546.0527271e-046.5827116e-021.3609535e-01
........................................................................
1381.50010325232942.4288518e+041.9145361e+01-1.1857213e-03110913664.07445338.851332.1262494e+041.6801899e+012.1153037e+034.2768788e+002.4288518e+041.9145361e+010nannannannan664.074456.0456968e-04338.851336.3469319e-046.7313453e-03-1.7380530e-02
1381.50149212073782.4314963e+041.9157202e+01-1.1857414e-03110914664.07975338.849132.1289830e+041.6812288e+012.1122083e+034.2748408e+002.4314963e+041.9157202e+010nannannannan664.079756.0464692e-04338.849136.3474779e-041.2294311e-02-1.9028442e-02
1381.50288098914582.4287336e+041.9145287e+01-1.1857615e-03110915664.07908338.851372.1266350e+041.6801832e+012.1092537e+034.2716589e+002.4287336e+041.9145287e+010nannannannan664.079086.0521072e-04338.851376.3506985e-041.1281053e-02-1.7392185e-02
1381.50426985743822.4250791e+041.9129375e+01-1.1857818e-03110916664.07296338.855502.1234850e+041.6787870e+012.0995103e+034.2670422e+002.4250791e+041.9129375e+010nannannannan664.072966.0523918e-04338.855506.3468731e-043.6670761e-03-1.0083861e-02
1381.50565872584662.4272904e+041.9130596e+01-1.1858019e-03110917664.07822338.846842.1244951e+041.6788940e+012.0982610e+034.2620702e+002.4272904e+041.9130596e+010nannannannan664.078226.0487830e-04338.846846.3467148e-041.0049758e-02-2.2052733e-02
1381.50704759425552.4244773e+041.9113134e+01-1.1858221e-03110918664.07699338.844202.1210760e+041.6773617e+012.0926931e+034.2577090e+002.4244773e+041.9113134e+010nannannannan664.076996.0498924e-04338.844206.3551613e-047.6570297e-03-2.6143335e-02
1381.5084364625482.4274957e+041.9118402e+01-1.1858423e-03110919664.07860338.842142.1231014e+041.6778240e+012.0832832e+034.2526455e+002.4274957e+041.9118402e+010nannannannan664.078606.0521363e-04338.842146.3519127e-041.0699908e-02-3.0003805e-02
1381.50982533095632.4274902e+041.9122919e+01-1.1858625e-03110920664.07231338.851372.1250465e+041.6782204e+012.0831892e+034.2515340e+002.4274902e+041.9122919e+010nannannannan664.072316.0427783e-04338.851376.3426507e-044.3808916e-03-1.5397585e-02
1381.51121419924882.4265334e+041.9115648e+01-1.1858827e-03110921664.08214338.845212.1236355e+041.6775822e+012.0772075e+034.2467227e+002.4265334e+041.9115648e+010nannannannan664.082146.0488580e-04338.845216.3436205e-041.4993464e-02-2.5431424e-02
1381.51260306765772.4296789e+041.9121765e+01-1.1859029e-03110922664.07292338.849712.1265840e+041.6781191e+012.0722200e+034.2412267e+002.4296789e+041.9121765e+010nannannannan664.072926.0415227e-04338.849716.3310139e-044.4403672e-03-1.8668674e-02

Note that unlike the table generated via a LightCurve Object, this table contains the SAP flux and PDCSAP flux!

Plotting the light curve

Lets now plot the light curve up for the object.

lcf.plot();

SAP and PDCSAP light curves

By default, a TESSLightCurveFiles will set the PDCSAP flux to its .flux property.

To compare the PDCSAP and the SAP flux, we can use the column keyword while plotting.

Note: alternatively, you can replace the flux column with the sap_flux column by using `lcf.flux = lcf[‘sap_flux’]

ax = lcf.plot(label='PDCSAP Flux', normalize=True)
lcf.plot(column='sap_flux', normalize=True, label='SAP Flux', ax=ax);

In brief:

  • 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 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.
  • The PDCSAP light curve is subject to more treatment than the SAP light curve, and is specifically intended for detecting planets. The PDCSAP pipeline attempts to remove systematic artifacts while keeping planetary transits intact.

Looking at the Figure we made 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.

You can switch between fluxes using the following commands,

pdcsap = lcf.flux

sap =lcf.sap_flux

For now, let’s continue to use the PDCSAP flux only. Because this is the default .flux property of our light curve object, we don’t need to change anything.

Note

The plot() methods in Lightkurve always return a Matplotlib object. This is useful because it lets us manipulate the plot using standard Matplotlib functions. For example, we can set the title as follow:

ax = lcf.plot()
ax.set_title("PDCSAP light curve of  L 98-59")
Text(0.5, 1.0, 'PDCSAP light curve of  L 98-59')

Now lets fold and bin our data to look at the transit as we did in the LightCurve object tutorial. Remember the lcf.flux default is the PDCSAP flux this time!

lcf.remove_nans().flatten(window_length=401).fold(period=3.690621,  epoch_time=1367.2755).bin(time_bin_size=0.025).plot();

Metadata

You can check the meta data and the CDPP noise metric of the TESSLightCurveFile as we have in the past.

lcf.meta
{'inherit': True,
 'extname': 'PRIMARY',
 'extver': 1,
 'simdata': False,
 'telescop': 'TESS',
 'instrume': 'TESS Photometer',
 'object': 'TIC 307210830',
 'ticid': 307210830,
 'radesys': 'ICRS',
 'ra_obj': 124.5319,
 'dec_obj': -68.313,
 'equinox': 2000.0,
 'exposure': 21.710393585867,
 'timeref': 'SOLARSYSTEM',
 'tassign': 'SPACECRAFT',
 'timesys': 'TDB',
 'bjdrefi': 2457000,
 'bjdreff': 0.0,
 'timeunit': 'd',
 'telapse': 27.412113113468,
 'livetime': 21.71039358586663,
 'tstart': 1354.101978098092,
 'tstop': 1381.514471377755,
 'date-obs': '2018-08-23T14:25:41.724Z',
 'date-end': '2018-09-20T00:19:41.143Z',
 'deadc': 0.792,
 'timepixr': 0.5,
 'tierrela': 1.16e-05,
 'int_time': 1.98,
 'readtime': 0.02,
 'frametim': 2.0,
 'num_frm': 60,
 'timedel': 0.001388888888888889,
 'backapp': True,
 'deadapp': True,
 'vignapp': True,
 'gaina': 5.300000190734863,
 'gainb': 5.179999828338623,
 'gainc': 5.269999980926514,
 'gaind': 5.190000057220459,
 'readnoia': 10.017000198364258,
 'readnoib': 7.407399654388428,
 'readnoic': 7.85230016708374,
 'readnoid': 9.964799880981445,
 'nreadout': 48,
 'fxdoff': 209700,
 'cdpp0_5': 264.31433105,
 'cdpp1_0': 202.23320007,
 'cdpp2_0': 159.35473633,
 'crowdsap': 0.99806839,
 'flfrcsap': 0.87759632,
 'nspsddet': 0,
 'nspsdcor': 0,
 'pdcvar': 0.9957757182968056,
 'pdcmethd': 'msMAP',
 'numband': 3,
 'fittype1': 'reducedRobust',
 'pr_good1': 0.9786046743392944,
 'pr_wght1': 0.0,
 'fittype2': 'prior',
 'pr_good2': 0.06772279739379883,
 'pr_wght2': 5.394961833953857,
 'fittype3': 'prior',
 'pr_good3': 0.6207972764968872,
 'pr_wght3': 49.4542121887207,
 'pdc_tot': 0.8734737634658813,
 'pdc_totp': 54.40318298339844,
 'pdc_cor': 0.999976396560669,
 'pdc_corp': 76.24014282226562,
 'pdc_var': 0.9333910942077637,
 'pdc_varp': 23.97138214111328,
 'pdc_noi': 0.5902431607246399,
 'pdc_noip': 59.09120559692383,
 'pdc_ept': 1.0,
 'pdc_eptp': 53.693321228027344,
 'checksum': 'ETQJHSNGESNGESNG',
 'tmofst43': 1.0399999618530273,
 'meanblca': 6664,
 'meanblcb': 6554,
 'meanblcc': 6593,
 'meanblcd': 6169,
 'simple': True,
 'bitpix': 8,
 'naxis': 0,
 'extend': True,
 'nextend': 2,
 'origin': 'NASA/Ames',
 'date': '2018-10-06',
 'creator': '4612 LightCurveExporterPipelineModule',
 'procver': 'spoc-3.3.37-20181001',
 'filever': '1.0',
 'timversn': 'OGIP/93-003',
 'data_rel': 2,
 'sector': 2,
 'camera': 4,
 'ccd': 3,
 'pxtable': 129,
 'pmra': 96.4716,
 'pmdec': -340.083,
 'pmtotal': 353.50136703,
 'tessmag': 9.39299965,
 'teff': 3469.0,
 'logg': 4.94010019,
 'mh': None,
 'radius': 0.31299999,
 'ticver': 7,
 'crmiten': True,
 'crblksz': 10,
 'crspoc': False,
 'label': 'TIC 307210830',
 'mission': 'TESS',
 'ra': 124.5319,
 'dec': -68.313,
 'filename': '/Users/rhounsel/.lightkurve-cache/mastDownload/TESS/tess2018234235059-s0002-0000000307210830-0121-s/tess2018234235059-s0002-0000000307210830-0121-s_lc.fits',
 'targetid': 307210830,
 'quality_bitmask': 'default',
 'quality_mask': array([False, False, False, ...,  True,  True,  True])}
lcf.mission
'TESS'
lcf.sector
2
lcf.estimate_cdpp()
218.15446  ppm

Congratulations! You have now learnt how to work with LightCurveFiles.