lightkurve.correctors.DesignMatrix#
- class lightkurve.correctors.DesignMatrix(df, columns=None, name='unnamed_matrix', prior_mu=None, prior_sigma=None)[source]#
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.- Parameters
- dfdict, array, or
pandas.DataFrame
object Columns to include in the design matrix. If this object is not a
DataFrame
then it will be passed to the DataFrame constructor.- columnsiterable of str (optional)
Column names, if not already provided via
df
.- namestr
Name of the matrix.
- prior_muarray
Prior means of the coefficients associated with each column in a linear regression problem.
- prior_sigmaarray
Prior standard deviations of the coefficients associated with each column in a linear regression problem.
- dfdict, array, or
Examples
>>> from lightkurve.correctors.designmatrix import DesignMatrix, create_spline_matrix >>> DesignMatrix(np.arange(100), name='slope') slope DesignMatrix (100, 1) >>> create_spline_matrix(np.arange(100), n_knots=5, name='spline') spline DesignMatrix (100, 5)
Methods
__init__
(df[, columns, name, prior_mu, ...])append_constant
([prior_mu, prior_sigma, inplace])Returns a new
DesignMatrix
with a column of ones appended.collect
(matrix)Join two designmatrices, return a design matrix collection
copy
()Returns a deepcopy of DesignMatrix
pca
([nterms, n_iter])Returns a new
DesignMatrix
with a smaller number of regressors.plot
([ax])Visualize the design matrix values as an image.
plot_priors
([ax])Visualize the coefficient priors.
split
(row_indices[, inplace])Returns a new
DesignMatrix
with regressors split into multiple columns.standardize
([inplace])Returns a new
DesignMatrix
in which the columns have been median-subtracted and sigma-divided.Convert this dense matrix object to a
SparseDesignMatrix
.validate
([rank])Emits
LightkurveWarning
if matrix has low rank or priors have incorrect shape.Attributes
Design matrix "X" to be used in RegressionCorrector objects
Matrix rank computed using
numpy.linalg.matrix_rank
.Tuple specifying the shape of the matrix as (n_rows, n_columns).
2D numpy array containing the matrix values.