hierarc.Likelihood package

Subpackages

Submodules

hierarc.Likelihood.anisotropy_scaling module

hierarc.Likelihood.cosmo_likelihood module

class hierarc.Likelihood.cosmo_likelihood.CosmoLikelihood(kwargs_likelihood_list, cosmology, kwargs_model, kwargs_bounds, sne_likelihood=None, kwargs_sne_likelihood=None, KDE_likelihood_chain=None, kwargs_kde_likelihood=None, normalized=False, 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)

info()[source]

prints information about the likelihood object

Returns:

print statements

likelihood(args, kwargs_cosmo_interp=None, verbose=False)[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

  • verbose (bool) – If true, prints intermediate outputs of likelihood calculation

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', lambda_scaling_property=0, lambda_scaling_property_beta=0, kwargs_lens_properties=None, global_los_distribution=False, mst_ifu=False, anisotropy_model='NONE', anisotropy_sampling=False, anisotropy_distribution='NONE', anisotropy_parameterization='beta', los_distributions=None, lambda_mst_distribution='NONE', gamma_in_sampling=False, gamma_in_distribution='NONE', log_m2l_sampling=False, log_m2l_distribution='NONE', alpha_lambda_sampling=False, beta_lambda_sampling=False, alpha_gamma_in_sampling=False, alpha_log_m2l_sampling=False, log_scatter=False, gamma_pl_index=None, gamma_pl_global_sampling=False, gamma_pl_global_dist='NONE', kin_scaling_param_list=None, j_kin_scaling_param_axes=None, j_kin_scaling_grid_list=None, num_distribution_draws=50, normalized=True, los_distribution_individual=None, kwargs_los_individual=None, prior_list=None, **kwargs_likelihood)[source]

Bases: TransformedCosmography, LensLikelihoodBase, KinScaling

Master class containing the likelihood definitions of different analysis for a 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 in units physical Mpc

check_dist(kwargs_lens, kwargs_kin, kwargs_source, kwargs_los)[source]

Checks if the provided keyword arguments describe a distribution function of hyperparameters or are single values.

Parameters:
  • kwargs_lens – lens model hyperparameter keywords

  • kwargs_kin – kinematic model hyperparameter keywords

  • kwargs_source – source brightness hyperparameter keywords

  • kwargs_los – list of dictionaries for line of sight hyperparameters

Returns:

bool, True if delta function, else False

ddt_dd_model_prediction(cosmo, kwargs_lens=None, kwargs_los=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

  • kwargs_los – line of slight list of dictionaries

Returns:

ddt_model mean, ddt_model sigma, dd_model mean, dd_model sigma

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, beta_dsp=None, kwargs_lens=None, kwargs_kin=None, kwargs_source=None, kwargs_los=None, cosmo=None)[source]

Log likelihood of the data of a lens given a model (defined with hyperparameters) and cosmological distances.

Parameters:
  • ddt – time-delay distance

  • dd – angular diameter distance to the deflector

  • delta_lum_dist – relative luminosity distance to pivot redshift

  • beta_dsp – Model prediction of ratio of Einstein radii theta_E_1 / theta_E_2

  • kwargs_lens – keywords of the hyperparameters of the lens model

  • kwargs_kin – keyword arguments of the kinematic model hyperparameters

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

  • kwargs_los – list of keyword arguments of global line of sight distributions

  • cosmo – ~astropy.cosmology instance

Returns:

log likelihood given the single lens analysis for the given hyperparameter

info()[source]

information about the lens

Returns:

print statement

lens_log_likelihood(cosmo, kwargs_lens=None, kwargs_kin=None, kwargs_source=None, kwargs_los=None, verbose=False)[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 hyperparameters of the lens model

  • kwargs_kin – keyword arguments of the kinematic model hyperparameters

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

  • kwargs_los – list of keyword arguments of global line of sight distributions

  • verbose (bool) – If true, prints intermediate outputs of likelihood calculation

Returns:

log likelihood of the data given the model

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

Log likelihood of the data of a lens given a specific model (as a draw from hyperparameters) and cosmological distances.

Parameters:
  • ddt – time-delay distance

  • dd – angular diameter distance to the deflector

  • delta_lum_dist – relative luminosity distance to pivot redshift

  • beta_dsp – Model prediction of ratio of Einstein radii theta_E_1 / theta_E_2

  • kwargs_lens – keywords of the hyperparameters of the lens model

  • kwargs_kin – keyword arguments of the kinematic model hyperparameters

  • kwargs_source – keyword arguments of source brightness

  • kwargs_los – line of sight list of dictionaries

  • 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 hyperparameter 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, kwargs_los=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 hyperparameters of the lens model

  • kwargs_kin – keyword arguments of the kinematic model hyperparameters

  • kwargs_los – line of sight parapers

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, kwargs_global_model=None)[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.

property gamma_pl_num

Number of power-law density slope parameters being sampled on individual lenses.

Returns:

number of power-law density slope parameters being sampled on individual lenses

info()[source]
Returns:

log_likelihood(cosmo, kwargs_lens=None, kwargs_kin=None, kwargs_source=None, kwargs_los=None, verbose=False)[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)

  • kwargs_los – line of sight keyword argument list

  • verbose (bool) – If true, prints intermediate outputs of likelihood calculation

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