Skip to content

Commit d99d74b

Browse files
Jammy2211Jammy2211
authored andcommitted
Merge branch 'main' of github.com:Jammy2211/PyAutoGalaxy
2 parents b868599 + 59174cf commit d99d74b

10 files changed

Lines changed: 470 additions & 39 deletions

File tree

autogalaxy/config/priors/mass/dark/cnfw.yaml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,78 @@
1+
cNFW:
2+
centre_0:
3+
type: Gaussian
4+
mean: 0.0
5+
sigma: 0.1
6+
width_modifier:
7+
type: Absolute
8+
value: 0.05
9+
limits:
10+
lower: -inf
11+
upper: inf
12+
centre_1:
13+
type: Gaussian
14+
mean: 0.0
15+
sigma: 0.1
16+
width_modifier:
17+
type: Absolute
18+
value: 0.05
19+
limits:
20+
lower: -inf
21+
upper: inf
22+
ell_comps_0:
23+
type: TruncatedGaussian
24+
mean: 0.0
25+
sigma: 0.3
26+
lower_limit: -1.0
27+
upper_limit: 1.0
28+
width_modifier:
29+
type: Absolute
30+
value: 0.2
31+
limits:
32+
lower: -1.0
33+
upper: 1.0
34+
ell_comps_1:
35+
type: TruncatedGaussian
36+
mean: 0.0
37+
sigma: 0.3
38+
lower_limit: -1.0
39+
upper_limit: 1.0
40+
width_modifier:
41+
type: Absolute
42+
value: 0.2
43+
limits:
44+
lower: -1.0
45+
upper: 1.0
46+
kappa_s:
47+
type: Uniform
48+
lower_limit: 0.0
49+
upper_limit: 1.0
50+
width_modifier:
51+
type: Relative
52+
value: 0.2
53+
limits:
54+
lower: 0.0
55+
upper: inf
56+
scale_radius:
57+
type: Uniform
58+
lower_limit: 0.0
59+
upper_limit: 30.0
60+
width_modifier:
61+
type: Relative
62+
value: 0.2
63+
limits:
64+
lower: 0.0
65+
upper: inf
66+
core_radius:
67+
type: Uniform
68+
lower_limit: 0.0
69+
upper_limit: 15.0
70+
width_modifier:
71+
type: Relative
72+
value: 0.2
73+
limits:
74+
lower: 0.0
75+
upper: inf
176
cNFWSph:
277
centre_0:
378
type: Gaussian

autogalaxy/config/priors/mass/dark/cnfw_mcr.yaml

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,88 @@
1+
cNFWMCRLudlow:
2+
centre_0:
3+
type: Gaussian
4+
mean: 0.0
5+
sigma: 0.1
6+
width_modifier:
7+
type: Absolute
8+
value: 0.05
9+
limits:
10+
lower: -inf
11+
upper: inf
12+
centre_1:
13+
type: Gaussian
14+
mean: 0.0
15+
sigma: 0.1
16+
width_modifier:
17+
type: Absolute
18+
value: 0.05
19+
limits:
20+
lower: -inf
21+
upper: inf
22+
ell_comps_0:
23+
type: TruncatedGaussian
24+
mean: 0.0
25+
sigma: 0.3
26+
lower_limit: -1.0
27+
upper_limit: 1.0
28+
width_modifier:
29+
type: Absolute
30+
value: 0.2
31+
limits:
32+
lower: -1.0
33+
upper: 1.0
34+
ell_comps_1:
35+
type: TruncatedGaussian
36+
mean: 0.0
37+
sigma: 0.3
38+
lower_limit: -1.0
39+
upper_limit: 1.0
40+
width_modifier:
41+
type: Absolute
42+
value: 0.2
43+
limits:
44+
lower: -1.0
45+
upper: 1.0
46+
mass_at_200:
47+
type: LogUniform
48+
lower_limit: 100000000.0
49+
upper_limit: 1000000000000000.0
50+
width_modifier:
51+
type: Relative
52+
value: 0.5
53+
limits:
54+
lower: 0.0
55+
upper: inf
56+
f_c:
57+
type: Uniform
58+
lower_limit: 0.0001
59+
upper_limit: 0.5
60+
width_modifier:
61+
type: Relative
62+
value: 0.2
63+
limits:
64+
lower: 0.0001
65+
upper: inf
66+
redshift_object:
67+
type: Uniform
68+
lower_limit: 0.0
69+
upper_limit: 1.0
70+
width_modifier:
71+
type: Relative
72+
value: 0.5
73+
limits:
74+
lower: 0.0
75+
upper: inf
76+
redshift_source:
77+
type: Uniform
78+
lower_limit: 0.0
79+
upper_limit: 1.0
80+
width_modifier:
81+
type: Relative
82+
value: 0.5
83+
limits:
84+
lower: 0.0
85+
upper: inf
186
cNFWMCRLudlowSph:
287
centre_0:
388
type: Gaussian

