{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# What are `LightCurve` objects?" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "`LightCurve` objects are data objects which encapsulate the brightness of a star over time. They provide a series of common operations, for example folding, binning, plotting, etc. There are a range of subclasses of `LightCurve` objects specific to telescopes, including `KeplerLightCurve` for Kepler and K2 data and `TessLightCurve` for TESS data.\n", "\n", "Although *lightkurve* was designed with Kepler, K2 and TESS in mind, these objects can be used for a range of astronomy data.\n", "\n", "You can create a `LightCurve` object from a `TargetPixelFile` object using Simple Aperture Photometry (see our tutorial for more information on Target Pixel Files [here](http://lightkurve.keplerscience.org/tutorials/1.02-target-pixel-files.html). Aperture Photometry is the simple act of summing up the values of all the pixels in a pre-defined aperture, as a function of time. By carefully choosing the shape of the aperture mask, you can avoid nearby contaminants or improve the strength of the specific signal you are trying to measure relative to the background.\n", "\n", "To demonstrate, lets create a `KeplerLightCurve` from a `KeplerTargetPixelFile`." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "from lightkurve import search_targetpixelfile\n", "\n", "# First we open a Target Pixel File from MAST, this one is already cached from our previous tutorial!\n", "tpf = search_targetpixelfile('KIC 6922244', quarter=4).download()\n", "\n", "# Then we convert the target pixel file into a light curve using the pipeline-defined aperture mask.\n", "lc = tpf.to_lightcurve(aperture_mask=tpf.pipeline_mask)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We've built a new `KeplerLightCurve` object called `lc`. Note in this case we've passed an **aperture_mask** to the `to_lightcurve` method. The default is to use the *Kepler* pipeline aperture. (You can pass your own aperture, which is a boolean `numpy` array.) By summing all the pixels in the aperture we have created a Simple Aperture Photometry (SAP) lightcurve.\n", "\n", "`KeplerLightCurve` has many useful functions that you can use. As with Target Pixel Files you can access the meta data very simply:" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'Kepler'" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "lc.meta['mission']" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "4" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "lc.meta['quarter']" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "And you still have access to time and flux attributes. In a light curve, there is only one flux point for every time stamp:" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "