Basic functions now allowing MG parameters¶
Python CAMB interface (https://github.com/mishakb/ISiTGR)
-
isitgr.
get_results
(params)[source]¶ Calculate results for specified parameters and return
CAMBdata
instance for getting results.Parameters: params – model.CAMBparams
instanceReturns: CAMBdata
instance
-
isitgr.
get_background
(params, no_thermo=False)[source]¶ Calculate background cosmology for specified parameters and return
CAMBdata
, ready to get derived parameters and use background functions likeangular_diameter_distance()
.Parameters: - params –
model.CAMBparams
instance - no_thermo – set True if thermal and ionization history not required.
Returns: CAMBdata
instance- params –
-
isitgr.
get_transfer_functions
(params, only_time_sources=False)[source]¶ Calculate transfer functions for specified parameters and return
CAMBdata
instance for getting results and subsequently calculating power spectra.Parameters: - params –
model.CAMBparams
instance - only_time_sources – does not calculate the CMB l,k transfer functions and does not apply any non-linear correction scaling. Results with only_time_sources=True can therefore be used with different initial power spectra to get consistent non-linear lensed spectra.
Returns: CAMBdata
instance- params –
-
isitgr.
set_params
(cp=None, verbose=False, **params)[source]¶ Set all CAMB parameters at once, including parameters which are part of the CAMBparams structure, as well as global parameters.
E.g.:
cp = isitgr.set_params(ns=1, H0=67, ombh2=0.022, omch2=0.1, w=-0.95, Alens=1.2, lmax=2000, WantTransfer=True, dark_energy_model='DarkEnergyPPF')
This is equivalent to:
cp = model.CAMBparams() cp.DarkEnergy = DarkEnergyPPF() cp.DarkEnergy.set_params(w=-0.95) cp.set_cosmology(H0=67, omch2=0.1, ombh2=0.022, Alens=1.2) cp.set_for_lmax(lmax=2000) cp.InitPower.set_params(ns=1) cp.WantTransfer = True
The wrapped functions are (in this order):
model.CAMBparams.set_accuracy()
model.CAMBparams.set_classes()
dark_energy.DarkEnergyEqnOfState.set_params()
(or equivalent if a different dark energy model class used)model.CAMBparams.set_cosmology()
model.CAMBparams.set_matter_power()
model.CAMBparams.set_for_lmax()
initialpower.InitialPowerLaw.set_params()
(or equivalent if a different initial power model class used)nonlinear.Halofit.set_params()
Parameters: - params – the values of the parameters
- cp – use this CAMBparams instead of creating a new one
- verbose – print out the equivalent set of commands
Returns: model.CAMBparams
instance
-
isitgr.
read_ini
(ini_filename, no_validate=False)[source]¶ Get a
model.CAMBparams
instance using parameter specified in a .ini parameter file.Parameters: - ini_filename – path of the .ini file to read
- no_validate – do not pre-validate the ini file (faster, but may crash kernel if error)
Returns: model.CAMBparams
instance
-
isitgr.
get_matter_power_interpolator
(params, zmin=0, zmax=10, nz_step=100, zs=None, kmax=10, nonlinear=True, var1=None, var2=None, hubble_units=True, k_hunit=True, return_z_k=False, k_per_logint=None, log_interp=True, extrap_kmax=None)[source]¶ Return a 2D spline interpolation object to evaluate matter power spectrum as function of z and k/h, e.g.
from isitgr import get_matter_power_interpolator PK = get_matter_power_interpolator(params); print('Power spectrum at z=0.5, k/h=0.1/Mpc is %s (Mpc/h)^3 '%(PK.P(0.5, 0.1)))
For a description of outputs for different var1, var2 see Matter power spectrum and matter transfer function variables. If you already have a
CAMBdata
result object, you can instead useget_matter_power_interpolator()
.Parameters: - params –
model.CAMBparams
instance - zmin – minimum z (use 0 or smaller than you want for good interpolation)
- zmax – maximum z (use larger than you want for good interpolation)
- nz_step – number of steps to sample in z (default max allowed is 100)
- zs – instead of zmin,zmax, nz_step, can specific explicit array of z values to spline from
- kmax – maximum k
- nonlinear – include non-linear correction from halo model
- var1 – variable i (index, or name of variable; default delta_tot)
- var2 – variable j (index, or name of variable; default delta_tot)
- hubble_units – if true, output power spectrum in \(({\rm Mpc}/h)^{3}\) units, otherwise \({\rm Mpc}^{3}\)
- k_hunit – if true, matter power is a function of k/h, if false, just k (both \({\rm Mpc}^{-1}\) units)
- return_z_k – if true, return interpolator, z, k where z, k are the grid used
- k_per_logint – specific uniform sampling over log k (if not set, uses optimized irregular sampling)
- log_interp – if true, interpolate log of power spectrum (unless any values are negative in which case ignored)
- extrap_kmax – if set, use power law extrapolation beyond kmax to extrap_kmax (useful for tails of integrals)
Returns: An object PK based on
RectBivariateSpline
, that can be called with PK.P(z,kh) or PK(z,log(kh)) to get log matter power values. If return_z_k=True, instead return interpolator, z, k where z, k are the grid used.- params –
-
isitgr.
get_age
(params)[source]¶ Get age of universe for given set of parameters
Parameters: params – model.CAMBparams
instanceReturns: age of universe in gigayears
-
isitgr.
get_zre_from_tau
(params, tau)[source]¶ Get reionization redshift given optical depth tau
Parameters: - params –
model.CAMBparams
instance - tau – optical depth
Returns: reionization redshift (or negative number if error)
- params –
-
isitgr.
set_feedback_level
(level=1)[source]¶ Set the feedback level for internal CAMB calls
Parameters: level – zero for nothing, >1 for more
-
isitgr.
run_ini
(ini_filename, no_validate=False)[source]¶ Run the command line camb from a .ini file (producing text files as with the command line program). This does the same as the command line program, except global config parameters are not read and set (which does not change results in almost all cases).
Parameters: - ini_filename – .ini file to use
- no_validate – do not pre-validate the ini file (faster, but may crash kernel if error)