WDmodel.covariance module¶
Parametrizes the noise of the spectrum fit using a Gaussian process.
-
class
WDmodel.covariance.
WDmodel_CovModel
(errscale, covtype='Matern32', coveps=1e-12)[source]¶ Bases:
object
Parametrizes the noise of the spectrum fit using a Gaussian process.
This class models the covariance of the spectrum fit using a stationary Gaussian process conditioned on the spectrum flux residuals and spectrum flux uncertainties. The class allows the kernel of the Gaussian process to be set in a single location. A few different stationary kernels are supported. These choices are defined in
celerite.terms
.- Parameters
errscale (float) – Chracteristic scale of the spectrum flux uncertainties. The kernel amplitude hyperparameters are reported as fractions of this number. If the spectrum flux is rescaled, this must be set appropriately to get the correct uncertainties. The
WDmodel
package uses the median of the spectrum flux uncertainty internally.covtype (
{'Matern32', 'SHO', 'Exp', 'White}
) – The model to use to parametrize the covariance. Choices are defined incelerite.terms
All choices except'White'
parametrize the covariance using a stationary kernel with a characteristic amplitudefsig
and scaletau
+ a white noise component with amplitudefw
. Only the white noise component is used to condition the Gaussian process ifcovtype
is'White'
. If not specified or unknown,'Matern32'
is used and aRuntimeWarning
is raised.coveps (float) – If
covtype
is'Matern32'
acelerite.terms.Matern32Term
is used to approximate a Matern32 kernel with precision coveps. The default is1e-12
. Ignored if any othercovtype
is specified.
-
_k1
¶ The non-trivial stationary component of the kernel
- Type
None or a term instance from
celerite.terms
-
_k2
¶ The white noise component of the kernel
- Returns
- Return type
A
WDmodel.covariance.WDmodel_CovModel
instance
Notes
Virtually none of the attributes should be used directly since it is trivially possible to break the model by redefining them. Access to them is best through the functions connected to the models.
-
__init__
(errscale, covtype='Matern32', coveps=1e-12)[source]¶ Initialize self. See help(type(self)) for accurate signature.
-
getgp
(wave, flux_err, fsig, tau, fw)[source]¶ Return the
celerite.GP
instancePrecomputes the covariance matrix of the Gaussian process specified by the functional form of the stationary kernel and the current values of the hyperparameters. Wraps
celerite.GP
.- Parameters
wave (array-like, optional) – Wavelengths at which to condition the Gaussian process
flux_err (array-like) – Flux uncertainty array on which to condition the Gaussian process
fsig (float) – The fractional amplitude of the non-trivial stationary kernel. The true amplitude is scaled by
WDmodel.covariance.WDmodel_CovModel._errscale
tau (float) – The characteristic length scale of the non-trivial stationary kernel.
fw (float) – The fractional amplitude of the white noise component of the kernel. The true amplitude is scaled by
WDmodel.covariance.WDmodel_CovModel._errscale
- Returns
gp – The Gaussian process with covariance matrix precomputed at the location of the data
- Return type
celerite.GP
instance
Notes
fsig
,tau
andfw
all must be > 0. This constraint is not checked here, but is instead imposed by the samplers/optimizers used in theWDmodel.fit
methods, and by bounds used to construct theWDmodel.likelihood.WDmodel_Likelihood
instance using theWDmodel.likelihood.setup_likelihood()
method.
-
lnlikelihood
(wave, res, flux_err, fsig, tau, fw)[source]¶ Return the log likelihood of the Gaussian process
Conditions the Gaussian process specified by the functional form of the stationary kernel and the current values of the hyperparameters on the data, and computes the log likelihood. Wraps
celerite.GP.log_likelihood()
.- Parameters
wave (array-like, optional) – Wavelengths at which to condition the Gaussian process
res (array-like) – Flux residual array on which to condition the Gaussian process. The kernel parametrization assumes that the mean model has been subtracted off.
flux_err (array-like) – Flux uncertaintyarray on which to condition the Gaussian process
fsig (float) – The fractional amplitude of the non-trivial stationary kernel. The true amplitude is scaled by
WDmodel.covariance.WDmodel_CovModel._errscale
tau (float) – The characteristic length scale of the non-trivial stationary kernel.
fw (float) – The fractional amplitude of the white noise component of the kernel. The true amplitude is scaled by
WDmodel.covariance.WDmodel_CovModel._errscale
- Returns
lnlike – The log likelihood of the Gaussian process conditioned on the data.
- Return type
See also
-
predict
(wave, res, flux_err, fsig, tau, fw, mean_only=False)[source]¶ Return the prediction for the Gaussian process
Conditions the Gaussian process specified by the parametrized with the functional form of the stationary kernel and the current values of the hyperparameters on the data, and computes returns the prediction at the same location as the data. Wraps
celerite.GP.predict()
.- Parameters
wave (array-like, optional) – Wavelengths at which to condition the Gaussian process
res (array-like) – Flux residual array on which to condition the Gaussian process. The kernel parametrization assumes that the mean model has been subtracted off.
flux_err (array-like) – Flux uncertaintyarray on which to condition the Gaussian process
fsig (float) – The fractional amplitude of the non-trivial stationary kernel. The true amplitude is scaled by
WDmodel.covariance.WDmodel_CovModel._errscale
tau (float) – The characteristic length scale of the non-trivial stationary kernel.
fw (float) – The fractional amplitude of the white noise component of the kernel. The true amplitude is scaled by
WDmodel.covariance.WDmodel_CovModel._errscale
mean_only (bool, optional) – Return only the predicted mean, not the covariance matrix
- Returns
wres (array-like) – The prediction of the Gaussian process conditioned on the data at the same location i.e. the model.
cov (array-like, optional) – The computed covariance matrix of the Gaussian process using the parametrized stationary kernel evaluated at the locations of the data.
See also