CBVCorrector.correct(cbv_type=['SingleScale'], cbv_indices=[array([1, 2, 3, 4, 5, 6, 7, 8])], ext_dm=None, cadence_mask=None, alpha_bounds=[0.0001, 10000.0], target_over_score=0.5, target_under_score=0.5, max_iter=100)[source]

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. The numercial optimization is performed using the scipy.optimize.minimize_scalar Brent’s method.

The optimizer attempts to maximize the over- and under-fitting goodness metrics. However, once the target_over_score or target_under_score is reached, a “Leaky ReLU” is used so that the optimization “pressure” concentrates on the other metric until both metrics rise above their respective target scores, instead of driving a single metric to near 1.0.

The optimization parameters used are stored in self.optimization_params as a record of how the optimization was performed.

The optimized correction is performed using LightKurve’s RegressionCorrector methods. See correct_gaussian_prior for details.

cbv_typestr list

List of CBV types to use in correction {‘ALL’ => Use all}

cbv_indiceslist of lists

List of CBV vectors to use in each of cbv_type passed. {‘ALL’ => Use all} NOTE: 1-Based indexing!

ext_dmDesignMatrix or DesignMatrixCollection

Optionally pass an extra design matrix to also be used in the fit

cadence_masknp.ndarray of bools (optional)

Mask, where True indicates a cadence that should be used.

alpha_boundsfloat list(len=2)

upper anbd lowe bounds for alpha


Target Over-fitting metric score


Target under-fitting metric score


Maximum number of iterations to optimize goodness metrics


Corrected light curve, with noise removed. In units of electrons / second


The following example will perform the correction using the SingleScale and Spike basis vectors. It will use alpha bounds of [1.0,1e3]. The target over-fitting score is 0.5 and the target under-fitting score is 0.8.

>>> cbv_type = ['SingleScale', 'Spike']
>>> cbv_indices = [np.arange(1,9), 'ALL']
>>> cbvCorrector.correct(cbv_type=cbv_type, cbv_indices=cbv_indices,  
>>>     alpha_bounds=[1.0,1e3],  
>>>     target_over_score=0.5, target_under_score=0.8)