# Module perturbation

source code

Perturbation theory and the power spectrum routines.

This module relies largely on power.c from Eisenstein & Hu (1999 ApJ 511 5)

http://background.uchicago.edu/~whu/transfer/transferpage.html

See notes in cosmolopy.EH.

Functions

 transfer_function_EH(k, **cosmology) The transfer function as a function of wavenumber k. source code

 fgrowth(z, omega_M_0, unnormed=False) Cosmological perturbation growth factor, normalized to 1 at z = 0. source code

 w_tophat(k, r) The k-space Fourier transform of a spherical tophat. source code

 w_gauss(k, r) The k-space Fourier transform of an isotropic three-dimensional gaussian source code

 sigma_j(r, j, z, **cosmology) Sigma statistic of order j for gaussian field of variancea r at redshift z. source code

 sigma_r(r, z, **cosmology) RMS mass fluctuations of a sphere of radius r at redshift z. source code

 norm_power(**cosmology) Normalize the power spectrum to the specified sigma_8. source code

 power_spectrum(k, z, **cosmology) The matter power spectrum P(k,z). source code

 volume_radius_dmdr(mass, **cosmology) The volume, radius, and dm/dr for a sphere of the given mass. source code

 mass_to_radius(mass, **cosmology) The radius in Mpc of a sphere of the given mass. source code

 radius_to_mass(r, **cosmology) The mass of a sphere of radius r in Mpc. source code

 virial_temp(mass, z, mu=None, **cosmology) The Virial temperature for a halo of a given mass. source code

 virial_mass(temp, z, mu=None, **cosmology) The mass of a halo of the given Virial temperature. source code

 virial_temp_HB(mass, z) Virial temperature from halo mass according to Haiman & Bryan (2006ApJ...650....7). source code

 virial_mass_HB(temp, z) Halo mass from Virial temperature according to Haiman & Bryan (2006ApJ...650....7). source code

 sig_del(temp_min, z, mass=None, passed_min_mass=False, **cosmology) Convenience function to calculate collapse fraction inputs. source code

 collapse_fraction(sigma_min, delta_crit, sigma_mass=0, delta=0) Fraction of mass contained in collapsed objects. source code
 Variables havepower = True powererror = None havetffit = True tffiterror = None __package__ = 'cosmolopy'
 Function Details

### transfer_function_EH(k, **cosmology)

source code

The transfer function as a function of wavenumber k.

# Parameters

cosmology : dict
Specify the cosmological parameters with the keys 'omega_M_0', 'omega_b_0', 'omega_n_0', 'N_nu', 'omega_lambda_0', 'h' and 'baryonic_effects'.
k : array
Wavenumber in Mpc^-1.

# Returns

If baryonic_effects is true, returns a tuple of arrays matching the shape of k:

(the transfer function for CDM + Baryons with baryonic effects,
the transfer function for CDM + Baryons without baryonic effects)

Otherwise, returns a tuple of arrays matching the shape of k:

(the transfer function for CDM + Baryons, the transfer function for CDM + Baryons + Neutrinos).

# Notes

Uses transfer function code power.c from Eisenstein & Hu (1999 ApJ 511 5). For baryonic effects, uses tf_fit.c from Eisenstein & Hu (1997 ApJ 496 605).

http://background.uchicago.edu/~whu/transfer/transferpage.html

### fgrowth(z, omega_M_0, unnormed=False)

source code

Cosmological perturbation growth factor, normalized to 1 at z = 0.

Approximate forumla from Carol, Press, & Turner (1992, ARA&A, 30, 499), "good to a few percent in regions of plausible Omega_M, Omega_Lambda".

This is proportional to D_1(z) from Eisenstein & Hu (1999 ApJ 511 5) equation 10, but the normalization is different: fgrowth = 1 at z = 0 and D_1(z) = \frac{1+z_\mathrm{eq}}{1+z} as z goes to infinity.

To get D_1 one would just use

D_1(z) = (1+z_\mathrm{eq}) \mathtt{fgrowth}(z,\Omega_{M0}, 1)


(see EHequation 1 for z_eq).

\mathtt{fgrowth} = \frac{D_1(z)}{D_1(0)}


