From 481c4c6f4a1bbcdc238bc98cfe2e03a08d62b7a9 Mon Sep 17 00:00:00 2001 From: NiekWielders Date: Thu, 14 May 2026 10:01:46 +0100 Subject: [PATCH 1/2] added maximum threshold --- autolens/analysis/result.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/autolens/analysis/result.py b/autolens/analysis/result.py index 4f806baef..185aa98ab 100644 --- a/autolens/analysis/result.py +++ b/autolens/analysis/result.py @@ -263,6 +263,7 @@ def positions_likelihood_from( self, factor=1.0, minimum_threshold=None, + maximum_threshold=None, positions: Optional[aa.Grid2DIrregular] = None, mass_centre_radial_distance_min: float = None, plane_redshift: Optional[float] = None, @@ -289,6 +290,9 @@ def positions_likelihood_from( minimum_threshold The output threshold is rounded up to this value if it is below it, to avoid extremely small threshold values. + maximum_threshold + The output threshold is rounded down to this value if it is above it, to avoid extremely large threshold + values. positions If input, these positions are used instead of the computed multiple image positions from the lens mass model. @@ -380,6 +384,9 @@ def positions_likelihood_from( plane_redshift=plane_redshift, ) + if maximum_threshold is not None: + threshold = min(threshold, maximum_threshold) + return PositionsLH( positions=positions, threshold=threshold, plane_redshift=plane_redshift ) From 1c07544d84af997a953793b0ebc1aa509c69752c Mon Sep 17 00:00:00 2001 From: NiekWielders Date: Thu, 14 May 2026 20:16:39 +0100 Subject: [PATCH 2/2] made maximum_threshold symmetric with minimum --- autolens/analysis/result.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/autolens/analysis/result.py b/autolens/analysis/result.py index 185aa98ab..37fd8c0cc 100644 --- a/autolens/analysis/result.py +++ b/autolens/analysis/result.py @@ -197,6 +197,7 @@ def positions_threshold_from( self, factor=1.0, minimum_threshold=None, + maximum_threshold=None, positions: Optional[aa.Grid2DIrregular] = None, plane_redshift: Optional[float] = None, ) -> float: @@ -224,6 +225,9 @@ def positions_threshold_from( minimum_threshold The output threshold is rounded up to this value if it is below it, to avoid extremely small threshold values. + maximum_threshold + The output threshold is rounded down to this value if it is above it, to avoid extremely large threshold + values. positions If input, these positions are used instead of the computed multiple image positions from the lens mass model. @@ -257,6 +261,10 @@ def positions_threshold_from( if threshold < minimum_threshold: return minimum_threshold + if maximum_threshold is not None: + if threshold > maximum_threshold: + return maximum_threshold + return threshold def positions_likelihood_from( @@ -380,13 +388,11 @@ def positions_likelihood_from( threshold = self.positions_threshold_from( factor=factor, minimum_threshold=minimum_threshold, + maximum_threshold=maximum_threshold, positions=positions, plane_redshift=plane_redshift, ) - if maximum_threshold is not None: - threshold = min(threshold, maximum_threshold) - return PositionsLH( positions=positions, threshold=threshold, plane_redshift=plane_redshift )