autolens.FitPositionsSource#
- class FitPositionsSource[source]#
Bases:
AbstractFitPositionsFits the positions of a a point source dataset using a Tracer object with a source-plane chi-squared based on the separation of image-plane positions ray-traced to the source-plane compared to the centre of the source galaxy.
The fit performs the following steps:
Determine the source-plane centre of the source-galaxy, which is either a free model parameter read from the profile’s centre (ag.ps.Point / ag.ps.PointFlux) or, for FitPositionsSourceSolved, solved for analytically given the current tracer (see autolens.point.fit.solved.SolvedCentre), using name pairing (see below).
Ray-trace the positions in the point source to the source-plane via the Tracer, including accounting for multi-plane ray-tracing.
Compute the distance of each ray-traced position to the source-plane centre and compute the residuals,
Compute the magnification of each image-plane position via the Hessian of the tracer’s deflection angles.
Compute the residuals of each position as the difference between the source-plane centre and each ray-traced position.
Compute the chi-squared of each position as the square of the residual multiplied by the magnification and divided by the RMS noise-map value.
Sum the chi-squared values to compute the overall log likelihood of the fit.
Steps 4-6 describe the default weighting = “magnification” scalar convention. Setting the weighting class attribute to “jacobian” instead weights each vector residual β̂ᵢ − c (with c the profile’s free centre) by the per-image precision tensor Wᵢ = Aᵢ⁻ᵀΘᵢAᵢ⁻¹ (see autolens.point.fit.solved.precision_tensor_components_from), with the observed-plane noise normalization matching FitPositionsSourceSolved — the same tensor likelihood as that class, but with the centre sampled as a free parameter rather than solved and marginalized.
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 (
Optional[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. This is not used in this source-plane point source fit.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
Attributes
chi_squaredReturns the chi-squared terms of the model data's fit to an dataset, by summing the chi-squared-map.
Returns the chi-squared of the point-source source-plane fit.
dataOverwrite this method to returns the data of the dataset.
Returns the log likelihood of the point-source source-plane fit, which is the sum of the chi-squared values.
magnifications_at_positionsThe magnification of every observed position in the image-plane, which is computed from the tracer's deflection angle map via the Hessian.
Returns the source-plane model positions of the point source, which are the positions of the image-plane positions ray-traced to the source-plane.
noise_mapOverwrite this method to returns the noise-map of the dataset.
Returns the noise normalization of the fit's Gaussian likelihood.
normalized_residual_mapReturns the normalized residual-map between the masked dataset and model data, where:
plane_indexReturns 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_redshiftReturns 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.
positionsReturns the residuals of the point-source source-plane fit, which are the distances of each source-plane position from the source-plane centre.
the back-traced source-plane positions minus the source-plane centre c (here the profile's free centre; FitPositionsSourceSolved overrides this to use the solved β* via _beta_hat, tolerating plain-ndarray test inputs).
signal_to_noise_mapThe signal-to-noise_map of the dataset and noise-map which are fitted.
source_plane_coordinateReturns the centre of the point-source in the source-plane, which is used when computing the model image-plane positions from the tracer.
How each back-traced position's residual from the source-plane centre is weighted: "magnification" — the traditional scalar µᵢ²/σᵢ² weighting with the magnified-noise normalization (the long-standing behaviour of this class, and the Lenstool convention); "jacobian" — the per-image precision tensor Wᵢ = Aᵢ⁻ᵀΘᵢAᵢ⁻¹ with the observed-plane normalization, matching FitPositionsSourceSolved but with the centre a free parameter.
- weighting = 'magnification'#
How each back-traced position’s residual from the source-plane centre is weighted: “magnification” — the traditional scalar µᵢ²/σᵢ² weighting with the magnified-noise normalization (the long-standing behaviour of this class, and the Lenstool convention); “jacobian” — the per-image precision tensor Wᵢ = Aᵢ⁻ᵀΘᵢAᵢ⁻¹ with the observed-plane normalization, matching FitPositionsSourceSolved but with the centre a free parameter.
- property model_data: Grid2DIrregular#
Returns the source-plane model positions of the point source, which are the positions of the image-plane positions ray-traced to the source-plane.
This calculation accounts for multi-plane ray-tracing, whereby if the tracer has more than 2 planees the redshift of the point source galaxy is extracted and the deflections between the image-plane and source-plane at its specific redshift are used.
- property residual_map: ArrayIrregular#
Returns the residuals of the point-source source-plane fit, which are the distances of each source-plane position from the source-plane centre.
- property residual_vectors: ndarray#
the back-traced source-plane positions minus the source-plane centre c (here the profile’s free centre; FitPositionsSourceSolved overrides this to use the solved β* via _beta_hat, tolerating plain-ndarray test inputs).
- Type:
The (n_positions, 2) array of vector residuals β̂ᵢ − c
- property chi_squared_map: float#
Returns the chi-squared of the point-source source-plane fit.
For weighting = “magnification” this is the squared residuals multiplied by the magnifications squared, divided by the noise-map values squared. For weighting = “jacobian” it is the per-image quadratic form (β̂ᵢ−c)ᵀ Wᵢ (β̂ᵢ−c) with the precision tensor Wᵢ = Aᵢ⁻ᵀΘᵢAᵢ⁻¹.
- property noise_normalization: float#
Returns the noise normalization of the fit’s Gaussian likelihood.
For weighting = “magnification” this is the long-standing magnified-noise source-plane-data convention Σᵢ log(2π µᵢ⁻²σᵢ²). For weighting = “jacobian” it is the observed-plane (model-independent) convention Σᵢ log((2π)² σᵢ⁴) matching FitPositionsSourceSolved (see that class’s docstring for why a model-dependent normalization would spuriously favour high-magnification models).