Setting unnormed to true turns off normalization.

Note: assumes Omega_lambda_0 = 1 - Omega_M_0!

### w_tophat(k, r)

source code

The k-space Fourier transform of a spherical tophat.

# Parameters

k: array
wavenumber
r: array
radius of the 3-D spherical tophat

Note: k and r need to be in the same units.

# Returns

\tilde{w}: array
the value of the transformed function at wavenumber k.

### w_gauss(k, r)

source code

The k-space Fourier transform of an isotropic three-dimensional gaussian

# Parameters

k: array
wavenumber
r: array
width of the 3-D gaussian

Note: k and r need to be in the same units.

# Returns

\tilde{w}: array
the value of the transformed function at wavenumber k.

### sigma_j(r, j, z, **cosmology)

source code

Sigma statistic of order j for gaussian field of variancea r at redshift z.

Returns sigma and the error on sigma.

# Parameters

r : array
radius of sphere in Mpc
j : array
order of the sigma statistic (0, 1, 2, 3, ...)
z : array
redshift

# Returns

sigma:
j-th order variance of the field smoothed by gaussian with with r
error:
An estimate of the numerical error on the calculated value of sigma.

# Notes

:: Eq. (152) of Matsubara (2003)

sigma_j(R,z) = sqrt{int_0^infty frac{k^2}{2 pi^2}~P(k, z)~k^{2j} tilde{w}_k^2(k, R)~dk} = sigma_j(R,0) left(frac{D_1(z)}{D_1(0)}right)

### sigma_r(r, z, **cosmology)

source code

RMS mass fluctuations of a sphere of radius r at redshift z.

Returns sigma and the error on sigma.

# Parameters

r : array
radius of sphere in Mpc
z : array
redshift

# Returns

sigma:
RMS mass fluctuations of a sphere of radius r at redshift z.
error:
An estimate of the numerical error on the calculated value of sigma.

# Notes

\sigma(R,z) = \sqrt{\int_0^\infty \frac{k^2}{2 \pi^2}~P(k, z)~
\tilde{w}_k^2(k, R)~dk} = \sigma(R,0) \left(\frac{D_1(z)}{D_1(0)}\right)


### norm_power(**cosmology)

source code

Normalize the power spectrum to the specified sigma_8.

Returns the factor deltaSqr.

### power_spectrum(k, z, **cosmology)

source code

The matter power spectrum P(k,z).

Uses equation 25 of Eisenstein & Hu (1999 ApJ 511 5).

# Parameters

k should be in Mpc^-1

# Cosmological Parameters

Uses 'n', and either 'sigma_8' or 'deltaSqr', as well as, for transfer_function_EH, 'omega_M_0', 'omega_b_0', 'omega_n_0', 'N_nu', 'omega_lambda_0', and 'h'.

# Notes

P(k,z) = \delta^2 \frac{2 \pi^2}{k^3} \left(\frac{c k}{h
H_{100}}\right)^{3+n} \left(T(k,z) \frac{D_1(z)}{D_1(0)}\right)^2


Using the non-dependence of the transfer function on redshift, we can rewrite this as

P(k,z) = P(k,0) \left( \frac{D_1(z)}{D_1(0)} \right)^2


which is used by sigma_r to the z-dependence out of the integral.

source code

The volume, radius, and dm/dr for a sphere of the given mass.

Uses the mean density of the universe.

# Parameters

mass: array
mass of the sphere in Solar Masses, M_sun.

# Returns

volume in Mpc^3 radius in Mpc dmdr in Msun / Mpc

source code

The radius in Mpc of a sphere of the given mass.

mass in Msun

# Notes

This is a convenience function that calls volume_radius_dmdr and returns only the radius.

source code

The mass of a sphere of radius r in Mpc.

Uses the mean density of the universe.

### virial_temp(mass, z, mu=None, **cosmology)

source code

The Virial temperature for a halo of a given mass.

Calculates the Virial temperature in Kelvin for a halo of a given mass using equation 26 of Barkana & Loeb.

The transition from neutral to ionized is assumed to occur at temp = 1e4K. At temp >= 10^4 k, the mean partical mass drops from 1.22 to 0.59 to very roughly account for collisional ionization.

