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:
objectClasses 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.WDmodelinstance) – The DA White Dwarf SED model generator - covmodel (
WDmodel.covariance.WDmodel_CovModelinstance) – The parametrized model for the covariance of the spectrumspec - pbs (dict) – Passband dictionary containing the passbands corresponding to
phot.pband generated byWDmodel.passband.get_pbmodel(). - lnlike (
WDmodel_Likelihoodinstance) – 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: numpy.recarray
-
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.WDmodelinstance
-
covmodel¶ The parametrized model for the covariance of the spectrum
specType: WDmodel.covariance.WDmodel_CovModelinstance
-
pbs¶ Passband dictionary containing the passbands corresponding to
phot.pband generated byWDmodel.passband.get_pbmodel().Type: dict
-
_lnlike¶ Instance of the likelihood function class, such as that produced by
WDmodel.likelihood.setup_likelihood()Type: WDmodel_Likelihoodinstance
-
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: float
-
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.fitmodule. Those methods evaluate the posterior probability of the model parameters given the data.Return type: WDmodel_PosteriorinstanceNotes
Wraps
celerite.modeling.Model.log_prior()which imposes a boundscheck and returns-inf. 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 (array-like) – Vector of the non-frozen 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: - theta (array-like) – Vector of the non-frozen model parameters. The order of the
parameters is defined by
-
__init__(spec, phot, model, covmodel, pbs, lnlike, pixel_scale=1.0, phot_dispersion=0.0)[source]¶ x.__init__(…) initializes x; see help(type(x)) for 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 (array-like) – Vector of the non-frozen 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: float Notes
The prior on
avis the ‘glos’ priorThe prior on
rvis 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(B-V) with PS1. Their sigma should be consistent despite the different filter set.The prior on
fsigandfw- the fractional amplitudes of the non-trivial stationary and white components of the kernel used to parametrize the covariance is half-Cauchy since we don’t want it to be less than zeroThere is no explicit prior on
taui.e. a tophat prior, defined by the boundsThe
fwhmhas 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 preventsfwhmfrom 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 returns-inf. 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 (array-like) – Vector of the non-frozen 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: float
-
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 (array-like) – Vector of the non-frozen 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: float
- spec (
-
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_Likelihoodinstance. 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