autolens.PositionsLH#
- class PositionsLH[source]#
Bases:
objectThe PositionsLH objects add a penalty term to the likelihood of the PyAutoLens log_likelihood_function defined in the Analysis classes.
The penalty term inspects the distance that the locations of the multiple images of the lensed source galaxy trace within one another in the source-plane and penalizes solutions where they trace far from one another, on the basis that this indicates an unphysical or inaccurate mass model. If they trace within the threshold the penalty term is not applied.
For the PositionsLH object, if the multiple image coordinates do not trace within the source-plane threshold of one another a penalty to the likelihood is applied:
log_Likelihood_penalty_base - log_likelihood_penalty_factor * (max_source_plane_separation - threshold)
The penalty term reduces as the source-plane coordinates trace closer to one another, meaning that the initial stages of the non-linear search can sample mass models that reduce the threshold.
For example, for one penalty term, if the multiple image coordinates are defined via positions=aa.Grid2DIrregular([(1.0, 0.0), (-1.0, 0.0)] and they do not trace within threshold=0.3 of one another, the mass model will receive a large likelihood penalty.
The default behaviour assumes a single lens plane and single source plane, meaning the input positions are the image-plane coordinates of one source galaxy at a specifc redshift.
For multiple source planes, the plane_redshift can be used to pair the image-plane positions with the redshift of the source plane they trace too.
- Parameters:
positions (
Grid2DIrregular) – The arcsecond coordinates of the lensed source multiple images which are used to compute the likelihood penalty.threshold (
float) – If the maximum separation of any two source plane coordinates is above the threshold the penalty term is applied.log_likelihood_penalty_factor (
float) – A factor which multiplies how far source pixels do not trace within the threshold of one another, with a larger factor producing a larger penalty making the non-linear parameter space gradient steeper.plane_redshift (
Optional[float]) – The plane redshift of the lensed source multiple images, which is only required if position threshold for a double source plane lens system is being used where the specific plane is required.
Methods
Returns a log-likelihood penalty used to constrain lens models where multiple image-plane positions do not trace to within a threshold distance of one another in the source-plane.
Outputs a positions.info file which summarises the positions penalty term for a model fit, including:
- output_positions_info(output_path, tracer, overwrite_file=True)[source]#
Outputs a positions.info file which summarises the positions penalty term for a model fit, including:
The arc second coordinates of the lensed source multiple images used for the model-fit.
The radial distance of these coordinates from (0.0, 0.0).
The threshold value used by the likelihood penalty.
The maximum source plane separation of the maximum likelihood tracer.
- log_likelihood_penalty_from(instance, analysis, xp=<module 'numpy' from '/home/docs/checkouts/readthedocs.org/user_builds/pyautolens/envs/latest/lib/python3.12/site-packages/numpy/__init__.py'>)[source]#
Returns a log-likelihood penalty used to constrain lens models where multiple image-plane positions do not trace to within a threshold distance of one another in the source-plane.
This penalty is intended for use in Analysis classes that include the PenaltyLH mixin. It adds a heavy penalty to the likelihood when the multiple images traces far apart in the source-plane, discouraging models where the mapped source-plane positions are too widely separated.
Specifically, if the maximum separation between traced positions in the source-plane exceeds a defined threshold, a penalty term is applied to the log likelihood:
penalty = log_likelihood_penalty_factor * (max_separation - threshold)
If the separation is within the threshold, no penalty is applied.