autogalaxy/config/priors/mass/dark/cnfw_mcr_scatter.yaml

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,98 @@
1+
cNFWMCRScatterLudlow:
2+
centre_0:
3+
type: Gaussian
4+
mean: 0.0
5+
sigma: 0.1
6+
width_modifier:
7+
type: Absolute
8+
value: 0.05
9+
limits:
10+
lower: -inf
11+
upper: inf
12+
centre_1:
13+
type: Gaussian
14+
mean: 0.0
15+
sigma: 0.1
16+
width_modifier:
17+
type: Absolute
18+
value: 0.05
19+
limits:
20+
lower: -inf
21+
upper: inf
22+
ell_comps_0:
23+
type: TruncatedGaussian
24+
mean: 0.0
25+
sigma: 0.3
26+
lower_limit: -1.0
27+
upper_limit: 1.0
28+
width_modifier:
29+
type: Absolute
30+
value: 0.2
31+
limits:
32+
lower: -1.0
33+
upper: 1.0
34+
ell_comps_1:
35+
type: TruncatedGaussian
36+
mean: 0.0
37+
sigma: 0.3
38+
lower_limit: -1.0
39+
upper_limit: 1.0
40+
width_modifier:
41+
type: Absolute
42+
value: 0.2
43+
limits:
44+
lower: -1.0
45+
upper: 1.0
46+
mass_at_200:
47+
type: LogUniform
48+
lower_limit: 100000000.0
49+
upper_limit: 1000000000000000.0
50+
width_modifier:
51+
type: Relative
52+
value: 0.5
53+
limits:
54+
lower: 0.0
55+
upper: inf
56+
f_c:
57+
type: Uniform
58+
lower_limit: 0.0001
59+
upper_limit: 0.5
60+
width_modifier:
61+
type: Relative
62+
value: 0.2
63+
limits:
64+
lower: 0.0001
65+
upper: inf
66+
redshift_object:
67+
type: Uniform
68+
lower_limit: 0.0
69+
upper_limit: 1.0
70+
width_modifier:
71+
type: Relative
72+
value: 0.5
73+
limits:
74+
lower: 0.0
75+
upper: inf
76+
redshift_source:
77+
type: Uniform
78+
lower_limit: 0.0
79+
upper_limit: 1.0
80+
width_modifier:
81+
type: Relative
82+
value: 0.5
83+
limits:
84+
lower: 0.0
85+
upper: inf
86+
scatter_sigma:
87+
type: Gaussian
88+
mean: 0.0
89+
sigma: 3.0
90+
width_modifier:
91+
type: Absolute
92+
value: 1.0
93+
limits:
94+
lower: -inf
95+
upper: inf
196
cNFWMCRScatterLudlowSph:
297
centre_0:
398
type: Gaussian

