lightkurve.correctors.
DesignMatrix
(df, columns=None, name='unnamed_matrix', prior_mu=None, prior_sigma=None)¶Bases: object
A matrix of column vectors for use in linear regression.
The purpose of this class is to provide a convenient method to interact
with a set of one or more regressors which are known to correlate with
trends or systematic noise signals which we want to remove from a light
curve. Specifically, this class is designed to provide the design matrix
for use by Lightkurve’s RegressionCorrector
class.
pandas.DataFrame
objectColumns to include in the design matrix. If this object is not a
DataFrame
then it will be passed to the DataFrame constructor.
Column names, if not already provided via df
.
Name of the matrix.
Prior means of the coefficients associated with each column in a linear regression problem.
Prior standard deviations of the coefficients associated with each column in a linear regression problem.
Attributes Summary
List of column names. 

Matrix rank computed using 

Tuple specifying the shape of the matrix as (n_rows, n_columns). 

2D numpy array containing the matrix values. 
Methods Summary

Returns a new 

Returns a new 

Visualize the design matrix values as an image. 

Visualize the coefficient priors. 

Returns a new 

Returns a new 
Attributes Documentation
columns
¶List of column names.
rank
¶Matrix rank computed using numpy.linalg.matrix_rank
.
shape
¶Tuple specifying the shape of the matrix as (n_rows, n_columns).
values
¶2D numpy array containing the matrix values.
Methods Documentation
append_constant
(self, prior_mu=0, prior_sigma=inf)¶Returns a new DesignMatrix
with a column of ones appended.
DesignMatrix
New design matrix with a column of ones appended. This column is named “offset”.
pca
(self, nterms=6)¶Returns a new DesignMatrix
with a smaller number of regressors.
This method will use Principal Components Analysis (PCA) to reduce the number of columns in the matrix.
Number of columns in the new matrix.
DesignMatrix
A new design matrix with PCA applied.
plot
(self, ax=None, **kwargs)¶Visualize the design matrix values as an image.
Uses Matplotlib’s plot_image
to visualize the
matrix values.
plot_priors
(self, ax=None)¶Visualize the coefficient priors.
split
(self, row_indices)¶Returns a new DesignMatrix
with regressors split into multiple
columns.
This method will return a new design matrix containing n_columns * len(row_indices) regressors. This is useful in situations where the linear regression can be improved by fitting separate coefficients for different contiguous parts of the regressors.
Every regressor (i.e. column) in the design matrix will be split up over multiple columns separated at the indices provided.
DesignMatrix
A new design matrix with shape (n_rows, len(row_indices)*n_columns).
standardize
(self)¶Returns a new DesignMatrix
in which the columns have been
mediansubtracted and sigmadivided.
For each column in the matrix, this method will subtract the median of the column and divide by the column’s standard deviation, i.e. it will compute the column’s socalled “standard scores” or “zvalues”.
This operation is useful because it will make the matrix easier to visualize and makes fitted coefficients easier to interpret.
Notes: * Standardizing a spline design matrix will break the splines. * Columns with constant values (i.e. zero standard deviation) will be left unchanged.
DesignMatrix
A new design matrix with mediansubtracted & sigmadivided columns.