Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sigma(R,z) and sigma_cb(R,z) allow R in h units (defaults unchanged) #452

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions python/classy.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1062,10 +1062,10 @@ cdef class Class:
return pk_at_k_z, k, z

# Gives sigma(R,z) for a given (R,z)
def sigma(self,double R,double z):
def sigma(self, double R, double z, h_units=False):
"""
Gives sigma (total matter) for a given R and z
(R is the radius in units of Mpc, so if R=8/h this will be the usual sigma8(z)
(R is the radius in units of Mpc, so if R=8/h, or R=8 if ``h_units=True``, this will be the usual sigma8(z)

.. note::

Expand All @@ -1082,16 +1082,20 @@ cdef class Class:
if (self.pt.k_max_for_pk < self.ba.h):
raise CosmoSevereError("In order to get sigma(R,z) you must set 'P_k_max_h/Mpc' to 1 or bigger, in order to have k_max > 1 h/Mpc.")

if fourier_sigmas_at_z(&self.pr,&self.ba,&self.fo,R,z,self.fo.index_pk_m,out_sigma,&sigma)==_FAILURE_:
R_with_units = R
if h_units:
R_with_units = R_with_units / self.ba.h

if fourier_sigmas_at_z(&self.pr,&self.ba,&self.fo,R_with_units,z,self.fo.index_pk_m,out_sigma,&sigma)==_FAILURE_:
raise CosmoSevereError(self.fo.error_message)

return sigma

# Gives sigma_cb(R,z) for a given (R,z)
def sigma_cb(self,double R,double z):
def sigma_cb(self,double R, double z, h_units=False):
"""
Gives sigma (cdm+b) for a given R and z
(R is the radius in units of Mpc, so if R=8/h this will be the usual sigma8(z)
(R is the radius in units of Mpc, so if R=8/h, or R=8 if ``h_units=True``, this will be the usual sigma8(z)

.. note::

Expand All @@ -1111,7 +1115,11 @@ cdef class Class:
if (self.pt.k_max_for_pk < self.ba.h):
raise CosmoSevereError("In order to get sigma(R,z) you must set 'P_k_max_h/Mpc' to 1 or bigger, in order to have k_max > 1 h/Mpc.")

if fourier_sigmas_at_z(&self.pr,&self.ba,&self.fo,R,z,self.fo.index_pk_cb,out_sigma,&sigma_cb)==_FAILURE_:
R_with_units = R
if h_units:
R_with_units = R_with_units / self.ba.h

if fourier_sigmas_at_z(&self.pr,&self.ba,&self.fo,R_with_units,z,self.fo.index_pk_cb,out_sigma,&sigma_cb)==_FAILURE_:
raise CosmoSevereError(self.fo.error_message)

return sigma_cb
Expand Down