lightkurve.correctors.CBVCorrector#

class lightkurve.correctors.CBVCorrector(lc, interpolate_cbvs=False, extrapolate_cbvs=False, do_not_load_cbvs=False, cbv_dir=None)[source]#

Class for removing systematics using Cotrending Basis Vectors (CBVs) from Kepler/K2/TESS.

On construction of this object, the relevant CBVs will be downloaded from MAST appropriate for the lightcurve object passed to the constructor.

For TESS there are multiple CBV types. All are loaded and the user must specify which to use in the correction.

Attributes
lcLightCurve

The light curve loaded into CBVCorrector in electrons / second

cbvsCotrendingBasisVectors list

The retrieved CBVs, can contain multiple types of CBVs

interpolated_cbvsbool

If true then the CBVs have been interpolated to the lightcurve

cbv_design_matrixDesignMatrix

The retrieved CBVs ported into a DesignMatrix object

extra_design_matrixDesignMatrix

An extra design matrix to include in the fit with the CBVs

design_matrix_collectionDesignMatrixCollection

The design matrix collection composed of cbv_design_matrix and extra_design_matrix

corrected_lcLightCurve

The returned light curve from correct() in electrons / second

coefficientsfloat ndarray

The fit coefficients corresponding to the design_matrix_collection

coefficients_errfloat ndarray

The error estimates for the coefficients, see regressioncorrector

model_lcLightCurve

The model fit to the lightcurve ‘lc’

diagnostic_lightcurvesdict

Model fits for each of the sub design matrices fit in model_lc

lc_neighborhoodLightCurveCollection

SPOC SAP light curves of all targets within the defined neighborhood of the target under study for use with the under-fitting metric

lc_neighborhood_fluxlist of arrays

Neighboring target flux aligned or interpolated to the target under study cadence

cadence_masknp.ndarray of bool

Mask, where True indicates a cadence that was used in RegressionCorrector.correct. Note: The saved cadence_mask is overwritten for each call to correct().

over_fitting_scorefloat

Over-fitting score from the most recent run of correct()

under_fitting_scorefloat

Under-fitting score from the most recent run of correct()

alphafloat

L2-norm regularization term used in most recent fit Equivalent to: designmatrix prior sigma = np.median(self.lc.flux_err) / np.sqrt(alpha)

__init__(lc, interpolate_cbvs=False, extrapolate_cbvs=False, do_not_load_cbvs=False, cbv_dir=None)[source]#

Constructor

This constructor will retrieve all relevant CBVs from MAST and then align or interpolate them with the passed-in light curve.

Parameters
lcLightCurve

The light curve to correct

interpolate_cbvsbool

By default, the cbvs will be ‘aligned’ to the lightcurve. If you wish to interpolate the cbvs instead then set this to True. Uses Piecewise Cubic Hermite Interpolating Polynomial (PCHIP).

extrapolate_cbvsbool

Set to True if the CBVs also have to be extrapolated outside their time stamp range. (If False then those cadences are filled with NaNs.)

do_not_load_cbvsbool

If True then the CBVs will NOT be loaded from MAST. Use this option if you wish to use the CBV corrector methods with only a custom design matrix (via the ext_dm argument in the corrector methods)

cbv_dirstr

Path to specific directory holding TESS CBVs. If this is None, will query MAST by default.

Methods

__init__(lc[, interpolate_cbvs, ...])

Constructor

compute_overfit_metric(**kwargs)

Measures the degree of over-fitting in the correction.

compute_underfit_metric(**kwargs)

Measures the degree of under-fitting the correction.

copy()

Returns a copy of this cbvCorrector object.

correct([cbv_type, cbv_indices, ext_dm, ...])

Optimizes the correction by adjusting the L2-Norm (Ridge Regression) regularization penalty term, alpha, based on the introduced noise (over-fitting) and residual correlation (under-fitting) goodness metrics.

correct_elasticnet([cbv_type, cbv_indices, ...])

Performs the correction using scikit-learn's ElasticNet which utilizes combined L1- and L2-Norm priors as a regularizer.

correct_gaussian_prior([cbv_type, ...])

Performs the correction using RegressionCorrector methods.

correct_regressioncorrector(...)

Pass-through method to gain access to the superclass RegressionCorrector.correct() method.

diagnose()

Returns diagnostic plots to assess the most recent correction.

diagnose_priors()

Returns a diagnostic plot visualizing how the best-fit coefficients compare against the priors.

goodness_metric_scan_plot([cbv_type, ...])

Returns a diagnostic plot of the over and under goodness metrics as a function of the L2-Norm regularization term, alpha.

over_fitting_metric([n_samples])

Computes the over-fitting metric using metrics.overfit_metric_lombscargle

under_fitting_metric([radius, min_targets, ...])

Computes the under-fitting metric using metrics.underfit_metric_neighbors

Attributes

cadence_mask

corrected_lc

dmc

Shorthand for self.design_matrix_collection.

original_lc