autogalaxy/profiles/mass/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,11 @@
3737
NFWMCRLudlow,
3838
gNFWMCRLudlow,
3939
NFWVirialMassConcSph,
40+
cNFW,
4041
cNFWSph,
42+
cNFWMCRLudlow,
4143
cNFWMCRLudlowSph,
44+
cNFWMCRScatterLudlow,
4245
cNFWMCRScatterLudlowSph,
4346
)
4447
from .stellar import (

autogalaxy/profiles/mass/dark/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@
99
from .nfw_truncated_mcr import NFWTruncatedMCRLudlowSph, NFWTruncatedMCRDuffySph
1010
from .nfw_truncated_mcr_scatter import NFWTruncatedMCRScatterLudlowSph
1111
from .nfw_virial_mass_conc import NFWVirialMassConcSph
12-
from .cnfw import cNFWSph
13-
from .cnfw_mcr import cNFWMCRLudlowSph
14-
from .cnfw_mcr_scatter import cNFWMCRScatterLudlowSph
12+
from .cnfw import cNFW, cNFWSph
13+
from .cnfw_mcr import cNFWMCRLudlow, cNFWMCRLudlowSph
14+
from .cnfw_mcr_scatter import cNFWMCRScatterLudlow, cNFWMCRScatterLudlowSph

autogalaxy/profiles/mass/dark/cnfw.py

Lines changed: 71 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,80 @@
33
from typing import Tuple
44

55
from autogalaxy.profiles.mass.dark.abstract import AbstractgNFW
6+
from autogalaxy.profiles.mass.abstract.mge import MGEDecomposer
67

78
import autoarray as aa
89

910

10-
class cNFWSph(AbstractgNFW):
11+
class cNFW(AbstractgNFW):
12+
def __init__(
13+
self,
14+
centre: Tuple[float, float] = (0.0, 0.0),
15+
ell_comps: Tuple[float, float] = (0.0, 0.0),
16+
kappa_s: float = 0.05,
17+
scale_radius: float = 1.0,
18+
core_radius: float = 0.01,
19+
):
20+
"""
21+
Represents a cored NFW density distribution
22+
23+
Parameters
24+
----------
25+
centre
26+
The (y,x) arc-second coordinates of the profile centre.
27+
ell_comps
28+
The first and second ellipticity components of the elliptical coordinate system.
29+
kappa_s
30+
The overall normalization of the dark matter halo
31+
(kappa_s = (rho_0 * D_d * scale_radius)/lensing_critical_density)
32+
scale_radius
33+
The cored NFW scale radius `theta_s`, as an angle on the sky in arcseconds.
34+
core_radius
35+
The cored NFW core radius `theta_c`, as an angle on the sky in arcseconds.
36+
"""
37+
38+
super().__init__(centre=centre, ell_comps=ell_comps)
39+
40+
self.kappa_s = kappa_s
41+
self.scale_radius = scale_radius
42+
self.core_radius = core_radius
43+
44+
45+
def deflections_yx_2d_from(self, grid: aa.type.Grid2DLike, xp=np, **kwargs):
46+
return self.deflections_2d_via_mge_from(grid=grid, xp=xp, **kwargs)
47+
48+
def deflections_2d_via_mge_from(self, grid: aa.type.Grid2DLike, xp=np, **kwargs):
49+
radii_min = self.scale_radius / 1000.0
50+
radii_max = self.scale_radius * 200.0
51+
log_sigmas = xp.linspace(xp.log(radii_min), xp.log(radii_max), 20)
52+
sigmas = xp.exp(log_sigmas)
53+
54+
mge_decomp = MGEDecomposer(mass_profile=self)
55+
56+
deflections_via_mge = mge_decomp.deflections_2d_via_mge_from(
57+
grid=grid,
58+
xp=xp,
59+
sigma_log_list=sigmas,
60+
ellipticity_convention='major',
61+
three_D=True
62+
)
63+
return deflections_via_mge
64+
65+
def density_3d_func(self, r, xp=np):
66+
67+
rho_at_scale_radius = (
68+
self.kappa_s / self.scale_radius
69+
) # density parameter of 3D gNFW
70+
71+
return (
72+
rho_at_scale_radius
73+
* self.scale_radius**3.0
74+
* (r.array + self.core_radius) ** (-1.0)
75+
* (r.array + self.scale_radius) ** (-2.0)
76+
)
77+
78+
79+
class cNFWSph(cNFW):
1180
def __init__(
1281
self,
1382
centre: Tuple[float, float] = (0.0, 0.0),
@@ -23,7 +92,7 @@ def __init__(
2392
centre
2493
The (y,x) arc-second coordinates of the profile centre.
2594
kappa_s
26-
The overall normalization of the dark matter halo \|
95+
The overall normalization of the dark matter halo
2796
(kappa_s = (rho_0 * D_d * scale_radius)/lensing_critical_density)
2897
scale_radius
2998
The cored NFW scale radius `theta_s`, as an angle on the sky in arcseconds.
@@ -165,16 +234,3 @@ def potential_2d_from(self, grid: aa.type.Grid2DLike, xp=np, **kwargs):
165234
This is not yet implemented for `cNFWSph`.
166235
"""
167236
return xp.zeros(shape=grid.shape[0])
168-
169-
def density_3d_func(self, theta, xp=np):
170-
171-
rho_at_scale_radius = (
172-
self.kappa_s / self.scale_radius
173-
) # density parameter of 3D gNFW
174-
175-
return (
176-
rho_at_scale_radius
177-
* self.scale_radius**3.0
178-
* (theta.array + self.core_radius) ** (-1.0)
179-
* (theta.array + self.scale_radius) ** (-2.0)
180-
)

0 commit comments

Comments
 (0)