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

Functions#

auto_select_entities(coolest_object)

Module Contents#

auto_select_entities(coolest_object)[source]#
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

  • kwargs_selection (dict, optional) – Keyword arguments for selecting which entities and profiles to consider, see BaseComposableModel for details.

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

  • kwargs_selection (dict, optional) – Keyword arguments for selecting which entities and profiles to consider, see BaseComposableModel for details.

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, auto_selection=True, kwargs_selection_source=None, kwargs_selection_lens_mass=None, kwargs_selection_lens_light=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

  • auto_selection (bool, True) – If True, will select entities based on their lensed attributes. In particular, all entities having a lensed=True will be associated to a ComposableLightModel for the source, and all entities having lensed=False will be associated to a ComposableLightModel and ComposableLightModel for the lens If False, the user should provide the appropriate keyword arguments in the kwargs_selection_* arguments.

  • kwargs_selection_lens_mass (dict, optional) – Keyword arguments for ComposableMassModel to select which entities and their profiles to consider for the lens mass model.

  • kwargs_selection_lens_light (dict, optional) – Keyword arguments for ComposableLightModel to select which entities and their profiles to consider for the lens light model.

  • kwargs_selection_source (dict, optional) – Keyword arguments for ComposableLightModel to select which entities and their profiles to consider for the source light model.

Raises:

ValueError – No valid entity found or no profiles found.

coolest[source]#
coord_obs[source]#
directory = None[source]#
lens_mass[source]#
lens_light[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)