Added more documentation

This commit is contained in:
Guilhem Lavaux 2014-12-23 16:43:03 +01:00
parent 7a27dae025
commit 85c1317939
2 changed files with 50 additions and 2 deletions

View File

@ -41,3 +41,13 @@ Timing
.. autofunction:: time_block
.. autofunction:: timeit
.. autofunction:: timeit_quiet
Cosmology
^^^^^^^^^
Power spectrum
--------------
.. autoclass:: CosmologyPower
:members:

View File

@ -49,11 +49,21 @@ cdef extern from "cosmopower.hpp" namespace "CosmoTool":
double power(double)
cdef class CosmologyPower:
"""CosmologyPower(**cosmo)
CosmologyPower manages and compute power spectra computation according to different
approximation given in the litterature.
Keyword arguments:
omega_B_0 (float): relative baryon density
omega_M_0 (float): relative matter density
h (float): Hubble constant relative to 100 km/s/Mpc
ns (float): power law of the large scale inflation spectrum
"""
cdef CosmoPower power
def __init__(self,**cosmo):
self.power = CosmoPower()
self.power.OMEGA_B = cosmo['omega_B_0']
self.power.OMEGA_C = cosmo['omega_M_0']-cosmo['omega_B_0']
@ -66,11 +76,26 @@ cdef class CosmologyPower:
self.power.updateCosmology()
def normalize(self,s8):
"""normalize(self, sigma8)
Compute the normalization of the power spectrum using sigma8.
Arguments:
sigma8 (float): standard deviation of density field smoothed at 8 Mpc/h
"""
self.power.SIGMA8 = s8
self.power.normalize()
def setFunction(self,funcname):
"""setFunction(self, funcname)
Choose an approximation to use for the computation of the power spectrum
Arguments:
funcname (str): the name of the approximation. It can be either
EFSTATHIOU, HU_WIGGLES, HU_BARYON, BARDEEN or SUGIYAMA.
"""
cdef CosmoFunction f
f = POWER_EFSTATHIOU
@ -93,6 +118,19 @@ cdef class CosmologyPower:
return self.power.power(k)
def compute(self, k):
"""compute(self, k)
Compute the power spectrum for mode which length k.
Arguments:
k (float): Mode for which to evaluate the power spectrum.
It can be a scalar or a numpy array.
The units must be in 'h Mpc^{-1}'.
Returns:
a scalar or a numpy array depending on the type of the k argument
"""
cdef np.ndarray out
cdef double kval
cdef tuple i