hierarc.Likelihood package

Subpackages

Submodules

hierarc.Likelihood.anisotropy_scaling module

class hierarc.Likelihood.anisotropy_scaling.AnisotropyScalingIFU(anisotropy_model='NONE', ani_param_array=None, ani_scaling_array_list=None)[source]

Bases: object

class to manage anisotropy scalings for IFU data

ani_scaling(aniso_param_array)[source]
Parameters:

aniso_param_array – anisotropy parameter array

Returns:

scaling J(a_ani) for the IFU’s

draw_anisotropy(a_ani=None, a_ani_sigma=0, beta_inf=None, beta_inf_sigma=0)[source]

draw Gaussian distribution and re-sample if outside bounds

Parameters:
  • a_ani – mean of the distribution

  • a_ani_sigma – std of the distribution

  • beta_inf – anisotropy at infinity (relevant for GOM model)

  • beta_inf_sigma – std of beta_inf distribution

Returns:

random draw from the distribution

class hierarc.Likelihood.anisotropy_scaling.AnisotropyScalingSingleAperture(ani_param_array, ani_scaling_array)[source]

Bases: object

class to manage anisotropy scaling for single slit observation

ani_scaling(aniso_param_array)[source]
Parameters:

aniso_param_array – anisotropy parameter array

Returns:

scaling J(a_ani) for single slit

hierarc.Likelihood.cosmo_likelihood module

class hierarc.Likelihood.cosmo_likelihood.CosmoLikelihood(kwargs_likelihood_list, cosmology, kwargs_bounds, sne_likelihood=None, kwargs_sne_likelihood=None, KDE_likelihood_chain=None, kwargs_kde_likelihood=None, ppn_sampling=False, lambda_mst_sampling=False, lambda_mst_distribution='delta', anisotropy_sampling=False, kappa_ext_sampling=False, kappa_ext_distribution='NONE', alpha_lambda_sampling=False, beta_lambda_sampling=False, lambda_ifu_sampling=False, lambda_ifu_distribution='NONE', sigma_v_systematics=False, sne_apparent_m_sampling=False, sne_distribution='GAUSSIAN', z_apparent_m_anchor=0.1, log_scatter=False, anisotropy_model='OM', anisotropy_distribution='NONE', custom_prior=None, interpolate_cosmo=True, num_redshift_interp=100, cosmo_fixed=None)[source]

Bases: object

this class contains the likelihood function of the Strong lensing analysis

cosmo_instance(kwargs_cosmo)[source]
Parameters:

kwargs_cosmo – cosmology parameter keyword argument list

Returns:

astropy.cosmology (or equivalent interpolation scheme class)

likelihood(args, kwargs_cosmo_interp=None)[source]
Parameters:
  • args – list of sampled parameters

  • kwargs_cosmo_interp (dict) – interpolated angular diameter distances with ‘ang_diameter_distances’ and ‘redshifts’, and optionally ‘ok’ and ‘K’ in none-flat scenarios

Returns:

log likelihood of the combined lenses

hierarc.Likelihood.hierarchy_likelihood module

class hierarc.Likelihood.hierarchy_likelihood.LensLikelihood(z_lens, z_source, name='name', likelihood_type='TDKin', anisotropy_model='NONE', ani_param_array=None, ani_scaling_array_list=None, ani_scaling_array=None, num_distribution_draws=50, kappa_ext_bias=False, kappa_pdf=None, kappa_bin_edges=None, mst_ifu=False, lambda_scaling_property=0, lambda_scaling_property_beta=0, normalized=True, kwargs_lens_properties=None, **kwargs_likelihood)[source]

Bases: TransformedCosmography, LensLikelihoodBase, AnisotropyScalingIFU

master class containing the likelihood definitions of different analysis for s single lens

angular_diameter_distances(cosmo)[source]

time-delay distance Ddt, angular diameter distance to the lens (dd)

Parameters:

cosmo – astropy.cosmology instance (or equivalent with interpolation)

Returns:

ddt, dd, ds in units physical Mpc

check_dist(kwargs_lens, kwargs_kin, kwargs_source)[source]

checks if the provided keyword arguments describe a distribution function of hyper parameters or are single values

Parameters:
  • kwargs_lens – lens model hyper-parameter keywords

  • kwargs_kin – kinematic model hyper-parameter keywords

  • kwargs_source – source brightness hyper-parameter keywords

Returns:

bool, True if delta function, else False

ddt_dd_model_prediction(cosmo, kwargs_lens=None)[source]

predicts the model uncertainty corrected ddt prediction of the applied model (e.g. power-law)

Parameters:
  • cosmo – astropy.cosmology instance

  • kwargs_lens – keywords of the hyper parameters of the lens model

Returns:

ddt_model mean, ddt_model sigma, dd_model mean, dd_model sigma

draw_lens(lambda_mst=1, lambda_mst_sigma=0, kappa_ext=0, kappa_ext_sigma=0, gamma_ppn=1, lambda_ifu=1, lambda_ifu_sigma=0, alpha_lambda=0, beta_lambda=0)[source]

draws a realization of a specific model from the hyper-parameter distribution

Parameters:
  • lambda_mst – MST transform

  • lambda_mst_sigma – spread in the distribution

  • kappa_ext – external convergence mean in distribution

  • kappa_ext_sigma – spread in the distribution

  • gamma_ppn – Post-Newtonian parameter

  • lambda_ifu – secondary lambda_mst parameter for subset of lenses specified for

  • lambda_ifu_sigma – secondary lambda_mst_sigma parameter for subset of lenses specified for

  • alpha_lambda – float, linear slope of the lambda_int scaling relation with lens quantity self._lambda_scaling_property

  • beta_lambda – float, a second linear slope of the lambda_int scaling relation with lens quantity self._lambda_scaling_property_beta

