Cosmology¶
- class kszx.Cosmology(params, lmax=None)¶
Thin wrapper around CAMB ‘results’ object, with methods such as H(), Plin(), etc.
Adding a wrapper around CAMB is not really necessary, but I like it for a few reasons:
The Cosmology object is pickleable (unlike the camb ‘results’ object).
I find the syntax a little more intuitive.
It’s a convenient place to add new methods (e.g. frsd(), alpha()).
NOTE: no h-units! All distances are Mpc (not \(h^{-1}\) Mpc), and all wavenumbers are Mpc\(^{-1}\) (not h Mpc\(^{-1}\)). All masses are Msol.
Constructor args:
params (
CosmologicalParamsobject, or string name).- The following string names are supported:
params='planck18+bao': https://arxiv.org/abs/1807.06209 (last column of Table 2)params='hmvec': match defaults in Mat’s hmvec code (https://github.com/simonsobs/hmvec)
lmax (int, optional): if specified, overrides the value of lmax in ‘params’.
Note: methods require caller to specify keywords, e.g. caller must call
Cosmology.Plin(k=xx, z=xx)instead ofPlin(xx,xx). This is intentional, to reduce the chances that I’ll create a bug by swapping arguments or using the wrong time coordinate (e.g. scale factor a instead of redshift z).- H(*, z, check=True)¶
Returns Hubble expansion rate \(H(z)\).
- chi(*, z, check=True)¶
Returns comoving distance \(\chi(z)\).
- z(*, chi, check=True)¶
Returns redshift \(z\) corresponding to specified comoving distance \(\chi\).
- Plin_z0(k, check=True)¶
Returns linear power spectrum \(P(k)\) at \(z=0\).
Calling
Plin_z0()is slightly faster than callingPlin(k,z)with k=0, and in most situations, callingPlin(k,z)is unnecessary, since:\[P_{lin}(k,z) \approx P_{lin}(k,0) \frac{D(z)}{D(0)}\]This approximation slightly breaks down (at the ~0.5% level!) on large scales \(k \lesssim 10^{-3}\) and small scales \(k \gtrsim 0.1\).
- Plin(*, k, z, kzgrid=False, check=True)¶
Returns linear power spectrum \(P(k,z)\).
The
kzgridargument has the following meaning:kzgrid=Falsemeans “broadcast k,z to get a set of points”kzgrid=Truemeans “take the Cartesian product of k,z to get a kzgrid”
(If
kzgrid=True, then the returned array has shape (nk,nz) – note that this convention is transposed relative to CAMB or hmvec.)
- D(*, z, z0norm, check=True)¶
Return the growth function \(D(z)\).
If
z0norm=True, normalize so that \(D(0)=1\).If
z0norm=False, normalize so that \(D(z) \rightarrow 1/(1+z)\) at high z.
- Dfit(*, z, z0norm, check=True)¶
Return the growth function
D(z), computed using a popular fitting function.This is probably not the function you want! You probably want
D(), notDfit().
- frsd(*, z, check=True)¶
Return RSD function \(f(z) = d(\log D)/d(\log a)\). Uses a fitting function for now!
- alpha(*, k, z, kzgrid=False, check=True)¶
Return \(\alpha(k,z)\), defined by \(\delta_m(k,z) = (3/5) \alpha(k,z) \zeta(k)\).
The function \(\alpha(k,z)\) arises in non-Gaussian halo bias as:
\[b(k,z) = b_g + 2 b_{ng} \frac{f_{NL}}{\alpha(k,z)}\]where \(b_{ng} = d(\log n)/d(\log \sigma_8) \approx \delta_c (b_g - 1)\).
Note that for fixed k, \(\alpha(k,z)\) is proportional to \(D(z)\), to an excellent approximation.
The
kzgridargument has the following meaning:kzgrid=Falsemeans “broadcast k,z to get a set of points”kzgrid=Truemeans “take the Cartesian product of k,z to get a kzgrid”
(If
kzgrid=True, then the returned array has shape (nk,nz) – note that this convention is transposed relative to CAMB or hmvec.)
- alpha_z0(k, check=True)¶
Returns \(\alpha(k)\) at \(z=0\), defined by \(\delta_m(k) = (3/5) \alpha(k) \zeta(k)\).
Calling
alpha_z0()is slightly faster than callingalpha(k,z)with k=0, and in most situations, callingalpha(k,z)is unnecessary, since:\[\alpha(k,z) \approx \alpha(k,0) \frac{D(z)}{D(0)}\]The function \(\alpha(k,z)\) arises in non-Gaussian halo bias as:
\[b(k,z) = b_g + 2 b_{ng} \frac{f_{NL}}{\alpha(k,z)}\]where \(b_{ng} = d(\log n)/d(\log \sigma_8) \approx \delta_c (b_g - 1)\).
- K(*, z)¶
Returns the kSZ radial weight K(z) = -T_CMB sigma_T n_{e0} x_e(z) e^{-tau(z)} (1+z)^2 in units (uK/Mpc).
For now, we approximate x_e=1 and tau=0. Then K(z) is just proportional to (1+z)^2. I’ll improve this later! Note that K(z) is negative.
- class kszx.CosmologicalParams(name=None)¶
Simple data class containing cosmological params (ombh2, omch2, etc.)
You probably don’t need to use this class – instead construct a
Cosmologyobject by name.Constructor args:
name (string or None).
- The following names are supported:
params='planck18+bao': https://arxiv.org/abs/1807.06209 (last column of Table 2)params='hmvec': match defaults in Mat’s hmvec code (https://github.com/simonsobs/hmvec)
If no name is specified, then caller must set ombh2, omch2, etc. after calling constructor.