# Parameters

mass: array
Mass in Solar Mass units.
z: array
Redshift.
mu: array, optional
Mean mass per particle.

### virial_mass(temp, z, mu=None, **cosmology)

source code

The mass of a halo of the given Virial temperature.

Uses equation 26 of Barkana & Loeb (2001PhR...349..125B), solved for T_vir as a function of mass.

# Parameters

temp: array
Virial temperature of the halo in Kelvin.
z: array
Redshift.

# Returns

mass: array
The mass of such a halo in Solar Masses.

# Notes

At temp >= 10^4 k, the mean partical mass drops from 1.22 to 0.59 to very roughly account for collisional ionization.

# Examples

>>> cosmo = {'omega_M_0' : 0.27,
...          'omega_lambda_0' : 1-0.27,
...          'omega_b_0' : 0.045,
...          'omega_n_0' : 0.0,
...          'N_nu' : 0,
...          'h' : 0.72,
...          'n' : 1.0,
...          'sigma_8' : 0.9
...          }
>>> mass = virial_mass(1e4, 6.0, **cosmo)
>>> temp = virial_temp(mass, 6.0, **cosmo)
>>> print "Mass = %.3g M_sun" % mass
Mass = 1.68e+08 M_sun
>>> print round(temp, 4)
10000.0

### virial_temp_HB(mass, z)

source code

Virial temperature from halo mass according to Haiman & Bryan (2006ApJ...650....7).

z is the redshift.

Units are Msun and kelvin.

### virial_mass_HB(temp, z)

source code

Halo mass from Virial temperature according to Haiman & Bryan (2006ApJ...650....7).

z is the redshift.

Units are Msun and kelvin.

### sig_del(temp_min, z, mass=None, passed_min_mass=False, **cosmology)

source code

Convenience function to calculate collapse fraction inputs.

# Parameters

temp_min:
Minimum Virial temperature for a halo to be counted. Or minimum mass, if passed_min_mass is True.
z:
Redshift.
mass: optional
The mass of the region under consideration. Defaults to considering the entire universe.
passed_min_mass: boolean
Indicates that the first argument is actually the minimum mass, not the minimum Virial temperature.

### collapse_fraction(sigma_min, delta_crit, sigma_mass=0, delta=0)

source code

Fraction of mass contained in collapsed objects.

Use sig_del to conveniently obtain sigma_min and delta_crit. See Examples velow.

# Parameters

sigma_min:
The standard deviatiation of density fluctuations on the scale corresponding to the minimum mass for a halo to be counted.
delta_crit:
The critical (over)density of collapse.
sigma_mass:
The standard deviation of density fluctuations on the scale corresponding to the mass of the region under consideration. Use zero to consider the entire universe.
delta:
The overdensity of the region under consideration. Zero corresponds to the mean density of the universe.

# Notes

The fraction of the mass in a region of mass m that has already collapsed into halos above mass m_min is:

f_\mathrm{col} = \mathrm{erfc} \left[ \frac{\delta_c - \delta(m)}
{ \sqrt {2 [\sigma^2(m_\mathrm{min}) - \sigma^2(m)]}} \right]


The answer isn't real if sigma_mass > sigma_min.

Note that there is a slight inconsistency in the mass used to calculate sigma in the above formula, since the region deviates from the average density.

# Examples

>>> import numpy
>>> import perturbation as cp
>>> cosmo = {'omega_M_0' : 0.27,
...          'omega_lambda_0' : 1-0.27,
...          'omega_b_0' : 0.045,
...          'omega_n_0' : 0.0,
...          'N_nu' : 0,
...          'h' : 0.72,
...          'n' : 1.0,
...          'sigma_8' : 0.9,
...          'baryonic_effects' : False
...          }
>>> fc = cp.collapse_fraction(*cp.sig_del(1e4, 0, **cosmo))
>>> print round(fc, 4)
0.7328
>>> fc = cp.collapse_fraction(*cp.sig_del(1e2, 0, **cosmo))
>>> print round(fc, 4)
0.8571

 Generated by Epydoc 3.0.1 on Tue Mar 27 20:49:14 2012 http://epydoc.sourceforge.net