autolens.FitPositionsImagePairRepeat#

class FitPositionsImagePairRepeat[source]#

Bases: AbstractFitPositionsImagePair

Abstract class to fit the positions of a point source dataset using a Tracer object with an image-plane chi-squared, where the specific implementation of the image-plane chi-squared is defined in the sub-class.

The fit performs the following steps:

  1. Determine the source-plane centre of the point source, which could be a free model parameter or computed as the barycenter of ray-traced positions in the source-plane, using name pairing (see below).

  2. Determine the image-plane model positions using the PointSolver and the source-plane centre of the point source (e.g. ray tracing triangles to and from the image and source planes), including accounting for multi-plane ray-tracing.

  3. Using the sub-class specific chi-squared, compute the residuals of each image-plane position, chi-squared and overall log likelihood of the fit.

Point source fitting uses name pairing, whereby the name of the Point object is paired to the name of the point source dataset to ensure that point source datasets are fitted to the correct point source.

This fit object is used in the FitPointDataset to perform position based fitting of a PointDataset, which may also fit other components of the point dataset like fluxes or time delays.

When performing a model-fit`via an `AnalysisPoint object the figure_of_merit of this object is called and returned in the log_likelihood_function.

Parameters:
  • name (str) – The name of the point source dataset which is paired to a Point profile.

  • data (Grid2DIrregular) – The positions of the point source in the image-plane which are fitted.

  • noise_map (ArrayIrregular) – The noise-map of the positions which are used to compute the log likelihood of the positions.

  • tracer (Tracer) – The tracer of galaxies whose point source profile are used to fit the positions.

  • solver (PointSolver) – Solves the lens equation in order to determine the image-plane positions of a point source by ray-tracing triangles to and from the source-plane.

  • profile (Optional[Point]) – Manually input the profile of the point source, which is used instead of the one extracted from the tracer via name pairing if that profile is not found.

Methods

square_distance

Calculate the square distance between two points.

Attributes

chi_squared

the observed-position chi-squared (as in all AbstractFit objects) plus, for policies other than "ignore", the unmatched-model penalty terms normalized by the mean position noise.

chi_squared_map

Returns the chi-squared-map between the residual-map and noise-map, where:

data

Overwrite this method to returns the data of the dataset.

log_likelihood

Returns the log likelihood of each model data point's fit to the dataset, where:

magnification_threshold

magnifications_at_positions

The magnification of every observed position in the image-plane, which is computed from the tracer's deflection angle map via the Hessian.

model_data

Returns the model positions, which are computed via the point solver.

n_unmatched_model_positions

The number of model positions the policy counts as unexplained extras — a useful fit-quality diagnostic alongside the chi-squared.

no_image_residual

noise_map

Overwrite this method to returns the noise-map of the dataset.

noise_normalization

Returns the noise-map normalization term of the noise-map, summing the noise_map value in every pixel as:

normalized_residual_map

Returns the normalized residual-map between the masked dataset and model data, where:

plane_index

Returns the integer plane index containing the point source galaxy, which is used when computing the deflection angles of image-plane positions from the tracer.

plane_redshift

Returns the redshift of the plane containing the point source galaxy, which is used when computing the deflection angles of image-plane positions from the tracer.

positions

residual_map

The distance of every observed position to its nearest model position (repeats allowed).

signal_to_noise_map

The signal-to-noise_map of the dataset and noise-map which are fitted.

source_plane_coordinate

Returns the centre of the point-source in the source-plane, which is used when computing the model image-plane positions from the tracer.

unmatched_model_mask

finite model positions which are not the nearest neighbour of any observed position and (under "magnification_filter") whose absolute magnification is above magnification_threshold.

unmatched_model_penalty_map

its distance to the nearest observed position where the unmatched_model_mask is set, zero elsewhere.

unmatched_model_policy

unmatched_model_policy = 'magnification_filter'#
magnification_threshold = 0.1#
no_image_residual = 10000.0#
property residual_map: ArrayIrregular#

The distance of every observed position to its nearest model position (repeats allowed).

If the solver returns no images (or only NaN-padded rows), every observed position contributes the no_image_residual floor.

property unmatched_model_mask#

finite model positions which are not the nearest neighbour of any observed position and (under "magnification_filter") whose absolute magnification is above magnification_threshold.

Type:

Boolean mask over the model positions marking the “extra” images the policy penalizes

property unmatched_model_penalty_map#

its distance to the nearest observed position where the unmatched_model_mask is set, zero elsewhere.

Type:

The penalty residual of every model position

property n_unmatched_model_positions: int#

The number of model positions the policy counts as unexplained extras — a useful fit-quality diagnostic alongside the chi-squared.

property chi_squared: float#

the observed-position chi-squared (as in all AbstractFit objects) plus, for policies other than "ignore", the unmatched-model penalty terms normalized by the mean position noise.

Type:

The chi-squared of the fit