Skip to content

Commit

Permalink
Add miscentering as option of existing user functions
Browse files Browse the repository at this point in the history
  • Loading branch information
combet committed Jul 16, 2024
1 parent 9613974 commit a5c65c3
Showing 1 changed file with 29 additions and 90 deletions.
119 changes: 29 additions & 90 deletions clmm/theory/parent_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -538,31 +538,38 @@ def inv_sigmac(redshift):

return 1.0 / _integ_pzfuncs(pzpdf, pzbins, kernel=inv_sigmac)

def eval_surface_density(self, r_proj, z_cl, verbose=False):
def eval_surface_density(self, r_proj, z_cl, r_mis=None, verbose=False):
r"""Computes the surface mass density
Parameters
----------
r_proj : array_like
Projected radial position from the cluster center in :math:`M\!pc`.
Projected radial position from the cluster center in :math:`M\!pc`
z_cl: float
Redshift of the cluster
r_mis : float, optional
Projected miscenter distance in :math:`M\!pc`
Returns
-------
numpy.ndarray, float
2D projected surface density in units of :math:`M_\odot\ Mpc^{-2}`
"""
if self.validate_input:
validate_argument(locals(), "r_proj", "float_array", argmin=0)
validate_argument(locals(), "z_cl", float, argmin=0)

if r_mis is not None: validate_argument(locals(), "r_mis", float, argmin=0)

if self.halo_profile_model == "einasto" and verbose:
print(f"Einasto alpha = {self._get_einasto_alpha(z_cl=z_cl)}")

return self._eval_surface_density(r_proj=r_proj, z_cl=z_cl)
if r_mis is None:
return self._eval_surface_density(r_proj=r_proj, z_cl=z_cl)
else:
return self._eval_miscentered_surface_density(r_proj=r_proj, z_cl=z_cl, r_mis=r_mis)

def eval_mean_surface_density(self, r_proj, z_cl, verbose=False):
def eval_mean_surface_density(self, r_proj, z_cl, r_mis=None, verbose=False):
r"""Computes the mean value of surface density inside radius `r_proj`
Parameters
Expand All @@ -571,101 +578,29 @@ def eval_mean_surface_density(self, r_proj, z_cl, verbose=False):
Projected radial position from the cluster center in :math:`M\!pc`.
z_cl: float
Redshift of the cluster
Returns
-------
numpy.ndarray, float
Mean surface density in units of :math:`M_\odot\ Mpc^{-2}`.
"""
if self.validate_input:
validate_argument(locals(), "r_proj", "float_array", argmin=0)
validate_argument(locals(), "z_cl", float, argmin=0)

if self.halo_profile_model == "einasto" and verbose:
print(f"Einasto alpha = {self._get_einasto_alpha(z_cl=z_cl)}")

return self._eval_mean_surface_density(r_proj=r_proj, z_cl=z_cl)

def eval_excess_surface_density(self, r_proj, z_cl, verbose=False):
r"""Computes the excess surface density
Parameters
----------
r_proj : array_like
Projected radial position from the cluster center in :math:`M\!pc`.
z_cl: float
Redshift of the cluster
Returns
-------
numpy.ndarray, float
Excess surface density in units of :math:`M_\odot\ Mpc^{-2}`.
"""
if self.validate_input:
validate_argument(locals(), "r_proj", "float_array", argmin=0)
validate_argument(locals(), "z_cl", float, argmin=0)

if self.halo_profile_model == "einasto" and verbose:
print(f"Einasto alpha = {self._get_einasto_alpha(z_cl=z_cl)}")

return self._eval_excess_surface_density(r_proj=r_proj, z_cl=z_cl)


