From 3fc9543be1c231c5e842667c2590ebe2f5dfc200 Mon Sep 17 00:00:00 2001 From: Niek Wielders Date: Tue, 10 Feb 2026 10:21:40 +0000 Subject: [PATCH 1/9] convergence and potential of cnfw back to zeros instead of error warning --- autogalaxy/profiles/mass/dark/cnfw.py | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/autogalaxy/profiles/mass/dark/cnfw.py b/autogalaxy/profiles/mass/dark/cnfw.py index 5ae5734a4..1dd868b22 100644 --- a/autogalaxy/profiles/mass/dark/cnfw.py +++ b/autogalaxy/profiles/mass/dark/cnfw.py @@ -156,10 +156,7 @@ def convergence_2d_from(self, grid: aa.type.Grid2DLike, xp=np, **kwargs): Convergence (dimensionless surface mass density) for the cored NFW profile. This is not yet implemented for `cNFWSph`. """ - raise NotImplementedError( - "convergence_2d_from is not implemented for cNFWSph; a physical cNFW " - "convergence expression must be added before use." - ) + return xp.zeros(shape=grid.shape[0]) @aa.grid_dec.to_array def potential_2d_from(self, grid: aa.type.Grid2DLike, xp=np, **kwargs): @@ -167,7 +164,4 @@ def potential_2d_from(self, grid: aa.type.Grid2DLike, xp=np, **kwargs): Lensing potential for the cored NFW profile. This is not yet implemented for `cNFWSph`. """ - raise NotImplementedError( - "potential_2d_from is not implemented for cNFWSph; a physical cNFW " - "potential expression must be added before use." - ) + return xp.zeros(shape=grid.shape[0]) \ No newline at end of file From 15d6e7ed896307491064a7adbaa7600ffe65a9bd Mon Sep 17 00:00:00 2001 From: Niek Wielders Date: Thu, 12 Feb 2026 14:48:07 +0000 Subject: [PATCH 2/9] added cnfw_mcr_scatter.py --- .../profiles/mass/dark/cnfw_mcr_scatter.py | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 autogalaxy/profiles/mass/dark/cnfw_mcr_scatter.py diff --git a/autogalaxy/profiles/mass/dark/cnfw_mcr_scatter.py b/autogalaxy/profiles/mass/dark/cnfw_mcr_scatter.py new file mode 100644 index 000000000..46ac9d4a7 --- /dev/null +++ b/autogalaxy/profiles/mass/dark/cnfw_mcr_scatter.py @@ -0,0 +1,42 @@ +from typing import Tuple + +from autogalaxy.profiles.mass.dark.cnfw import cNFWSph + +from autogalaxy.profiles.mass.dark import mcr_util + + +class cNFWMCRLudlowSph(cNFWSph): + def __init__( + self, + centre: Tuple[float, float] = (0.0, 0.0), + mass_at_200: float = 1e9, + scatter_sigma: float = 0.0, + f_c=0.01, + redshift_object: float = 0.5, + redshift_source: float = 1.0, + ): + self.mass_at_200 = mass_at_200 + self.scatter_sigma = scatter_sigma + self.f_c = f_c + self.redshift_object = redshift_object + self.redshift_source = redshift_source + + ( + kappa_s, + scale_radius, + core_radius, + radius_at_200, + ) = mcr_util.kappa_s_scale_radius_and_core_radius_for_ludlow( + mass_at_200=mass_at_200, + scatter_sigma=scatter_sigma, + f_c=f_c, + redshift_object=redshift_object, + redshift_source=redshift_source, + ) + + super().__init__( + centre=centre, + kappa_s=kappa_s, + scale_radius=scale_radius, + core_radius=core_radius, + ) \ No newline at end of file From bda2bd96c502b2932d3d6f6aab990e6e643d531d Mon Sep 17 00:00:00 2001 From: Niek Wielders Date: Thu, 12 Feb 2026 14:52:15 +0000 Subject: [PATCH 3/9] gave class correct name scatter --- autogalaxy/profiles/mass/dark/cnfw_mcr_scatter.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autogalaxy/profiles/mass/dark/cnfw_mcr_scatter.py b/autogalaxy/profiles/mass/dark/cnfw_mcr_scatter.py index 46ac9d4a7..14b1a75f3 100644 --- a/autogalaxy/profiles/mass/dark/cnfw_mcr_scatter.py +++ b/autogalaxy/profiles/mass/dark/cnfw_mcr_scatter.py @@ -5,7 +5,7 @@ from autogalaxy.profiles.mass.dark import mcr_util -class cNFWMCRLudlowSph(cNFWSph): +class cNFWMCRScatterLudlowSph(cNFWSph): def __init__( self, centre: Tuple[float, float] = (0.0, 0.0), From 230291f53e8486960f44be06fe181c74d55c1ce0 Mon Sep 17 00:00:00 2001 From: Niek Wielders Date: Thu, 12 Feb 2026 14:53:11 +0000 Subject: [PATCH 4/9] update dark/__init__.py --- autogalaxy/profiles/mass/dark/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/autogalaxy/profiles/mass/dark/__init__.py b/autogalaxy/profiles/mass/dark/__init__.py index 5a7b29895..4fdc2cae5 100644 --- a/autogalaxy/profiles/mass/dark/__init__.py +++ b/autogalaxy/profiles/mass/dark/__init__.py @@ -11,3 +11,4 @@ from .nfw_virial_mass_conc import NFWVirialMassConcSph from .cnfw import cNFWSph from .cnfw_mcr import cNFWMCRLudlowSph +from .cnfw_mcr_scatter import cNFWMCRScatterLudlowSph From e8f976befff50a43dffd591ff7d5826b15e73a88 Mon Sep 17 00:00:00 2001 From: Niek Wielders Date: Thu, 12 Feb 2026 14:54:10 +0000 Subject: [PATCH 5/9] update mass/__init__.py --- autogalaxy/profiles/mass/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/autogalaxy/profiles/mass/__init__.py b/autogalaxy/profiles/mass/__init__.py index 8ec0fa820..28b65b7f2 100644 --- a/autogalaxy/profiles/mass/__init__.py +++ b/autogalaxy/profiles/mass/__init__.py @@ -38,6 +38,7 @@ NFWVirialMassConcSph, cNFWSph, cNFWMCRLudlowSph, + cNFWMCRScatterLudlowSph, ) from .stellar import ( Gaussian, From ebc72739dddc8730bfceebf46599aa340a2a8d40 Mon Sep 17 00:00:00 2001 From: Niek Wielders Date: Thu, 12 Feb 2026 14:56:18 +0000 Subject: [PATCH 6/9] added cnfw mcr scatter priors --- .../priors/mass/dark/cnfw_mcr_scatter.yaml | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 autogalaxy/config/priors/mass/dark/cnfw_mcr_scatter.yaml diff --git a/autogalaxy/config/priors/mass/dark/cnfw_mcr_scatter.yaml b/autogalaxy/config/priors/mass/dark/cnfw_mcr_scatter.yaml new file mode 100644 index 000000000..907ca18aa --- /dev/null +++ b/autogalaxy/config/priors/mass/dark/cnfw_mcr_scatter.yaml @@ -0,0 +1,71 @@ +cNFWMCRScatterLudlowSph: + centre_0: + type: Gaussian + mean: 0.0 + sigma: 0.1 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + centre_1: + type: Gaussian + mean: 0.0 + sigma: 0.1 + width_modifier: + type: Absolute + value: 0.05 + limits: + lower: -inf + upper: inf + mass_at_200: + type: LogUniform + lower_limit: 100000000.0 + upper_limit: 1000000000000000.0 + width_modifier: + type: Relative + value: 0.5 + limits: + lower: 0.0 + upper: inf + f_c: + type: Uniform + lower_limit: 0.0001 + upper_limit: 0.5 + width_modifier: + type: Relative + value: 0.2 + limits: + lower: 0.0001 + upper: inf + redshift_object: + type: Uniform + lower_limit: 0.0 + upper_limit: 1.0 + width_modifier: + type: Relative + value: 0.5 + limits: + lower: 0.0 + upper: inf + redshift_source: + type: Uniform + lower_limit: 0.0 + upper_limit: 1.0 + width_modifier: + type: Relative + value: 0.5 + limits: + lower: 0.0 + upper: inf + scatter: + type: Gaussian + mean: 0.0 + sigma: 3.0 + width_modifier: + type: Absolute + value: 1.0 + limits: + lower: -inf + upper: inf \ No newline at end of file From 58c2a28cf18a9d1ebde6115df2dffe3387a06922 Mon Sep 17 00:00:00 2001 From: Niek Wielders Date: Thu, 12 Feb 2026 15:06:47 +0000 Subject: [PATCH 7/9] added tests for cNFWScatterLudlow --- .../profiles/mass/dark/test_nfw_scatter.py | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/test_autogalaxy/profiles/mass/dark/test_nfw_scatter.py b/test_autogalaxy/profiles/mass/dark/test_nfw_scatter.py index 91f621a44..291272e9f 100644 --- a/test_autogalaxy/profiles/mass/dark/test_nfw_scatter.py +++ b/test_autogalaxy/profiles/mass/dark/test_nfw_scatter.py @@ -59,3 +59,27 @@ def test__scatter_is_nonzero(): deflections_ell = nfw_ell.deflections_yx_2d_from(grid=grid) assert deflections_sph[0] != pytest.approx(deflections_ell[0], 1.0e-4) + + # Testing the cored NFW + + cnfw_sph = ag.mp.cNFWMCRScatterLudlowSph( + ell_comps=(0.5, 0.5), + mass_at_200=1.0e9, + scatter_sigma=1.0, + f_c=0.01, + redshift_object=0.6, + redshift_source=2.5, + ) + + assert cnfw_sph.scale_radius == pytest.approx(0.14978, 1.0e-4) + + cnfw_sph = ag.mp.cNFWMCRScatterLudlowSph( + ell_comps=(0.5, 0.5), + mass_at_200=1.0e9, + scatter_sigma=-1.0, + f_c=0.01, + redshift_object=0.6, + redshift_source=2.5, + ) + + assert cnfw_sph.scale_radius == pytest.approx(0.29886, 1.0e-4) From 6e00708418775d7b5ae79e21ed9030239b187d9d Mon Sep 17 00:00:00 2001 From: Niek Wielders Date: Thu, 12 Feb 2026 15:18:27 +0000 Subject: [PATCH 8/9] removed ell_comps in cnfw test --- test_autogalaxy/profiles/mass/dark/test_nfw_scatter.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/test_autogalaxy/profiles/mass/dark/test_nfw_scatter.py b/test_autogalaxy/profiles/mass/dark/test_nfw_scatter.py index 291272e9f..84765875e 100644 --- a/test_autogalaxy/profiles/mass/dark/test_nfw_scatter.py +++ b/test_autogalaxy/profiles/mass/dark/test_nfw_scatter.py @@ -60,10 +60,10 @@ def test__scatter_is_nonzero(): assert deflections_sph[0] != pytest.approx(deflections_ell[0], 1.0e-4) - # Testing the cored NFW + +def test__scatter_is_nonzero_cored(): cnfw_sph = ag.mp.cNFWMCRScatterLudlowSph( - ell_comps=(0.5, 0.5), mass_at_200=1.0e9, scatter_sigma=1.0, f_c=0.01, @@ -74,7 +74,6 @@ def test__scatter_is_nonzero(): assert cnfw_sph.scale_radius == pytest.approx(0.14978, 1.0e-4) cnfw_sph = ag.mp.cNFWMCRScatterLudlowSph( - ell_comps=(0.5, 0.5), mass_at_200=1.0e9, scatter_sigma=-1.0, f_c=0.01, From fee7acb456b6fdd998ad5de8b320a0df60febf3d Mon Sep 17 00:00:00 2001 From: Niek Wielders Date: Fri, 13 Feb 2026 10:15:07 +0000 Subject: [PATCH 9/9] deleted blank line --- test_autogalaxy/profiles/mass/dark/test_nfw_scatter.py | 1 - 1 file changed, 1 deletion(-) diff --git a/test_autogalaxy/profiles/mass/dark/test_nfw_scatter.py b/test_autogalaxy/profiles/mass/dark/test_nfw_scatter.py index 84765875e..9bb2eb066 100644 --- a/test_autogalaxy/profiles/mass/dark/test_nfw_scatter.py +++ b/test_autogalaxy/profiles/mass/dark/test_nfw_scatter.py @@ -61,7 +61,6 @@ def test__scatter_is_nonzero(): assert deflections_sph[0] != pytest.approx(deflections_ell[0], 1.0e-4) - def test__scatter_is_nonzero_cored(): cnfw_sph = ag.mp.cNFWMCRScatterLudlowSph( mass_at_200=1.0e9,