Returns:

draw from the distributions

static draw_source(mu_sne=1, sigma_sne=0, lum_dist=0, **kwargs)[source]

draws a source magnitude from a distribution specified by population parameters

Parameters:
  • mu_sne – mean magnitude of SNe

  • sigma_sne – std of magnitude distribution of SNe relative to the mean magnitude

  • lum_dist – luminosity distance (astronomical magnitude scaling of defined brightness to the source redshift)

Returns:

realization of source amplitude given distribution

hyper_param_likelihood(ddt, dd, delta_lum_dist, kwargs_lens=None, kwargs_kin=None, kwargs_source=None, cosmo=None)[source]

log likelihood of the data of a lens given a model (defined with hyper-parameters) and cosmological distances

Parameters:
  • ddt – time-delay distance

  • dd – angular diameter distance to the deflector

  • delta_lum_dist – relative luminosity distance to pivot redshift

  • kwargs_lens – keywords of the hyper parameters of the lens model

  • kwargs_kin – keyword arguments of the kinematic model hyper parameters

  • kwargs_source – keyword argument of the source model (such as SNe)

  • cosmo – astropy.cosmology instance

Returns:

log likelihood given the single lens analysis for the given hyper parameter

lens_log_likelihood(cosmo, kwargs_lens=None, kwargs_kin=None, kwargs_source=None)[source]

log likelihood of the data of a lens given a model (defined with hyper-parameters) and cosmology

Parameters:
  • cosmo – astropy.cosmology instance

  • kwargs_lens – keywords of the hyper parameters of the lens model

  • kwargs_kin – keyword arguments of the kinematic model hyper parameters

  • kwargs_source – keyword argument of the source model (such as SNe)

Returns:

log likelihood of the data given the model

log_likelihood_single(ddt, dd, delta_lum_dist, kwargs_lens, kwargs_kin, kwargs_source, sigma_v_sys_error=None)[source]

log likelihood of the data of a lens given a specific model (as a draw from hyper-parameters) and cosmological distances

Parameters:
  • ddt – time-delay distance

  • dd – angular diameter distance to the deflector

  • delta_lum_dist – relative luminosity distance to pivot redshift

  • kwargs_lens – keywords of the hyper parameters of the lens model

  • kwargs_kin – keyword arguments of the kinematic model hyper parameters

  • kwargs_source – keyword arguments of source brightness

  • sigma_v_sys_error – unaccounted uncertainty in the velocity dispersion measurement

Returns:

log likelihood given the single lens analysis for a single (random) realization of the hyper parameter distribution

luminosity_distance_modulus(cosmo, z_apparent_m_anchor)[source]

the difference in luminosity distance between a pivot redshift (z_apparent_m_anchor) and the source redshift (effectively the ratio as this is the magnitude transform)

Parameters:
  • cosmo – astropy.cosmology instance (or equivalent with interpolation)

  • z_apparent_m_anchor – redshift of pivot/anchor at which the apparent SNe brightness is defined relative to

Returns:

lum_dist(z_source) - lum_dist(z_pivot)

sigma_v_measured_vs_predict(cosmo, kwargs_lens=None, kwargs_kin=None)[source]

mean and error covariance of velocity dispersion measurement mean and error covariance of velocity dispersion predictions

Parameters:
  • cosmo – astropy.cosmology instance

  • kwargs_lens – keywords of the hyper parameters of the lens model

  • kwargs_kin – keyword arguments of the kinematic model hyper parameters

Returns:

sigma_v_measurement, cov_error_measurement, sigma_v_predict_mean, cov_error_predict

hierarc.Likelihood.lens_sample_likelihood module

class hierarc.Likelihood.lens_sample_likelihood.LensSampleLikelihood(kwargs_lens_list, normalized=False)[source]

Bases: object

class to evaluate the likelihood of a cosmology given a sample of angular diameter posteriors Currently this class does not include possible covariances between the lens samples

log_likelihood(cosmo, kwargs_lens=None, kwargs_kin=None, kwargs_source=None)[source]
Parameters:
  • cosmo – astropy.cosmology instance

  • kwargs_lens – keywords of the parameters of the lens model

  • kwargs_kin – keyword arguments of the kinematic model

  • kwargs_source – keyword argument of the source model (such as SNe)

Returns:

log likelihood of the combined lenses

num_data()[source]

number of data points across the lens sample

Returns:

integer

hierarc.Likelihood.transformed_cosmography module

class hierarc.Likelihood.transformed_cosmography.TransformedCosmography(z_lens, z_source)[source]

Bases: object

class to manage hierarchical hyper-parameter that impact the cosmographic posterior interpretation of individual lenses.

displace_prediction(ddt, dd, gamma_ppn=1, lambda_mst=1, kappa_ext=0, mag_source=0)[source]

here we effectively change the posteriors of the lens, but rather than changing the instance of the KDE we displace the predicted angular diameter distances in the opposite direction The displacements form different effects are multiplicative and thus invariant under the order those displacements are applied.

Parameters:
  • ddt – time-delay distance

  • dd – angular diameter distance to the deflector

  • lambda_mst – overall global mass-sheet transform applied on the sample, lambda_mst=1 corresponds to the input model

  • gamma_ppn – post-newtonian gravity parameter (=1 is GR)

  • kappa_ext – external convergence to be added on top of the D_dt posterior

  • mag_source – source magnitude (attention, log scale, thus transform needs to be changed!)

Returns:

ddt, dd, mag_source

Module contents