jaxtronomy.Sampling package

Subpackages

Submodules

jaxtronomy.Sampling.likelihood module

class Likelihood(kwargs_data_joint, kwargs_model, param_class, image_likelihood=True, check_bounds=True, astrometric_likelihood=False, image_position_likelihood=False, source_position_likelihood=None, image_position_uncertainty=0.004, check_positive_flux=False, source_position_tolerance=None, source_position_sigma=0.001, force_no_add_image=False, source_marg=False, linear_prior=None, restrict_image_number=False, max_num_images=None, bands_compute=None, time_delay_likelihood=False, image_likelihood_mask_list=None, flux_ratio_likelihood=False, kwargs_flux_compute=None, prior_lens=None, prior_source=None, prior_extinction=None, prior_lens_light=None, prior_ps=None, prior_special=None, prior_lens_kde=None, prior_source_kde=None, prior_lens_light_kde=None, prior_ps_kde=None, prior_special_kde=None, prior_extinction_kde=None, prior_lens_lognormal=None, prior_source_lognormal=None, prior_extinction_lognormal=None, prior_lens_light_lognormal=None, prior_ps_lognormal=None, prior_special_lognormal=None, custom_logL_addition=None, kwargs_pixelbased=None, kinematic_2d_likelihood=False, kin_lens_idx=0, kin_lens_light_idx=0, tracer_likelihood=False, tracer_likelihood_mask=None)[source]

Bases: object

This class contains the routines to run a MCMC process.

the key components are: - im_sim_class: an instance of a class that simulates one (or more) images and returns the likelihood, such as ImageModel(), Multiband(), MultiExposure() - param_class: instance of a Param() class that can cast the sorted list of parameters that are sampled into the conventions of the ImSim class

Additional arguments are supported for adding a time-delay likelihood etc (see __init__ definition)

__init__(kwargs_data_joint, kwargs_model, param_class, image_likelihood=True, check_bounds=True, astrometric_likelihood=False, image_position_likelihood=False, source_position_likelihood=None, image_position_uncertainty=0.004, check_positive_flux=False, source_position_tolerance=None, source_position_sigma=0.001, force_no_add_image=False, source_marg=False, linear_prior=None, restrict_image_number=False, max_num_images=None, bands_compute=None, time_delay_likelihood=False, image_likelihood_mask_list=None, flux_ratio_likelihood=False, kwargs_flux_compute=None, prior_lens=None, prior_source=None, prior_extinction=None, prior_lens_light=None, prior_ps=None, prior_special=None, prior_lens_kde=None, prior_source_kde=None, prior_lens_light_kde=None, prior_ps_kde=None, prior_special_kde=None, prior_extinction_kde=None, prior_lens_lognormal=None, prior_source_lognormal=None, prior_extinction_lognormal=None, prior_lens_light_lognormal=None, prior_ps_lognormal=None, prior_special_lognormal=None, custom_logL_addition=None, kwargs_pixelbased=None, kinematic_2d_likelihood=False, kin_lens_idx=0, kin_lens_light_idx=0, tracer_likelihood=False, tracer_likelihood_mask=None)[source]

Initializing class.

Parameters:
  • param_class – instance of a Param() class that can cast the sorted list of parameters that are sampled into the conventions of the ImSim class

  • image_likelihood – bool, option to compute the imaging likelihood

  • source_position_likelihood – bool, if True, ray-traces image positions back to source plane and evaluates relative errors in respect ot the position_uncertainties in the image plane

  • check_bounds – bool, option to punish the hard bounds in parameter space

  • astrometric_likelihood – bool, additional likelihood term of the predicted vs modelled point source position

  • image_position_uncertainty – float, 1-sigma Gaussian uncertainty on the point source position (only used if point_source_likelihood=True)

  • check_positive_flux – bool, option to punish models that do not have all positive linear amplitude parameters

  • source_position_tolerance – float, punishment of check_solver occurs when image positions are predicted further away than this number

  • image_likelihood_mask_list – list of boolean 2d arrays of size of images marking the pixels to be evaluated in the likelihood

  • force_no_add_image – bool, if True: computes ALL image positions of the point source. If there are more images predicted than modelled, a punishment occurs

  • source_marg – marginalization addition on the imaging likelihood based on the covariance of the inferred linear coefficients

  • linear_prior – float or list of floats (when multi-linear setting is chosen) indicating the range of linear amplitude priors when computing the marginalization term.

  • restrict_image_number – bool, if True: computes ALL image positions of the point source. If there are more images predicted than indicated in max_num_images, a punishment occurs

  • max_num_images – int, see restrict_image_number

  • bands_compute – list of bools with same length as data objects, indicates which “band” to include in the fitting

  • time_delay_likelihood – bool, if True computes the time-delay likelihood of the FIRST point source

  • kwargs_flux_compute – keyword arguments of how to compute the image position fluxes (see FluxRatioLikeliood)

  • custom_logL_addition – a definition taking as arguments (kwargs_lens, kwargs_source, kwargs_lens_light, kwargs_ps, kwargs_special, kwargs_extinction) and returns a logL (punishing) value.

  • kwargs_pixelbased – keyword arguments with various settings related to the pixel-based solver (see SLITronomy documentation)

  • kinematic_2d_likelihood – bool, option to compute the kinematic likelihood

  • tracer_likelihood – option to perform likelihood on tracer quantity derived from imaging or spectroscopy

property kwargs_imaging

Dictionary of imaging model keyword arguments.

Returns:

kwargs_imaging

logL(args, verbose=False)[source]

Routine to compute X2 given variable parameters for a MCMC/PSO chain.

Parameters:
  • args (tuple or list of floats) – ordered parameter values that are being sampled

  • verbose (boolean) – if True, makes print statements about individual likelihood components

Returns:

log likelihood of the data given the model (natural logarithm)

log_likelihood(kwargs_return, verbose=False)[source]
Parameters:
  • kwargs_return (keyword arguments) – need to contain ‘kwargs_lens’, ‘kwargs_source’, ‘kwargs_lens_light’, ‘kwargs_ps’, ‘kwargs_special’. These entries themselves are lists of keyword argument of the parameters entering the model to be evaluated

  • verbose (boolean) – if True, makes print statements about individual likelihood components

Returns:

  • logL (float) log likelihood of the data given the model (natural logarithm)

static check_bounds(args, lowerLimit, upperLimit, verbose=False)[source]

Checks whether the parameter vector has left its bound, if so, adds a big number.

property num_data
Returns:

number of independent data points in the combined fitting

property param_limits
effective_num_data_points(**kwargs)[source]

Returns the effective number of data points considered in the X2 estimation to compute the reduced X2 value.

likelihood(a)[source]
negativelogL(a)[source]

For minimizer function, the negative value of the logl value is requested.

Parameters:

a – array of parameters

Returns:

-logL

Module contents