def eval_miscentered_surface_density(self, r_proj, z_cl, r_mis, verbose=False):
r"""Computes the surface mass density
Parameters
----------
r_proj : array_like
Projected radial position from the cluster center in :math:`M\!pc`.
z_cl: float
Redshift of the cluster
r_mis : float
r_mis : float, optional
Projected miscenter distance in :math:`M\!pc`.
Returns
-------
numpy.ndarray, float
2D projected surface density in units of :math:`M_\odot\ Mpc^{-2}`
Mean surface density in units of :math:`M_\odot\ Mpc^{-2}`.
"""
if self.validate_input:
validate_argument(locals(), "r_proj", "float_array", argmin=0)
validate_argument(locals(), "r_mis", float, argmin=0)
validate_argument(locals(), "z_cl", float, argmin=0)
if r_mis is not None: validate_argument(locals(), "r_mis", float, argmin=0)

if self.halo_profile_model == "einasto" and verbose:
print(f"Einasto alpha = {self._get_einasto_alpha(z_cl=z_cl)}")

return self._eval_miscentered_surface_density(r_proj=r_proj, z_cl=z_cl, r_mis=r_mis)

def eval_miscentered_mean_surface_density(self, r_proj, z_cl, r_mis, verbose=False):
r"""Computes the mean value of surface density inside radius `r_proj`
Parameters
----------
r_proj : array_like
Projected radial position from the cluster center in :math:`M\!pc`.
z_cl: float
Redshift of the cluster
r_mis : float
Projected miscenter distance in :math:`M\!pc`.
Returns
-------
numpy.ndarray, float
Miscentered mean surface density in units of :math:`M_\odot\ Mpc^{-2}`.
"""
if self.validate_input:
validate_argument(locals(), "r_proj", "float_array", argmin=0)
validate_argument(locals(), "z_cl", float, argmin=0)
validate_argument(locals(), "r_mis", float, argmin=0)

if self.halo_profile_model == "einasto" and verbose:
print(f"Einasto alpha = {self._get_einasto_alpha(z_cl=z_cl)}")
if r_mis is None:
return self._eval_mean_surface_density(r_proj=r_proj, z_cl=z_cl)
else:
return self._eval_miscentered_mean_surface_density(r_proj=r_proj, z_cl=z_cl, r_mis=r_mis)

return self._eval_miscentered_mean_surface_density(r_proj=r_proj, z_cl=z_cl, r_mis = r_mis)

def eval_miscentered_excess_surface_density(self, r_proj, z_cl, r_mis, verbose=False):
def eval_excess_surface_density(self, r_proj, z_cl, r_mis=None, verbose=False):
r"""Computes the excess surface density
Parameters
Expand All @@ -674,23 +609,27 @@ def eval_miscentered_excess_surface_density(self, r_proj, z_cl, r_mis, verbose=F
Projected radial position from the cluster center in :math:`M\!pc`.
z_cl: float
Redshift of the cluster
r_mis : float
r_mis : float, optional
Projected miscenter distance in :math:`M\!pc`.
Returns
-------
numpy.ndarray, float
Miscentered excess surface density in units of :math:`M_\odot\ Mpc^{-2}`.
Excess surface density in units of :math:`M_\odot\ Mpc^{-2}`.
"""
if self.validate_input:
validate_argument(locals(), "r_proj", "float_array", argmin=0)
validate_argument(locals(), "z_cl", float, argmin=0)
validate_argument(locals(), "r_mis", float, argmin=0)
if r_mis is not None: validate_argument(locals(), "r_mis", float, argmin=0)

if self.halo_profile_model == "einasto" and verbose:
print(f"Einasto alpha = {self._get_einasto_alpha(z_cl=z_cl)}")

return self._eval_miscentered_excess_surface_density(r_proj=r_proj, z_cl=z_cl, r_mis=r_mis)
if r_mis is None:
return self._eval_excess_surface_density(r_proj=r_proj, z_cl=z_cl)
else:
return self._eval_miscentered_excess_surface_density(r_proj=r_proj, z_cl=z_cl, r_mis=r_mis)


def eval_excess_surface_density_2h(
self,
Expand Down

0 comments on commit a5c65c3

Please sign in to comment.