1818'''
1919import numpy as np
2020from scipy .integrate import quad
21+ import scipy .special as spec
2122
2223
2324def _rho_crit (z , omega_m ):
@@ -87,37 +88,6 @@ def P_simple_BBPS_generalized(x, M, z, P_0, x_c, beta,
8788 return P_0 * (x / x_c )** gamma * (1 + (x / x_c )** alpha )** (- beta )
8889
8990
90- def P_BBPS_generalized (r , M , z , omega_b , omega_m ,
91- P_0 , x_c , beta , alpha = 1 , gamma = - 0.3 , delta = 200 ):
92- '''
93- The generalized NFW form of the Battaglia profile, presented in BBPS2
94- equation 10 as:
95-
96- :math:`P = P_{\\ Delta} P_0 (x / x_c)^\\ gamma \
97- [1 + (x / x_c)^\\ alpha]^{-\\ beta}`
98-
99- Where :math:`x = r/R_{\\ Delta}`.
100-
101- Args:
102- r (float): Radius from cluster center, in Mpc.
103- M (float): Halo mass M_{200}, in Msun.
104- z (float): Redshift to cluster.
105- omega_b (float): Baryon fraction.
106- omega_m (float): Matter fraction.
107- P_0 (float): Pressure scale parameter, see BBPS2 Eq. 10.
108- x_c (float): Core scale parameter, see BBPS2 Eq. 10.
109- beta (float): Asymptotic dropoff parameter, see BBPS2 Eq. 10.
110-
111- Returns:
112- float: Pressure at a distance `r` from a cluster center, in units of \
113- Msun s^{-2} Mpc^{-1}.
114- '''
115- x = r / R_delta (M , z , omega_m , delta = delta )
116- Pd = P_delta (M , z , omega_b , omega_m , delta = delta )
117- return Pd * P_simple_BBPS_generalized (x , M , z , P_0 , x_c , beta ,
118- alpha = alpha , gamma = gamma , delta = delta )
119-
120-
12191def _A_BBPS (M , z , A_0 , alpha_m , alpha_z ):
12292 '''
12393 Mass-Redshift dependency model for the generalized BBPS profile parameters,
@@ -140,32 +110,42 @@ def P_simple_BBPS(x, M, z):
140110 return P_simple_BBPS_generalized (x , M , z , P_0 , x_c , beta )
141111
142112
143- def P_BBPS (r , M , z , omega_b , omega_m ):
113+ def P_BBPS (r , M , z , omega_b , omega_m ,
114+ params_P_0 = (18.1 , 0.154 , - 0.758 ),
115+ params_x_c = (0.497 , - 0.00865 , 0.731 ),
116+ params_beta = (4.35 , 0.0393 , 0.415 ),
117+ alpha = 1 ,
118+ gamma = - 0.3 ,
119+ delta = 200 ):
144120 '''
145121 The best-fit pressure profile presented in BBPS2.
146122
147123 Args:
148- r (float): Radius from the cluster center, in Mpc.
124+ r (float): Radius from the cluster center, in Mpc :math:`h^{-2/3}` .
149125 M (float): Cluster :math:`M_{\\ Delta}`, in Msun.
150126 z (float): Cluster redshift.
151127 omega_b (float): Baryon fraction.
152128 omega_m (float): Matter fraction.
129+ params_P_0 (tuple): 3-tuple of :math:`P_0` mass, redshift dependence \
130+ parameters A, :math:`\\ alpha_m`, :math:`\\ alpha_z`, \
131+ respectively. See BBPS2 Equation 11.
132+ params_x_c (tuple): 3-tuple of :math:`x_c` mass, redshift dependence, \
133+ same as `params_P_0`.
134+ params_beta (tuple): 3-tuple of :math:`\\ beta` mass, redshift \
135+ dependence, same as `params_P_0`.
153136
154137 Returns:
155138 float: Pressure at distance `r` from the cluster, in units of \
156- Msun s^{-2} Mpc^{-1}.
139+ :math:`h^{8/3} Msun s^{-2} Mpc^{-1}` .
157140 '''
158- # These are the best-fit parameters from BBPS2 Table 1, under AGN Feedback
159- # \Delta = 200
160- params_P = (18.1 , 0.154 , - 0.758 )
161- params_x_c = (0.497 , - 0.00865 , 0.731 )
162- params_beta = (4.35 , 0.0393 , 0.415 )
163-
164- P_0 = _A_BBPS (M , z , * params_P )
141+ P_0 = _A_BBPS (M , z , * params_P_0 )
165142 x_c = _A_BBPS (M , z , * params_x_c )
166143 beta = _A_BBPS (M , z , * params_beta )
167- return P_BBPS_generalized (r , M , z , omega_b , omega_m ,
168- P_0 , x_c , beta )
144+
145+ x = r / R_delta (M , z , omega_m , delta = delta )
146+ Pd = P_delta (M , z , omega_b , omega_m , delta = delta )
147+ return Pd * P_simple_BBPS_generalized (x , M , z , P_0 , x_c , beta ,
148+ alpha = alpha , gamma = gamma , delta = delta )
169149
170150
171151def projected_P_BBPS (r , M , z , omega_b , omega_m ,
@@ -193,7 +173,7 @@ def projected_P_BBPS(r, M, z, omega_b, omega_m,
193173
194174
195175def projected_y_BBPS (r , M , z , omega_b , omega_m ,
196- dist = 8 , epsrel = 1e-3 ):
176+ Xh = 0.76 , dist = 8 , epsrel = 1e-3 ):
197177 '''
198178 Projected Compton-y parameter along the line of sight, at a perpendicular
199179 distance `r` from a cluster of mass `M` at redshift `z`. All arguments have
@@ -205,6 +185,7 @@ def projected_y_BBPS(r, M, z, omega_b, omega_m,
205185 z (float): Cluster redshift.
206186 omega_b (float): Baryon fraction.
207187 omega_m (float): Matter fraction.
188+ Xh (float): Primordial hydrogen mass fraction.
208189
209190 Returns:
210191 float: Compton y parameter. Unitless.
@@ -213,8 +194,47 @@ def projected_y_BBPS(r, M, z, omega_b, omega_m,
213194 # divided by the mass-energy of the electron, in units of s^2 Msun^{-1}.
214195 # Source: Astropy constants and unit conversions.
215196 cy = 1.61574202e+15
216- return cy * projected_P_BBPS (r , M , z , omega_b , omega_m ,
217- dist = dist , epsrel = epsrel )
197+ # We need to convert from GAS pressure to ELECTRON pressure. This is the
198+ # equation to do so, see BBPS2 p. 3.
199+ ch = (2 * Xh + 2 ) / (5 * Xh + 3 )
200+ return ch * cy * projected_P_BBPS (r , M , z , omega_b , omega_m ,
201+ dist = dist , epsrel = epsrel )
202+
203+
204+ def Cxl (M , z , omega_b , omega_m , da , ell ,
205+ dist = 8 , epsrel = 1e-3 ):
206+ '''
207+ The Fourier-transform of a cluster's Compton y parameter on the sky. Assumes
208+ the flat-sky approximation.
209+
210+ Args:
211+ M (float): Cluster :math:`M_{\\ Delta}`, in Msun.
212+ z (float): Cluster redshift.
213+ omega_b (float): Baryon fraction.
214+ omega_m (float): Matter fraction.
215+ d_a (float): Angular diameter distance at redshift `z`. Should be \
216+ in Mpc.
217+ ell (float): The Fourier-transform wavenumber.
218+
219+ Returns:
220+ float: :math:`C_{x, l}`. Unitless.
221+ '''
222+ return quad (lambda theta : 2 * np .pi * theta * spec .j0 (ell * theta )
223+ * projected_y_BBPS (theta * da , M , z , omega_b , omega_m ,
224+ dist = dist , epsrel = epsrel ),
225+ 0 , 2 * np .pi ,
226+ epsrel = epsrel )[0 ]
227+
228+
229+ def smoothed_xi (theta , M , z , omega_b , omega_m , da ,
230+ dist = 8 , epsrel = 1e-3 , maxl = 10000 ):
231+ # Convert from arcmin to radians
232+ theta = theta * 60 * np .pi / 180
233+ return quad (lambda ell : 1 / (2 * np .pi ) * ell * spec .j0 (ell * theta )
234+ * Cxl (M , z , omega_b , omega_m , da , ell ,
235+ dist = dist , epsrel = epsrel ),
236+ 0 , maxl ,
237+ epsrel = epsrel )[0 ]
218238
219239
220240def projected_P_BBPS_real (r , M , z , omega_b , omega_m , chis , zs ,
@@ -240,7 +260,8 @@ def projected_P_BBPS_real(r, M, z, omega_b, omega_m, chis, zs,
240260 chi_cluster = np .interp (z , zs , chis )
241261 return quad (lambda x : P_BBPS (np .sqrt ((x - chi_cluster )** 2 + r * r ),
242262 M , z ,
243- omega_b , omega_m ) / (1 + np .interp (x , chis , zs )),
263+ omega_b , omega_m )
264+ / (1 + np .interp (x , chis , zs )),
244265 chi_cluster - dist * R_del ,
245266 chi_cluster + dist * R_del ,
246267 epsrel = epsrel )[0 ]
0 commit comments