coolest.api.composable_models#

Classes#

BaseComposableModel

Given a COOLEST object, evaluates a selection of mass or light profiles.

ComposableLightModel

Given a COOLEST object, evaluates a selection of entity and their light profiles.

ComposableMassModel

Given a COOLEST object, evaluates a selection of entity and their mass profiles.

ComposableLensModel

Given a COOLEST object, evaluates a selection of entity and

Module Contents#

class BaseComposableModel(model_type, coolest_object, coolest_directory=None, load_posterior_samples=False, entity_selection=None, profile_selection=None)[source]#

Given a COOLEST object, evaluates a selection of mass or light profiles. This class serves as parent for more specific classes and should not be instantiated by the user.

Parameters:
  • model_type (str) – Either ‘light_model’ or ‘mass_model’

  • coolest_object (COOLEST) – COOLEST instance

  • coolest_directory (str, optional) – Directory which contains the COOLEST template, by default None

  • load_posterior_samples (bool, optional) – If True, and if the COOLEST metadata provides it, the constructor will attempt to load the chain file containing posterior samples, in addition to point estimates for each profile parameters. Default is False.

  • entity_selection (list, optional) – List of indices of the lensing entities to consider; If None, selects the first entity which has a model of type model_type, by default None

  • profile_selection (list, optional) – List of either lists of indices, or ‘all’, for selecting which (mass or light) profile of a given lensing entity to consider. If None, selects all the profiles of within the corresponding entity, by default None

Raises:

ValueError – No valid entity found or no profiles found.

directory = None[source]#
num_profiles = 0[source]#
setup_profiles_and_params(model_type, entities, entity_selection, profile_selection)[source]#
estimate_center()[source]#
class ComposableLightModel(coolest_object, coolest_directory=None, **kwargs_selection)[source]#

Given a COOLEST object, evaluates a selection of entity and their light profiles.

Parameters:
  • coolest_object (COOLEST) – COOLEST instance

  • coolest_directory (str, optional) – Directory which contains the COOLEST template, by default None

  • entity_selection (list, optional) – List of indices of the lensing entities to consider; If None, selects the first entity that has a light model, by default None

  • profile_selection (list, optional) – List of either lists of indices, or ‘all’, for selecting which light profile of a given lensing entity to consider. If None, selects all the profiles of within the corresponding entity, by default None

Raises:

ValueError – No valid entity found or no profiles found.

surface_brightness(return_extra=False)[source]#

Returns the surface brightness as stored in the COOLEST file

evaluate_surface_brightness(x, y)[source]#

Evaluates the surface brightness at given coordinates

class ComposableMassModel(coolest_object, coolest_directory=None, load_posterior_samples=False, **kwargs_selection)[source]#

Given a COOLEST object, evaluates a selection of entity and their mass profiles.

Parameters:
  • coolest_object (COOLEST) – COOLEST instance

  • coolest_directory (str, optional) – Directory which contains the COOLEST template, by default None

  • entity_selection (list, optional) – List of indices of the lensing entities to consider; If None, selects the first entity that has a mass model, by default None

  • profile_selection (list, optional) – List of either lists of indices, or ‘all’, for selecting which mass profile of a given lensing entity to consider. If None, selects all the profiles of within the corresponding entity, by default None

Raises:

ValueError – No valid entity found or no profiles found.

evaluate_potential(x, y, mode='point', last_n_samples=None)[source]#

Evaluates the lensing potential field at given coordinates

fermat_potential(x, y, x_src, y_src, mode='point', last_n_samples=None)[source]#

Computes the Fermat potential for image (x, y) and source position (x_src, y_src)

evaluate_deflection(x, y)[source]#

Evaluates the lensing deflection field at given coordinates

evaluate_convergence(x, y)[source]#

Evaluates the lensing convergence (i.e., 2D mass density) at given coordinates

evaluate_hessian(x, y)[source]#

Evaluates the lensing Hessian components at given coordinates

evaluate_jacobian(x, y)[source]#

Evaluates the lensing Jacobian (d beta / d theta) at given coordinates

evaluate_magnification(x, y)[source]#

Evaluates the lensing magnification at given coordinates

ray_shooting(x, y)[source]#

evaluates the lens equation beta = theta - alpha(theta)

class ComposableLensModel(coolest_object, coolest_directory=None, kwargs_selection_source=None, kwargs_selection_lens_mass=None)[source]#

Given a COOLEST object, evaluates a selection of entity and their mass and light profiles, typically to construct an image of the lens.

Parameters:
  • coolest_object (COOLEST) – COOLEST instance

  • coolest_directory (str, optional) – Directory which contains the COOLEST template, by default None

  • entity_selection (list, optional) – List of indices of the lensing entities to consider; If None, selects the first entity that has a light/mass model, by default None

  • profile_selection (list, optional) – List of either lists of indices, or ‘all’, for selecting which light/mass profile of a given lensing entity to consider. If None, selects all the profiles of within the corresponding entity, by default None

Raises:

ValueError – No valid entity found or no profiles found.

coolest[source]#
coord_obs[source]#
directory = None[source]#
lens_mass[source]#
source[source]#
model_image(supersampling=5, convolved=True, super_convolution=True)[source]#

generates an image of the lens based on the selected model components

model_residuals(mask=None, **model_image_kwargs)[source]#

computes the normalized residuals map as (data - model) / sigma

evaluate_lensed_surface_brightness(x, y)[source]#

Evaluates the surface brightness of a lensed source at given coordinates

ray_shooting(x, y)[source]#

evaluates the lens equation beta = theta - alpha(theta)