camb.model

class camb.model.CAMBparams[source]

Object storing the parameters for a CAMB calculation, including cosmological parameters and settings for what to calculate. When a new object is instantiated, default parameters are set automatically.

get_omega_k()[source]

Get curvature parameter Omega_k

Returns:Omega_k
set_accuracy(AccuracyBoost=1.0, lSampleBoost=1.0, lAccuracyBoost=1.0, HighAccuracyDefault=True, DoLateRadTruncation=True)[source]

Set parameters determining calculation accuracy (large values may give big slow down). Note curently these are set globally, not just per parameter set.

Parameters:
  • AccuracyBoost – increase AccuracyBoost to decrease integration step size, increase density of k sampling, etc.
  • lSampleBoost – increase lSampleBoost to increase density of L sampling for CMB
  • lAccuracyBoost – increase lAccuracyBoost to increase the maximum L included in the Boltzmann hierarchies
  • HighAccuracyDefault – True for Planck-level accuracy (False is WMAP)
  • DoLateRadTruncation – If True, use approximation to radiation perturbation evolution at late times
Returns:

self

set_bbn_helium(ombh2, delta_nnu, tau_neutron=880.3)[source]

Set the Helium abundance parameter YHe using BBN consistency (using fitting formula as Planck 2015 papers)

Parameters:
  • ombh2 – physical density of baryons
  • delta_nnu – additional relativistic Delta_Neff = N_eff - 3.046
  • tau_neutron – neutron half life in seconds
Returns:

self

set_cosmology(H0=67, cosmomc_theta=None, ombh2=0.022, omch2=0.12, omk=0.0, neutrino_hierarchy='degenerate', num_massive_neutrinos=1, mnu=0.06, nnu=3.046, YHe=None, meffsterile=0, standard_neutrino_neff=3.046, TCMB=2.7255, tau=None, tau_neutron=880.3)[source]

Sets cosmological parameters in terms of physical densities and parameters used in Planck 2015 analysis. Default settings give a single distinct neutrino mass eigenstate, by default one neutrino with mnu = 0.06eV. Set the neutrino_hierarchy parameter to normal or inverted to use a two-eigenstate model that is a good approximation to the known mass splittings seen in oscillation measurements. If you require more fine-grained control you can set the neutrino parameters directly rather than using this function.

Parameters:
  • H0 – Hubble parameter (in km/s/Mpc)
  • cosmomc_theta – The CosmoMC theta parameter. You must set H0=None to solve for H0 given cosmomc_theta
  • ombh2 – physical density in baryons
  • omch2 – physical density in cold dark matter
  • omk – Omega_K curvature parameter
  • neutrino_hierarchy – ‘degenerate’, ‘normal’, or ‘inverted’ (1 or 2 eigenstate approximation)
  • num_massive_neutrinos – number of massive neutrinos (ignored unless hierarchy == ‘degenerate’)
  • mnu – sum of neutrino masses (in eV)
  • nnu – N_eff, effective relativistic degrees of freedom
  • YHe – Helium mass fraction. If None, set from BBN consistency.
  • meffsterile – effective mass of sterile neutrinos
  • standard_neutrino_neff – default value for N_eff in standard cosmology (non-integer to allow for partial heating of neutrinos at electron-positron annihilation and QED effects)
  • TCMB – CMB temperature (in Kelvin)
  • tau – optical depth; if None, current Reion settings are not changed
  • tau_neutron – neutron lifetime, for setting YHe using BBN consistency
set_dark_energy(w=-1.0, sound_speed=1.0, dark_energy_model='fluid')[source]

Set dark energy parameters. Not that in this version these are not actually stored in the CAMBparams variable but set globally. So be careful!

Parameters:
  • w – p_de/rho_de, assumed constant
  • sound_speed – rest-frame sound speed of dark energy fluid
  • dark_energy_model – model to use, default is ‘fluid’
Returns:

self

set_for_lmax(lmax, max_eta_k=None, lens_potential_accuracy=0, lens_margin=150, k_eta_fac=2.5, lens_k_eta_reference=18000.0)[source]

Set parameters to get CMB power spectra accurate to specific a l_lmax. Note this does not fix the actual output L range, spectra may be calculated above l_max (but may not be accurate there). To fix the l_max for output arrays use the optional input argument to camb.CAMBdata.get_cmb_power_spectra() etc.

Parameters:
  • lmax – l_max you want
  • max_eta_k – maximum value of k*eta_* to use, which indirectly sets k_max. If None, sensible value set automatically.
  • lens_potential_accuracy – Set to 1 or higher if you want to get the lensing potential accurate
  • lens_margin – the delta l_max to use to ensure lensed C_L are correct at l_max
  • k_eta_fac – k_eta_fac default factor for setting max_eta_k = k_eta_fac*lmax if max_eta_k=None
  • lens_k_eta_reference – value of max_eta_k to use when lens_potential_accuracy>0; use k_eta_max = lens_k_eta_reference*lens_potential_accuracy
Returns:

self

set_initial_power(initial_power_params)[source]

Set the InitialPower primordial power spectrum parameters

Parameters:initial_power_paramsinitialpower.InitialPowerParams instance
Returns:self
set_matter_power(redshifts=[0.0], kmax=1.2, k_per_logint=None, silent=False)[source]

Set parameters for calculating matter power spectra and transfer functions.

Parameters:
  • redshifts – array of redshifts to calculate
  • kmax – maximum k to calculate
  • k_per_logint – number of k steps per log k. Set to zero to use default optimized spacing.
  • silent – if True, don’t give warnings about sort order
Returns:

self

validate()[source]

Do some quick tests for sanity

Returns:True if OK
class camb.model.TransferParams[source]

Object storing parameters for the matter power spectrum calculation. PK variables are for setting main outputs. Other entries are used internally, e.g. for sampling to get correct non-linear corrections and lensing.

Variables:
  • high_precision – True for more accuracy
  • kmax – k_max to output
  • k_per_logint – number of points per log k interval. If zero, set an irregular optimized spacing.
  • PK_num_redshifts – number of redshifts to calculate
  • PK_redshifts – redshifts to output for the matter transfer and power