WDmodel.likelihood module¶
Classes defining the likelihood and the posterior probability of the model given the data

class
WDmodel.likelihood.
WDmodel_Posterior
(spec, phot, model, covmodel, pbs, lnlike, pixel_scale=1.0, phot_dispersion=0.0)[source]¶ Bases:
object
Classes defining the posterior probability of the model given the data
An instance of this class is used to store the data and model, and evaluate the likelihood and prior to compute the posterior.
 Parameters
spec (
numpy.recarray
) – The spectrum withdtype=[('wave', '<f8'), ('flux', '<f8'), ('flux_err', '<f8')]
phot (None or
numpy.recarray
) – The photometry withdtype=[('pb', 'str'), ('mag', '<f8'), ('mag_err', '<f8')]
model (
WDmodel.WDmodel.WDmodel
instance) – The DA White Dwarf SED model generatorcovmodel (
WDmodel.covariance.WDmodel_CovModel
instance) – The parametrized model for the covariance of the spectrumspec
pbs (dict) – Passband dictionary containing the passbands corresponding to
phot.pb
and generated byWDmodel.passband.get_pbmodel()
.lnlike (
WDmodel_Likelihood
instance) – Instance of the likelihood function class, such as that produced byWDmodel.likelihood.setup_likelihood()
pixel_scale (float, optional) – Jacobian of the transformation between wavelength in Angstrom and pixels. In principle, this should be a vector, but virtually all spectral reduction packages resample the spectrum onto a uniform wavelength scale that is close to the native pixel scale of the spectrograph. Default is
1.
phot_dispersion (float, optional) – Excess photometric dispersion to add in quadrature with the photometric uncertainties
phot.mag_err
. Use if the errors are grossly underestimated. Default is0.

spec
¶ The spectrum with
dtype=[('wave', '<f8'), ('flux', '<f8'), ('flux_err', '<f8')]
 Type

phot
¶ The photometry with
dtype=[('pb', 'str'), ('mag', '<f8'), ('mag_err', '<f8')]
 Type
None or
numpy.recarray

model
¶ The DA White Dwarf SED model generator
 Type
WDmodel.WDmodel.WDmodel
instance

covmodel
¶ The parametrized model for the covariance of the spectrum
spec
 Type
WDmodel.covariance.WDmodel_CovModel
instance

pbs
¶ Passband dictionary containing the passbands corresponding to
phot.pb
and generated byWDmodel.passband.get_pbmodel()
. Type

_lnlike
¶ Instance of the likelihood function class, such as that produced by
WDmodel.likelihood.setup_likelihood()
 Type
WDmodel_Likelihood
instance

pixel_scale
¶ Jacobian of the transformation between wavelength in Angstrom and pixels. In principle, this should be a vector, but virtually all spectral reduction packages resample the spectrum onto a uniform wavelength scale that is close to the native pixel scale of the spectrograph. Default is
1.
 Type

phot_dispersion
¶ Excess photometric dispersion to add in quadrature with the photometric uncertainties
phot.mag_err
. Use if the errors are grossly underestimated. Default is0.
 Type
float, optional
 Returns
lnpost – It is this instance that is passed to the samplers/optimizers in the
WDmodel.fit
module. Those methods evaluate the posterior probability of the model parameters given the data. Return type
WDmodel_Posterior
instance
Notes
Wraps
celerite.modeling.Model.log_prior()
which imposes a boundscheck and returnsinf
. This is not an issue as the samplers used in the methods inWDmodel.fit
.
__call__
(theta, prior=False, likelihood=False)[source]¶ Evalulates the log posterior of the model parameters given the data
 Parameters
theta (arraylike) – Vector of the nonfrozen model parameters. The order of the parameters is defined by
WDmodel_Likelihood.parameter_names
.prior (bool, optional) – Only return the value of the log prior given the model parameters
likelihood (bool, optional) – Only return the value of the log likelihood given the model parameters if the prior is finite
 Returns
lnpost – the log posterior of the model parameters given the data
 Return type

__init__
(spec, phot, model, covmodel, pbs, lnlike, pixel_scale=1.0, phot_dispersion=0.0)[source]¶ Initialize self. See help(type(self)) for accurate signature.

_lnprior
()[source]¶ Evalulates the log likelihood of the model parameters given the data.
Implements an lnprior function which imposes weakly informative priors on the model parameters.
 Parameters
theta (arraylike) – Vector of the nonfrozen model parameters. The order of the parameters is defined by
WDmodel_Likelihood.parameter_names
. Returns
lnprior – the log likelihood of the model parameters given the data
 Return type
Notes
The prior on
av
is the ‘glos’ priorThe prior on
rv
is a Gaussian with mean 3.1 and standard deviation 0.18. This is adopted from Schlafly et al., 2014 PS1 analysis. Note that they report 3.31, but they aren’t really measuring E(BV) with PS1. Their sigma should be consistent despite the different filter set.The prior on
fsig
andfw
 the fractional amplitudes of the nontrivial stationary and white components of the kernel used to parametrize the covariance is halfCauchy since we don’t want it to be less than zeroThere is no explicit prior on
tau
i.e. a tophat prior, defined by the boundsThe
fwhm
has a lower bound set at the value below which the spectrum isn’t being convolved anymore. We never run into this bound since real spectra have physical instrumental broadening. This preventsfwhm
from going to zero for fitting poorly simulated spectra generated from simply resampling the model grid.The prior on all other parameters are broad Gaussians
Wraps
celerite.modeling.Model.log_prior()
which imposes a boundscheck and returnsinf
. This is not an issue as the samplers used in the methods inWDmodel.fit
.

lnlike
(theta)[source]¶ Evalulates the log likelihood of the model parameters given the data.
Convenience function that can return the value of the likelihood even if the prior is not finite unlike
WDmodel_Posterior.__call__()
for debugging. Parameters
theta (arraylike) – Vector of the nonfrozen model parameters. The order of the parameters is defined by
WDmodel_Likelihood.parameter_names
. Returns
lnlike – the log likelihood of the model parameters given the data
 Return type

lnprior
(theta)[source]¶ Evalulates the log prior of the model parameters.
Convenience function that can return the value of the prior defined to make the interface consistent with the
WDmodel_Posterior.lnlike()
method. Just a thin wrapper aroundWDmodel_Posterior._lnprior()
which is what is actually evalulated byWDmodel_Posterior.__call__()
. Parameters
theta (arraylike) – Vector of the nonfrozen model parameters. The order of the parameters is defined by
WDmodel_Likelihood.parameter_names
. Returns
lnprior – the log prior of the model parameters
 Return type

WDmodel.likelihood.
setup_likelihood
(params)[source]¶ Setup the form of the likelihood of the data given the model.
 Parameters
params (dict) – A parameter dictionary used to configure the
WDmodel_Likelihood
instance. The format of the dict is defined byWDmodel.io.read_params()
. Returns
lnlike – An instance of the likelihood function class.
 Return type
WDmodel.likelihood.WDmodel_Likelihood