# 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 with dtype=[('wave', '<f8'), ('flux', '<f8'), ('flux_err', '<f8')]

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

• model (WDmodel.WDmodel.WDmodel instance) – The DA White Dwarf SED model generator

• covmodel (WDmodel.covariance.WDmodel_CovModel instance) – The parametrized model for the covariance of the spectrum spec

• pbs (dict) – Passband dictionary containing the passbands corresponding to phot.pb and generated by WDmodel.passband.get_pbmodel().

• lnlike (WDmodel_Likelihood instance) – Instance of the likelihood function class, such as that produced by WDmodel.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 is 0.

spec

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

Type

numpy.recarray

wave_scale

length of the wavelength array wave in Angstroms

Type

float

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
covmodel

The parametrized model for the covariance of the spectrum spec

Type
pbs

Passband dictionary containing the passbands corresponding to phot.pb and generated by WDmodel.passband.get_pbmodel().

Type

dict

_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

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 is 0.

Type

float, optional

p0

initial values of all the model parameters, including fixed parameters

Type

dict

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 returns -inf. This is not an issue as the samplers used in the methods in WDmodel.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

float

__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 (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 av is the ‘glos’ prior

The 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(B-V) with PS1. Their sigma should be consistent despite the different filter set.

The prior on fsig and fw - 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 zero

There is no explicit prior on tau i.e. a tophat prior, defined by the bounds

The 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 prevents fwhm 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 returns -inf. This is not an issue as the samplers used in the methods in WDmodel.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 around WDmodel_Posterior._lnprior() which is what is actually evalulated by WDmodel_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

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 by WDmodel.io.read_params().

Returns

lnlike – An instance of the likelihood function class.

Return type

WDmodel.likelihood.WDmodel_Likelihood