Skip to content

Commit 7f8669c

Browse files
committed
minor refactoring, 3d pressure profile test
1 parent ef380ca commit 7f8669c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+23567
-21
lines changed

cluster_toolkit/pressure_profile.py

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
`projected_P_BBPS_real` interpolates over a table of comoving distances to
1717
obtain a more precise answer.
1818
'''
19+
1920
import numpy as np
2021
from scipy.integrate import quad
2122
import scipy.special as spec
@@ -34,14 +35,13 @@ def _rho_crit(z, omega_m):
3435
return 2.77536627e+11 * (omega_m * (1 + z)**3 + omega_lambda)
3536

3637

37-
def P_delta(M, z, omega_b, omega_m, delta=200):
38+
def R_delta(M, z, omega_m, delta=200):
3839
'''
39-
The pressure amplitude of a halo:
40-
41-
:math:`P_{\\Delta} = G * M_{\\Delta} * \\Delta * \\rho_{crit}(z) \
42-
* \\Omega_b / \\Omega_m / (2R_{\\Delta})`
40+
The radius of a sphere of mass M (in Msun), which has a density `delta`
41+
times the critical density of the universe.
4342
44-
See BBPS, section 4.1 for details.
43+
:math:`R_{\\Delta} = \\Big(\\frac{3 M_{\\Delta}} \
44+
{8 \\pi \\Delta \\rho_{crit}}\Big)^{1/3}`
4545
4646
Args:
4747
M (float): Halo mass :math:`M_{\\Delta}`, in units of Msun.
@@ -50,21 +50,20 @@ def P_delta(M, z, omega_b, omega_m, delta=200):
5050
delta (float): The halo overdensity :math:`\\Delta`.
5151
5252
Returns:
53-
float: Pressure amplitude, in units of Msun h^{8/3} s^{-2} Mpc^{-1}.
53+
float: Radius, in :math:`\\text{Mpc} h^\\frac{-2}{3}`.
5454
'''
55-
# G = 4.51710305e-48 Mpc^3 Msun^{-1} s^{-2}
56-
# (source: astropy's constants module and unit conversions)
57-
return 4.51710305e-48 * M * delta * _rho_crit(z, omega_m) * \
58-
omega_b / omega_m / 2 / R_delta(M, omega_m, z, delta)
55+
volume = M / (delta * _rho_crit(z, omega_m))
56+
return (3 * volume / (4 * np.pi))**(1./3)
5957

6058

61-
def R_delta(M, z, omega_m, delta=200):
59+
def P_delta(M, z, omega_b, omega_m, delta=200):
6260
'''
63-
The radius of a sphere of mass M (in Msun), which has a density `delta`
64-
times the critical density of the universe.
61+
The pressure amplitude of a halo:
6562
66-
:math:`R_{\\Delta} = \\Big(\\frac{3 M_{\\Delta}} \
67-
{8 \\pi \\Delta \\rho_{crit}}\Big)^{1/3}`
63+
:math:`P_{\\Delta} = G * M_{\\Delta} * \\Delta * \\rho_{crit}(z) \
64+
* \\Omega_b / \\Omega_m / (2R_{\\Delta})`
65+
66+
See BBPS, section 4.1 for details.
6867
6968
Args:
7069
M (float): Halo mass :math:`M_{\\Delta}`, in units of Msun.
@@ -73,10 +72,12 @@ def R_delta(M, z, omega_m, delta=200):
7372
delta (float): The halo overdensity :math:`\\Delta`.
7473
7574
Returns:
76-
float: Radius, in :math:`\\text{Mpc} h^\\frac{-2}{3}`.
75+
float: Pressure amplitude, in units of Msun h^{8/3} s^{-2} Mpc^{-1}.
7776
'''
78-
volume = M / (delta * _rho_crit(z, omega_m))
79-
return (3 * volume / (4 * np.pi))**(1./3)
77+
# G = 4.51710305e-48 Mpc^3 Msun^{-1} s^{-2}
78+
# (source: astropy's constants module and unit conversions)
79+
return 4.51710305e-48 * M * delta * _rho_crit(z, omega_m) * \
80+
(omega_b / omega_m) / (2 * R_delta(M, z, omega_m, delta))
8081

8182

8283
def P_simple_BBPS_generalized(x, M, z, P_0, x_c, beta,
@@ -114,8 +115,7 @@ def P_BBPS(r, M, z, omega_b, omega_m,
114115
params_P_0=(18.1, 0.154, -0.758),
115116
params_x_c=(0.497, -0.00865, 0.731),
116117
params_beta=(4.35, 0.0393, 0.415),
117-
alpha=1,
118-
gamma=-0.3,
118+
alpha=1, gamma=-0.3,
119119
delta=200):
120120
'''
121121
The best-fit pressure profile presented in BBPS2.

docs/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
api/

0 commit comments

Comments
 (0)