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.

Returns:Effective number of degrees of freedom in relativistic species at early times.
Make independent copy.
return:copy of self
get_DH(ombh2=None, delta_neff=None)[source]

Get deuterium ration D/H by intepolation using the bbn.BBNPredictor instance passed to model.CAMBparams.set_cosmology() (or the default one, if Y_He has not been set).


BBN helium nucleon fraction D/H

get_Y_p(ombh2=None, delta_neff=None)[source]

Get BBN helium nucleon fraction (NOT the same as the mass fraction Y_He) by intepolation using the bbn.BBNPredictor instance passed to model.CAMBparams.set_cosmology() (or the default one, if Y_He has not been set).


Y_p helium nucleon fraction predicted by BBN.


Get curvature parameter 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.

  • 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


set_cosmology(H0=67.0, 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.0, standard_neutrino_neff=3.046, TCMB=2.7255, tau=None, deltazrei=None, bbn_predictor=None, theta_H0_range=[10, 100])[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.

  • 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
  • deltazrei – redshift width of reionization; if None, uses default
  • bbn_predictorbbn.BBNPredictor instance used to get YHe from BBN consistency if YHe is None
  • theta_H0_range – if cosmomc_theta is specified, the min, max interval of H0 values to map to; outside this range it will raise an exception.
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!

  • 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’


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.

  • 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



Set the InitialPower primordial power spectrum parameters

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

Set parameters for calculating matter power spectra and transfer functions.

  • 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.
  • nonlinear – if None, uses existing setting, otherwise boolean for whether to use non-linear matter power.
  • accurate_massive_neutrino_transfers – if you want the massive neutrino transfers accurately
  • silent – if True, don’t give warnings about sort order



Settings for whether or not to use non-linear corrections for the CMB lensing potential. Note that set_for_lmax also sets lensing to be non-linear if lens_potential_accuracy>0

Parameters:nonlinear – true to use non-linear corrections

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.

  • 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