{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# How to load and use Cotrending Basis Vectors for Kepler, K2 and TESS" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Cotrending Basis Vectors (CBVs) are generated in the PDC component of the Kepler/K2/TESS pipeline and are used to remove systematic trends in light curves. They are built from the most common systematic trends observed in each PDC Unit of Work (Quarter for Kepler, Campaign for K2 and Sector for TESS). Each Kepler and K2 module output and each CCD in TESS has its own set of CBVs. You can read an introduction to the CBVs in [Demystifying Kepler Data](https://arxiv.org/pdf/1207.3093.pdf) or to greater detail in the [Kepler Data Processing Handbook](https://archive.stsci.edu/kepler/manuals/KSCI-19081-003-KDPH.pdf). The same basic method to generate CBVs is used for all three missions.\n", "\n", "This tutorial provides examples of how to load CBVs from MAST and set them up in a design matrix for use to remove systematic trends. Please consult the [DesignMatrix page](https://docs.lightkurve.org/reference/api/lightkurve.correctors.DesignMatrix.html#lightkurve.correctors.DesignMatrix) in the API docs for the full details on that class. A convenient tool has been created called [CBVCorrector](https://docs.lightkurve.org/reference/api/lightkurve.correctors.CBVCorrector.html?highlight=cbvcorrector) which will utilize the CBVs for the custom removal of systematic trends. See the [CBVCorrector HOWTO page](https://docs.lightkurve.org/tutorials/2-creating-light-curves/2-3-how-to-use-cbvcorrector.html) for example usage." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Cotrending Basis Vector Types" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "There are three basic types of CBVs: \n", "- **Single-Scale** contains all systematic trends combined in a single set of basis vectors. \n", "- **Multi-Scale** contains systematic trends in specific wavelet-based band passes. There are usually three sets of multi-scale basis vectors in three bands.\n", "- **Spike** contains only short impulsive spike systematics.\n", "\n", "There are two different correction methods in PDC: Single-Scale and Multi-Scale. Single-Scale performs the correction in a single bandpass. Multi-Scale performs the correction in three separate wavelet-based bandpasses. Both corrections are performed in PDC but we can only export a single PDC light curve for each target. So, PDC must choose which of the two on a per-target basis. Generally speaking, single-scale performs better at preserving longer period signals. But at periods close to transiting planet durations multi-scale performs better at preserving signals. PDC therefore mostly chooses multi-scale for use within the planet finding pipeline and for the archive. You can find in the light curve FITS header which PDC method was chosen (keyword “PDCMETHD”). Additionally, a seperate correction is alway performed to remove short impulsive systematic spikes.\n", "\n", "For an individual's research needs, the mission supplied PDC lightcurves might not be ideal and so the CBVs are provided to the user to perform their own correction. All three CBV types are provided at MAST for TESS, however only Single-Scale is provided at MAST for Kepler and K2. For TESS, Cotrending Basis Vectors are currently only supplied at a 2-minute cadence. For Kepler/K2 only for the 30-minute target cadence." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Obtaining the CBVs" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Two tools are available to automatically download the CBVs relevent to your target of study: `load_tess_cbvs` and `load_kepler_cbvs`. Here is an example loading in the TESS Multi-Scale Band 2 CBVs for TESS target TIC 99180739, which happens to be on camera 1 and CCD 1. Note that you do not need to have a lightcurve object already loaded. One can directly request whichever CBVs one desires." ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "execution": { "iopub.execute_input": "2023-11-03T14:13:20.721272Z", "iopub.status.busy": "2023-11-03T14:13:20.721086Z", "iopub.status.idle": "2023-11-03T14:13:26.138120Z", "shell.execute_reply": "2023-11-03T14:13:26.137657Z" } }, "outputs": [], "source": [ "from lightkurve import search_lightcurve\n", "from lightkurve.correctors import load_tess_cbvs, load_kepler_cbvs\n", "import numpy as np\n", "lc = search_lightcurve('TIC 99180739', author='SPOC', sector=10).download(flux_column='sap_flux')\n", "cbvs = load_tess_cbvs(sector=lc.sector, camera=lc.camera, ccd=lc.ccd, cbv_type='MultiScale', band=2)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This TessCotrendingBasisVectors object contains 8 Multi-Scale band 2 CBVs for Sector 10, Camera 1, CCD 1. A CBV object contains only one type of CBVs. To obtain all types you must request each seperately. The basis vectors themselves are containted in an astropy.timeseries.TimeSeries Table:" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "execution": { "iopub.execute_input": "2023-11-03T14:13:26.140528Z", "iopub.status.busy": "2023-11-03T14:13:26.140292Z", "iopub.status.idle": "2023-11-03T14:13:26.145019Z", "shell.execute_reply": "2023-11-03T14:13:26.144676Z" } }, "outputs": [ { "data": { "text/html": [ "
time | CADENCENO | GAP | VECTOR_1 | VECTOR_2 | VECTOR_3 | VECTOR_4 | VECTOR_5 | VECTOR_6 | VECTOR_7 | VECTOR_8 |
---|---|---|---|---|---|---|---|---|---|---|
Time | int32 | bool | float32 | float32 | float32 | float32 | float32 | float32 | float32 | float32 |
1569.4331173767373 | 246224 | 0 | -0.00026 | 0.00163 | -0.00016 | 0.00014 | 0.00005 | -0.00150 | -0.00004 | -0.00007 |
1569.434506265032 | 246225 | 0 | -0.00036 | 0.00158 | -0.00025 | -0.00007 | 0.00006 | -0.00152 | -0.00006 | -0.00007 |
1569.435895153328 | 246226 | 0 | -0.00045 | 0.00152 | -0.00034 | -0.00028 | 0.00007 | -0.00153 | -0.00008 | -0.00008 |