API¶
Cosmology¶
Cosmology class
- cosmoprimo.cosmology.Background(cosmology, engine=None, set_engine=True, **extra_params)¶
Return
Backgroundcalculations.- Parameters
cosmology (Cosmology) – Current cosmology.
engine (string, default=None) – Engine name, one of [‘class’, ‘camb’, ‘eisenstein_hu’, ‘eisenstein_hu_nowiggle’, ‘bbks’]. If
None, returns currentCosmology.engine.set_engine (bool, default=True) – Whether to attach returned engine to
cosmology(SetFalseif e.g. you want to use this engine for a single calculation).extra_params (dict) – Extra engine parameters, typically precision parameters.
- Returns
engine
- Return type
- class cosmoprimo.cosmology.BaseBackground(engine)¶
Bases:
cosmoprimo.cosmology.BaseSectionBase background engine, including a few definitions.
- Omega_Lambda(z)¶
Density of cosmological constant, unitless.
- Omega_b(z)¶
Density parameter of baryons, unitless.
- Omega_cdm(z)¶
Density parameter of cold dark matter, unitless.
- Omega_de(z)¶
Density of total dark energy (fluid + cosmological constant), unitless.
- Omega_fld(z)¶
Density of cosmological constant, unitless.
- Omega_g(z)¶
Density parameter of photons, unitless.
- Omega_k(z)¶
Density parameter of curvature, unitless.
- Omega_m(z)¶
Density parameter of non-relativistic (matter-like) component, including non-relativistic part of massive neutrino, unitless.
- Omega_ncdm(z)¶
Density parameter of massive neutrinos, unitless. If
speciesisNonereturned shape is (N_ncdm,) ifzis a scalar, else (N_ncdm, len(z)). Else ifspeciesis between 0 and N_ncdm, return density for this species.
- Omega_ncdm_tot(z)¶
Total density parameter of massive neutrinos, unitless.
- Omega_pncdm(z, species=None)¶
Density parameter of pressure of non-relativistic part of massive neutrinos, unitless. If
speciesisNonereturned shape is (N_ncdm,) ifzis a scalar, else (N_ncdm, len(z)). Else ifspeciesis between 0 and N_ncdm, return density for this species.
- Omega_pncdm_tot(z)¶
Total density parameter of pressure of non-relativistic part of massive neutrinos, unitless.
- Omega_r(z)¶
Density parameter of relativistic (radiation-like) component, including relativistic part of massive neutrino and massless neutrino, unitless.
- Omega_ur(z)¶
Density parameter of ultra relativistic neutrinos, unitless.
- T_cmb(z)¶
The CMB temperature, in \(K\).
- T_ncdm(z)¶
Return the ncdm temperature (massive neutrinos), in \(K\). Returned shape is (N_ncdm,) if
zis a scalar, else (N_ncdm, len(z)).
- efunc(z)¶
Function giving \(E(z)\), where the Hubble parameter is defined as \(H(z) = H_{0} E(z)\), unitless.
- hubble_function(z)¶
Hubble function
ba.index_bg_H, in \(\mathrm{km}/\mathrm{s}/\mathrm{Mpc}\).
- p_ncdm(z, species=None)¶
Pressure of non-relativistic part of massive neutrinos for each species, in \(10^{10} M_{\odot}/h / (\mathrm{Mpc}/h)^{3}\). If
speciesisNonereturned shape is (N_ncdm,) ifzis a scalar, else (N_ncdm, len(z)). Else ifspeciesis between 0 and N_ncdm, return pressure for this species.
- p_ncdm_tot(z)¶
Total pressure of non-relativistic part of massive neutrinos, in \(10^{10} M_{\odot}/h / (\mathrm{Mpc}/h)^{3}\).
- rho_Lambda(z)¶
Comoving density of cosmological constant \(\rho_{\Lambda}\), in \(10^{10} M_{\odot}/h / (\mathrm{Mpc}/h)^{3}\).
- rho_b(z)¶
Comoving density of baryons \(\rho_{b}\), in \(10^{10} M_{\odot}/h / (\mathrm{Mpc}/h)^{3}\).
- rho_cdm(z)¶
Comoving density of cold dark matter \(\rho_{cdm}\), in \(10^{10} M_{\odot}/h / (\mathrm{Mpc}/h)^{3}\).
- rho_crit(z)¶
Comoving critical density excluding curvature \(\rho_{c}\), in \(10^{10} M_{\odot}/h / (\mathrm{Mpc}/h)^{3}\).
This is defined as:
\[\rho_{\mathrm{crit}}(z) = \frac{3 H(z)^{2}}{8 \pi G}.\]
- rho_de(z)¶
Total comoving density of dark energy \(\rho_{\mathrm{de}}\) (fluid + cosmological constant), in \(10^{10} M_{\odot}/h / (\mathrm{Mpc}/h)^{3}\).
- rho_fld(z)¶
Comoving density of dark energy fluid \(\rho_{\mathrm{fld}}\), in \(10^{10} M_{\odot}/h / (\mathrm{Mpc}/h)^{3}\).
- rho_g(z)¶
Comoving density of photons \(\rho_{g}\), in \(10^{10} M_{\odot}/h / (\mathrm{Mpc}/h)^{3}\).
- rho_k(z)¶
Comoving density of curvature \(\rho_{k}\), in \(10^{10} M_{\odot}/h / (\mathrm{Mpc}/h)^{3}\).
- rho_m(z)¶
Comoving density of matter \(\rho_{m}\), in \(10^{10} M_{\odot}/h / (\mathrm{Mpc}/h)^{3}\).
- rho_ncdm(z, species=None)¶
Comoving density of non-relativistic part of massive neutrinos for each species, in \(10^{10} M_{\odot}/h / (\mathrm{Mpc}/h)^{3}\). If
speciesisNonereturned shape is (N_ncdm,) ifzis a scalar, else (N_ncdm, len(z)). Else ifspeciesis between 0 and N_ncdm, return density for this species.
- rho_ncdm_tot(z)¶
Total comoving density of non-relativistic part of massive neutrinos, in \(10^{10} M_{\odot}/h / (\mathrm{Mpc}/h)^{3}\).
- rho_r(z)¶
Comoving density of radiation \(\rho_{r}\), in \(10^{10} M_{\odot}/h / (\mathrm{Mpc}/h)^{3}\).
- rho_tot(z)¶
Comoving total density \(\rho_{\mathrm{tot}}\), in \(10^{10} M_{\odot}/h / (\mathrm{Mpc}/h)^{3}\).
- rho_ur(z)¶
Comoving density of ultra-relativistic radiation (massless neutrinos) \(\rho_{ur}\), in \(10^{10} M_{\odot}/h / (\mathrm{Mpc}/h)^{3}\).
- class cosmoprimo.cosmology.BaseEngine(extra_params=None, **params)¶
Bases:
cosmoprimo.utils.BaseClassBase engine for cosmological calculation.
Initialize engine.
- Parameters
extra_params (dict, default=None) – Extra engine parameters, typically precision parameters.
params (dict) – Engine parameters.
- get(*args, **kwargs)¶
Return an input (or easily derived) parameter.
- get_background()¶
Return
Backgroundcalculations.
- get_perturbations()¶
Return
Perturbationscalculations.
- get_primordial()¶
Return
Primordialcalculations.
- get_thermodynamics()¶
Return
Thermodynamicscalculations.
- class cosmoprimo.cosmology.BaseSection(engine)¶
Bases:
objectBase section.
- class cosmoprimo.cosmology.Cosmology(engine=None, extra_params=None, **params)¶
Bases:
cosmoprimo.cosmology.BaseEngineCosmology, defined as a set of parameters (and possibly a current engine attached to it).
Initialize
Cosmology.Note
Massive neutrinos can be provided e.g. through
m_ncdmorOmega_ncdm/omega_ncdmwith their temperatures w.r.t. CMBT_ncdm_over_cmb. In the case ofOmega_ncdm, the neutrino energy density (see_compute_ncdm_momenta()) will be inverted to recoverm_ncdm. If a single value form_ncdmorOmega_ncdmis provided,neutrino_hierarchycan be set toNone(default, single massive neutrino) or ‘normal’, ‘inverted’, ‘degenerate’ (all neutrinos with same mass), which will determine the masses of the 3 neutrinos. If the number of relativistic speciesN_uris not provided (orNone), it will be determined from the desired effective number of neutrinosN_eff(typically kept at 3.044 for 3 neutrinos whateverm_ncdmorOmega_ncdm/omega_ncdm) and the number of massless neutrinos (\(m \leq 0.00017\)), which are then removed from the listm_ncdm. ParameterOmega_ncdm/omega_ncdm(accessed ascosmo['Omega_ncdm']/cosmo['omega_ncdm']) will always provide the total energy density of neutrinos (single value). The pivot scalek_pivotis in \(\mathrm{Mpc}^{-1}\).`- Parameters
engine (string, default=None) – Engine name, one of [‘class’, ‘camb’, ‘eisenstein_hu’, ‘eisenstein_hu_nowiggle’, ‘bbks’]. If
None, no engine is set.extra_params (dict, default=None) – Extra engine parameters, typically precision parameters.
params (dict) – Cosmological and calculation parameters which take priority over the default ones.
- clone(engine=None, extra_params=None, **params)¶
Clone current cosmology instance, optionally updating engine and parameters.
- Parameters
engine (string, default=None) – Engine name, one of [‘class’, ‘camb’, ‘eisenstein_hu’, ‘eisenstein_hu_nowiggle’, ‘bbks’]. If
None, use same engine (class) as current instance.extra_params (dict, default=None) – Extra engine parameters, typically precision parameters.
params (dict) – Cosmological and calculation parameters which take priority over the current ones.
- Returns
new – Copy of current instance, with updated engine and parameters.
- Return type
- classmethod from_state(state)¶
Instantiate and initalise class with state dictionary.
- get(*args, **kwargs)¶
Return an input (or easily derived) parameter.
- get_background(engine=None, set_engine=True, **extra_params)¶
Get background.
- Parameters
engine (string, default=None) – Engine name, one of [‘class’, ‘camb’, ‘eisenstein_hu’, ‘eisenstein_hu_nowiggle’, ‘bbks’]. If
None, returns currentCosmology.engine.set_engine (bool, default=True) – Whether to attach returned engine to
cosmology. (SetFalseif e.g. you want to use this engine for a single calculation).extra_params (dict) – Extra engine parameters, typically precision parameters.
- classmethod get_default_parameters(of=None, include_conflicts=True)¶
Return default input parameters.
- Parameters
of (string, default=None) – One of [‘cosmology’,’calculation’]. If
None, returns all parameters.include_conflicts (bool, default=True) – Whether to include conflicting parameters (then all accepted parameters).
- Returns
params – Dictionary of default parameters.
- Return type
dict
- get_fourier(engine=None, set_engine=True, **extra_params)¶
Get fourier.
- Parameters
engine (string, default=None) – Engine name, one of [‘class’, ‘camb’, ‘eisenstein_hu’, ‘eisenstein_hu_nowiggle’, ‘bbks’]. If
None, returns currentCosmology.engine.set_engine (bool, default=True) – Whether to attach returned engine to
cosmology. (SetFalseif e.g. you want to use this engine for a single calculation).extra_params (dict) – Extra engine parameters, typically precision parameters.
- get_harmonic(engine=None, set_engine=True, **extra_params)¶
Get harmonic.
- Parameters
engine (string, default=None) – Engine name, one of [‘class’, ‘camb’, ‘eisenstein_hu’, ‘eisenstein_hu_nowiggle’, ‘bbks’]. If
None, returns currentCosmology.engine.set_engine (bool, default=True) – Whether to attach returned engine to
cosmology. (SetFalseif e.g. you want to use this engine for a single calculation).extra_params (dict) – Extra engine parameters, typically precision parameters.
- get_perturbations(engine=None, set_engine=True, **extra_params)¶
Get perturbations.
- Parameters
engine (string, default=None) – Engine name, one of [‘class’, ‘camb’, ‘eisenstein_hu’, ‘eisenstein_hu_nowiggle’, ‘bbks’]. If
None, returns currentCosmology.engine.set_engine (bool, default=True) – Whether to attach returned engine to
cosmology. (SetFalseif e.g. you want to use this engine for a single calculation).extra_params (dict) – Extra engine parameters, typically precision parameters.
- get_primordial(engine=None, set_engine=True, **extra_params)¶
Get primordial.
- Parameters
engine (string, default=None) – Engine name, one of [‘class’, ‘camb’, ‘eisenstein_hu’, ‘eisenstein_hu_nowiggle’, ‘bbks’]. If
None, returns currentCosmology.engine.set_engine (bool, default=True) – Whether to attach returned engine to
cosmology. (SetFalseif e.g. you want to use this engine for a single calculation).extra_params (dict) – Extra engine parameters, typically precision parameters.
- get_thermodynamics(engine=None, set_engine=True, **extra_params)¶
Get thermodynamics.
- Parameters
engine (string, default=None) – Engine name, one of [‘class’, ‘camb’, ‘eisenstein_hu’, ‘eisenstein_hu_nowiggle’, ‘bbks’]. If
None, returns currentCosmology.engine.set_engine (bool, default=True) – Whether to attach returned engine to
cosmology. (SetFalseif e.g. you want to use this engine for a single calculation).extra_params (dict) – Extra engine parameters, typically precision parameters.
- get_transfer(engine=None, set_engine=True, **extra_params)¶
Get transfer.
- Parameters
engine (string, default=None) – Engine name, one of [‘class’, ‘camb’, ‘eisenstein_hu’, ‘eisenstein_hu_nowiggle’, ‘bbks’]. If
None, returns currentCosmology.engine.set_engine (bool, default=True) – Whether to attach returned engine to
cosmology. (SetFalseif e.g. you want to use this engine for a single calculation).extra_params (dict) – Extra engine parameters, typically precision parameters.
- classmethod load(filename)¶
Load class from disk.
- save(filename)¶
Save class to disk.
- set_engine(engine, set_engine=True, **extra_params)¶
Set engine for cosmological calculation.
- Parameters
engine (string) – Engine name, one of [‘class’, ‘camb’, ‘eisenstein_hu’, ‘eisenstein_hu_nowiggle’, ‘bbks’].
set_engine (bool, default=True) – Whether to attach returned engine to
cosmology. (SetFalseif e.g. you want to use this engine for a single calculation).extra_params (dict) – Extra engine parameters, typically precision parameters.
- exception cosmoprimo.cosmology.CosmologyError¶
Bases:
ExceptionException raised by
Cosmology.- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- cosmoprimo.cosmology.Fourier(cosmology, engine=None, set_engine=True, **extra_params)¶
Return
Fouriercalculations.- Parameters
cosmology (Cosmology) – Current cosmology.
engine (string, default=None) – Engine name, one of [‘class’, ‘camb’, ‘eisenstein_hu’, ‘eisenstein_hu_nowiggle’, ‘bbks’]. If
None, returns currentCosmology.engine.set_engine (bool, default=True) – Whether to attach returned engine to
cosmology(SetFalseif e.g. you want to use this engine for a single calculation).extra_params (dict) – Extra engine parameters, typically precision parameters.
- Returns
engine
- Return type
- cosmoprimo.cosmology.Harmonic(cosmology, engine=None, set_engine=True, **extra_params)¶
Return
Harmoniccalculations.- Parameters
cosmology (Cosmology) – Current cosmology.
engine (string, default=None) – Engine name, one of [‘class’, ‘camb’, ‘eisenstein_hu’, ‘eisenstein_hu_nowiggle’, ‘bbks’]. If
None, returns currentCosmology.engine.set_engine (bool, default=True) – Whether to attach returned engine to
cosmology(SetFalseif e.g. you want to use this engine for a single calculation).extra_params (dict) – Extra engine parameters, typically precision parameters.
- Returns
engine
- Return type
- cosmoprimo.cosmology.Perturbations(cosmology, engine=None, set_engine=True, **extra_params)¶
Return
Perturbationscalculations.- Parameters
cosmology (Cosmology) – Current cosmology.
engine (string, default=None) – Engine name, one of [‘class’, ‘camb’, ‘eisenstein_hu’, ‘eisenstein_hu_nowiggle’, ‘bbks’]. If
None, returns currentCosmology.engine.set_engine (bool, default=True) – Whether to attach returned engine to
cosmology(SetFalseif e.g. you want to use this engine for a single calculation).extra_params (dict) – Extra engine parameters, typically precision parameters.
- Returns
engine
- Return type
- cosmoprimo.cosmology.Primordial(cosmology, engine=None, set_engine=True, **extra_params)¶
Return
Primordialcalculations.- Parameters
cosmology (Cosmology) – Current cosmology.
engine (string, default=None) – Engine name, one of [‘class’, ‘camb’, ‘eisenstein_hu’, ‘eisenstein_hu_nowiggle’, ‘bbks’]. If
None, returns currentCosmology.engine.set_engine (bool, default=True) – Whether to attach returned engine to
cosmology(SetFalseif e.g. you want to use this engine for a single calculation).extra_params (dict) – Extra engine parameters, typically precision parameters.
- Returns
engine
- Return type
- class cosmoprimo.cosmology.RegisteredEngine(name, bases, class_dict)¶
Bases:
typeMetaclass registering
BaseEngine-derived classes.- mro()¶
Return a type’s method resolution order.
- cosmoprimo.cosmology.Thermodynamics(cosmology, engine=None, set_engine=True, **extra_params)¶
Return
Thermodynamicscalculations.- Parameters
cosmology (Cosmology) – Current cosmology.
engine (string, default=None) – Engine name, one of [‘class’, ‘camb’, ‘eisenstein_hu’, ‘eisenstein_hu_nowiggle’, ‘bbks’]. If
None, returns currentCosmology.engine.set_engine (bool, default=True) – Whether to attach returned engine to
cosmology(SetFalseif e.g. you want to use this engine for a single calculation).extra_params (dict) – Extra engine parameters, typically precision parameters.
- Returns
engine
- Return type
- cosmoprimo.cosmology.Transfer(cosmology, engine=None, set_engine=True, **extra_params)¶
Return
Transfercalculations.- Parameters
cosmology (Cosmology) – Current cosmology.
engine (string, default=None) – Engine name, one of [‘class’, ‘camb’, ‘eisenstein_hu’, ‘eisenstein_hu_nowiggle’, ‘bbks’]. If
None, returns currentCosmology.engine.set_engine (bool, default=True) – Whether to attach returned engine to
cosmology(SetFalseif e.g. you want to use this engine for a single calculation).extra_params (dict) – Extra engine parameters, typically precision parameters.
- Returns
engine
- Return type
- cosmoprimo.cosmology.check_params(args)¶
Check for conflicting parameters in
argsparameter dictionary.
- cosmoprimo.cosmology.compile_params(args)¶
Compile parameters
args: - normalise parameter names - perform immediate parameter derivations (e.g. omega => Omega) - set neutrino masses if relevant- Parameters
args (dict) – Input parameter dictionary, without parameter conflicts.
- Returns
params – Normalised parameter dictionary.
- Return type
dict
References
https://github.com/bccp/nbodykit/blob/master/nbodykit/cosmology/cosmology.py
- cosmoprimo.cosmology.find_conflicts(name)¶
Return conflicts corresponding to input parameter name.
- Parameters
name (string) – Parameter name.
- Returns
conflicts – Conflicting parameter names.
- Return type
tuple
- cosmoprimo.cosmology.get_engine(engine)¶
Return engine (class) for cosmological calculation.
- Parameters
engine (BaseEngine, string) – Engine or one of [‘class’, ‘camb’, ‘eisenstein_hu’, ‘eisenstein_hu_nowiggle’, ‘bbks’].
- Returns
engine
- Return type
- cosmoprimo.cosmology.merge_params(args, moreargs)¶
Merge
moreargsparameters intoargs.moreargsparameters take priority over those defined inargs.Note
argsis modified in-place.- Parameters
args (dict) – Base parameter dictionary.
moreargs (dict) – Parameter dictionary to be merged into
args.
- Returns
args – Merged parameter dictionary.
- Return type
dict
Engines¶
CLASS¶
Cosmological calculation with the Boltzmann code CLASS.
- class cosmoprimo.classy.ClassEngine(*args: Any, **kwargs: Any)¶
Bases:
pyclass.ClassEngine,cosmoprimo.cosmology.BaseEngineEngine for the Boltzmann code CLASS.
Initialize engine.
- Parameters
extra_params (dict, default=None) – Extra engine parameters, typically precision parameters.
params (dict) – Engine parameters.
- get(*args, **kwargs)¶
Return an input (or easily derived) parameter.
- get_background()¶
Return
Backgroundcalculations.
- get_perturbations()¶
Return
Perturbationscalculations.
- get_primordial()¶
Return
Primordialcalculations.
- get_thermodynamics()¶
Return
Thermodynamicscalculations.
- get_transfer()¶
Return
Transfercalculations.
- class cosmoprimo.classy.Fourier(*args: Any, **kwargs: Any)¶
Bases:
pyclass.Fourier- pk_interpolator(nonlinear=False, of='delta_m', **kwargs)¶
Return
PowerSpectrumInterpolator2Dinstance.- Parameters
nonlinear (bool, default=False) – Whether to return the nonlinear power spectrum (if requested in parameters, with ‘nonlinear’:’halofit’ or ‘HMcode’). Computed only for
of == 'delta_m'or ‘delta_cb’.of (string, tuple, default='delta_m') – Perturbed quantities. Either ‘delta_m’ for matter perturbations or ‘delta_cb’ for cold dark matter + baryons perturbations will use precomputed spectra. Else, e.g. (‘delta_m’,’theta_cb’) for the cross matter density - cold dark matter + baryons velocity power spectra, are computed on-the-fly.
kwargs (dict) – Arguments for
PowerSpectrumInterpolator2D.
- pk_kz(k, z, nonlinear=False, of='m')¶
Return power spectrum, in \((\mathrm{Mpc}/h)^{3}\), using original CLASS routine.
- Parameters
k (array_like) – Wavenumbers, in \(h/\mathrm{Mpc}\).
z (array_like) – Redshifts.
nonlinear (bool, default=False) – Whether to return the nonlinear power spectrum (if requested in parameters, with ‘nonlinear’:’halofit’ or ‘HMcode’).
of (string, default='delta_m') – Perturbed quantities. Either ‘delta_m’ for matter perturbations or ‘delta_cb’ for cold dark matter + baryons perturbations.
- Returns
pk – Power spectrum array of shape (len(k),len(z)).
- Return type
array
- property sigma8_cb¶
Current r.m.s. of cold dark matter + baryons perturbations in a sphere of \(8 \mathrm{Mpc}/h\) unitless.
- property sigma8_m¶
Current r.m.s. of matter perturbations in a sphere of \(8 \mathrm{Mpc}/h\), unitless.
- sigma8_z(z, of='delta_m')¶
Return the r.m.s. of of perturbations in sphere of \(8 \mathrm{Mpc}/h\).
- sigma_rz(r, z, of='delta_m', **kwargs)¶
Return the r.m.s. of of perturbations in sphere of \(r \mathrm{Mpc}/h\).
- table(nonlinear=False, of='delta_m')¶
Return power spectrum table, in \((\mathrm{Mpc}/h)^{3}\).
- Parameters
nonlinear (bool, default=False) – Whether to return the nonlinear power spectrum (if requested in parameters, with ‘nonlinear’:’halofit’ or ‘HMcode’). Computed only for
of == 'delta_m'or ‘delta_cb’.of (string, tuple, default='delta_m') – Perturbed quantities. Either ‘delta_m’ for matter perturbations or ‘delta_cb’ for cold dark matter + baryons perturbations will use precomputed spectra. Else, e.g. (‘delta_m’,’theta_cb’) for the cross matter density - cold dark matter + baryons velocity power spectra, are computed on-the-fly.
- Returns
k (array) – Wavenumbers.
z (array) – Redshifts.
pk (array) – Power spectrum array of shape (len(k),len(z)).
- class cosmoprimo.classy.Harmonic(*args: Any, **kwargs: Any)¶
Bases:
pyclass.Harmonic- lensed_table(ellmax=- 1, of=None)¶
Return table of lensed \(C_{\ell}\), unitless.
- Parameters
ellmax (int, default=-1) – Maximum \(\ell\) desired. If negative, is relative to the requested maximum \(\ell\).
of (list, default=None) – List of outputs, [‘tt’,’ee’,’bb’,’pp’,’te’,’tp’]. If
None, return all computed outputs.
- Returns
cell – Structured array.
- Return type
array
- unlensed_table(ellmax=- 1, of=None)¶
Return table of unlensed \(C_{\ell}\) (i.e. CMB power spectra without lensing and lensing potentials), unitless.
- Parameters
ellmax (int, default=-1) – Maximum \(\ell\) desired. If negative, is relative to the requested maximum \(\ell\).
of (list, default=None) – List of outputs, [‘tt’,’ee’,’bb’,’te’,’pp’,’tp’,’ep’]. If
None, return all computed outputs.
- Returns
cell – Structured array.
- Return type
array
Note
Normalisation is \(C_{\ell}\) rather than \(\ell(\ell+1)C_{\ell}/(2\pi)\) (or \(\ell^{2}(\ell+1)^{2}/(2\pi)\) in the case of the lensing potential
ppspectrum). Usually multiplied by CMB temperature in \(\mu K\).
- class cosmoprimo.classy.Primordial(*args: Any, **kwargs: Any)¶
Bases:
pyclass.Primordial- property A_s¶
Scalar amplitude of the primordial power spectrum at \(k_\mathrm{pivot}\), unitless.
- property ln_1e10_A_s¶
\(\ln(10^{10}A_s)\), unitless.
- pk_interpolator(mode='scalar')¶
Return power spectrum interpolator.
- Parameters
mode (string, default='scalar') – ‘scalar’, ‘vector’ or ‘tensor’ mode.
- Returns
interp –
PowerSpectrumInterpolator1Dinstance if only one type of initial conditions (typically adiabatic), else dictionary of class:PowerSpectrumInterpolator1D corresponding to the tuples of initial conditions.- Return type
- pk_k(k, mode='scalar')¶
The primordial spectrum of curvature perturbations at
k, generated by inflation, in \((\mathrm{Mpc}/h)^{3}\). For scalar perturbations this is e.g. defined as:\[\mathcal{P_R}(k) = A_s \left (\frac{k}{k_0} \right )^{n_s - 1 + 1/2 \ln(k/k_0) (dn_s / d\ln k)}\]See also: eq. 2 of this reference.
- Parameters
k (array_like) – Wavenumbers, in \(h/\mathrm{Mpc}\).
mode (string, default='scalar') – ‘scalar’, ‘vector’ or ‘tensor’ mode.
- Returns
pk – The primordial power spectrum if only one type of initial conditions (typically adiabatic), else dictionary of primordial power spectra corresponding to the tuples of initial conditions.
- Return type
array, dict
- table()¶
Return primordial table.
- Returns
data – Structured array containing thermodynamics data.
- Return type
array
CAMB¶
Cosmological calculation with the Boltzmann code CAMB.
- class cosmoprimo.camb.Background(engine)¶
Bases:
cosmoprimo.cosmology.BaseBackground- Omega_Lambda(z)¶
Density of cosmological constant, unitless.
- Omega_b(z)¶
Density parameter of baryons, unitless.
- Omega_cdm(z)¶
Density parameter of cold dark matter, unitless.
- Omega_de(z)¶
Total density of dark energy (fluid + cosmological constant), unitless.
- Omega_fld(z)¶
Density of cosmological constant, unitless.
- Omega_g(z)¶
Density parameter of photons, unitless.
- Omega_k(z)¶
Density parameter of curvature, unitless.
- Omega_m(z)¶
Density parameter of non-relativistic (matter-like) component, including non-relativistic part of massive neutrino, unitless.
- Omega_ncdm(z)¶
Density parameter of massive neutrinos, unitless. If
speciesisNonereturned shape is (N_ncdm,) ifzis a scalar, else (N_ncdm, len(z)). Else ifspeciesis between 0 and N_ncdm, return density for this species.
- Omega_ncdm_tot(z)¶
Total density parameter of massive neutrinos, unitless.
- Omega_pncdm(z, species=None)¶
Density parameter of pressure of non-relativistic part of massive neutrinos, unitless. If
speciesisNonereturned shape is (N_ncdm,) ifzis a scalar, else (N_ncdm, len(z)). Else ifspeciesis between 0 and N_ncdm, return density for this species.
- Omega_pncdm_tot(z)¶
Total density parameter of pressure of non-relativistic part of massive neutrinos, unitless.
- Omega_r(z)¶
Density parameter of relativistic (radiation-like) component, including relativistic part of massive neutrino and massless neutrino, unitless.
- Omega_ur(z)¶
Density parameter of ultra relativistic neutrinos, unitless.
- T_cmb(z)¶
The CMB temperature, in \(K\).
- T_ncdm(z)¶
Return the ncdm temperature (massive neutrinos), in \(K\). Returned shape is (N_ncdm,) if
zis a scalar, else (N_ncdm, len(z)).
- angular_diameter_distance(z)¶
Proper angular diameter distance, in \(\mathrm{Mpc}/h\).
See eq. 18 of astro-ph/9905116 for \(D_{A}(z)\).
- comoving_angular_distance(z)¶
Comoving angular distance, in \(\mathrm{Mpc}/h\).
See eq. 16 of astro-ph/9905116 for \(D_{M}(z)\).
- comoving_radial_distance(z)¶
Comoving radial distance, in \(mathrm{Mpc}/h\).
See eq. 15 of astro-ph/9905116 for \(D_C(z)\).
- efunc(z)¶
Function giving \(E(z)\), where the Hubble parameter is defined as \(H(z) = H_{0} E(z)\), unitless.
- hubble_function(z)¶
Hubble function, in \(\mathrm{km}/\mathrm{s}/\mathrm{Mpc}\).
- luminosity_distance(z)¶
Luminosity distance, in \(\mathrm{Mpc}/h\).
See eq. 21 of astro-ph/9905116 for \(D_{L}(z)\).
- p_ncdm(z, species=None)¶
Pressure of non-relativistic part of massive neutrinos for each species, in \(10^{10} M_{\odot}/h / (\mathrm{Mpc}/h)^{3}\). If
speciesisNonereturned shape is (N_ncdm,) ifzis a scalar, else (N_ncdm, len(z)). Else ifspeciesis between 0 and N_ncdm, return pressure for this species.
- p_ncdm_tot(z)¶
Total pressure of non-relativistic part of massive neutrinos, in \(10^{10} M_{\odot}/h / (\mathrm{Mpc}/h)^{3}\).
- rho_Lambda(z)¶
Comoving density of cosmological constant \(\rho_{\Lambda}\), in \(10^{10} M_{\odot}/h / (\mathrm{Mpc}/h)^{3}\).
- rho_b(z)¶
Density parameter of baryons, unitless.
- rho_cdm(z)¶
Comoving density of cold dark matter \(\rho_{cdm}\), in \(10^{10} M_{\odot}/h / (\mathrm{Mpc}/h)^{3}\).
- rho_crit(z)¶
Comoving critical density excluding curvature \(\rho_{c}\), in \(10^{10} M_{\odot}/h / (\mathrm{Mpc}/h)^{3}\).
This is defined as:
\[\rho_{\mathrm{crit}}(z) = \frac{3 H(z)^{2}}{8 \pi G}.\]
- rho_de(z)¶
Comoving total density of dark energy \(\rho_{\mathrm{de}}\) (fluid + cosmological constant), in \(10^{10} M_{\odot}/h / (\mathrm{Mpc}/h)^{3}\).
- rho_fld(z)¶
Comoving density of dark energy fluid \(\rho_{\mathrm{fld}}\), in \(10^{10} M_{\odot}/h / (\mathrm{Mpc}/h)^{3}\).
- rho_g(z)¶
Comoving density of photons \(\rho_{g}\), in \(10^{10} M_{\odot}/h / (\mathrm{Mpc}/h)^{3}\).
- rho_k(z)¶
Comoving density of curvature \(\rho_{k}\), in \(10^{10} M_{\odot}/h / (\mathrm{Mpc}/h)^{3}\).
- rho_m(z)¶
Comoving density of matter \(\rho_{m}\), in \(10^{10} M_{\odot}/h / (\mathrm{Mpc}/h)^{3}\).
- rho_ncdm(z, species=None)¶
Comoving density of non-relativistic part of massive neutrinos for each species, in \(10^{10} M_{\odot}/h / (\mathrm{Mpc}/h)^{3}\). If
speciesisNonereturned shape is (N_ncdm,) ifzis a scalar, else (N_ncdm, len(z)). Else ifspeciesis between 0 and N_ncdm, return density for this species.
- rho_ncdm_tot(z)¶
Total comoving density of non-relativistic part of massive neutrinos \(\rho_{ncdm}\), in \(10^{10} M_{\odot}/h / (\mathrm{Mpc}/h)^{3}\).
- rho_r(z)¶
Comoving density of radiation \(\rho_{r}\), in \(10^{10} M_{\odot}/h / (\mathrm{Mpc}/h)^{3}\).
- rho_tot(z)¶
Comoving total density \(\rho_{\mathrm{tot}}\), in \(10^{10} M_{\odot}/h / (\mathrm{Mpc}/h)^{3}\).
- rho_ur(z)¶
Comoving density of ultra-relativistic radiation (massless neutrinos) \(\rho_{ur}\), in \(10^{10} M_{\odot}/h / (\mathrm{Mpc}/h)^{3}\).
- time(z)¶
Proper time (age of universe), in \(\mathrm{Gy}\).
- class cosmoprimo.camb.CambEngine(*args, **kwargs)¶
Bases:
cosmoprimo.cosmology.BaseEngineEngine for the Boltzmann code CAMB.
Initialize engine.
- Parameters
extra_params (dict, default=None) – Extra engine parameters, typically precision parameters.
params (dict) – Engine parameters.
- compute(tasks)¶
The main function, which executes the desired modules.
- Parameters
tasks (list, string) – Calculation to perform, in the following list: [‘background’, ‘thermodynamics’, ‘transfer’, ‘harmonic’, ‘lensing’, ‘fourier’]
- get(*args, **kwargs)¶
Return an input (or easily derived) parameter.
- get_background()¶
Return
Backgroundcalculations.
- get_perturbations()¶
Return
Perturbationscalculations.
- get_primordial()¶
Return
Primordialcalculations.
- get_thermodynamics()¶
Return
Thermodynamicscalculations.
- class cosmoprimo.camb.Fourier(engine)¶
Bases:
cosmoprimo.cosmology.BaseSection- pk_interpolator(nonlinear=False, of='delta_m', **kwargs)¶
Return
PowerSpectrumInterpolator2Dinstance.- Parameters
nonlinear (bool, default=False) – Whether to return the nonlinear power spectrum (if requested in parameters, with ‘nonlinear’:’halofit’ or ‘HMcode’). Computed only for of == ‘delta_m’.
of (string, tuple, default='delta_m') – Perturbed quantities. Does not make difference between ‘theta_cb’ and ‘theta_m’.
kwargs (dict) – Arguments for
PowerSpectrumInterpolator2D.
- pk_kz(k, z, nonlinear=False, of='delta_m')¶
Return power spectrum, in \((\mathrm{Mpc}/h)^{3}\).
- Parameters
k (array_like) – Wavenumbers, in \(h/\mathrm{Mpc}\).
z (array_like) – Redshifts.
nonlinear (bool, default=False) – Whether to return the nonlinear power spectrum (if requested in parameters, with ‘nonlinear’:’halofit’ or ‘HMcode’).
of (string, default='delta_m') – Perturbed quantities. Does not make difference between ‘theta_cb’ and ‘theta_m’.
- Returns
pk – Power spectrum array of shape (len(k),len(z)).
- Return type
array
- property sigma8_m¶
Current r.m.s. of matter perturbations in a sphere of \(8 \mathrm{Mpc}/h\), unitless.
- sigma8_z(z, of='delta_m')¶
Return the r.m.s. of of perturbations in sphere of \(8 \mathrm{Mpc}/h\).
- sigma_rz(r, z, of='delta_m', **kwargs)¶
Return the r.m.s. of of perturbations in sphere of \(r \mathrm{Mpc}/h\).
- table(nonlinear=False, of='m')¶
Return power spectrum table, in \((\mathrm{Mpc}/h)^{3}\).
- Parameters
nonlinear (bool, default=False) – Whether to return the nonlinear power spectrum (if requested in parameters, with ‘nonlinear’:’halofit’ or ‘HMcode’). Computed only for of == ‘delta_m’ or ‘delta_cb’.
of (string, tuple, default='delta_m') – Perturbed quantities. Does not make difference between ‘theta_cb’ and ‘theta_m’.
- Returns
k (array) – Wavenumbers.
z (array) – Redshifts.
pk (array) – Power spectrum array of shape (len(k),len(z)).
- class cosmoprimo.camb.Harmonic(engine)¶
Bases:
cosmoprimo.cosmology.BaseSection- lens_potential_cl(ellmax=- 1)¶
Return potential \(C_{\ell}\) [‘pp’,’tp’,’ep’], unitless.
- lensed_cl(ellmax=- 1)¶
Return lensed \(C_{\ell}\) [‘tt’,’ee’,’bb’,’te’], unitless.
- unlensed_cl(ellmax=- 1)¶
Return unlensed \(C_{\ell}\) [‘tt’,’ee’,’bb’,’te’], unitless.
- class cosmoprimo.camb.Primordial(engine)¶
Bases:
cosmoprimo.cosmology.BaseSection- property A_s¶
Scalar amplitude of the primordial power spectrum at \(k_\mathrm{pivot}\), unitless.
- property k_pivot¶
Primordial power spectrum pivot scale, where the primordial power is equal to \(A_{s}\), in \(h/\mathrm{Mpc}\).
- property ln_1e10_A_s¶
\(\ln(10^{10}A_s)\), unitless.
- property n_s¶
Power-law index i.e. tilt of the primordial power spectrum, unitless.
- pk_interpolator(mode='scalar')¶
Return power spectrum interpolator.
- Parameters
mode (string, default='scalar') – ‘scalar’, ‘vector’ or ‘tensor’ mode.
- Returns
interp
- Return type
- pk_k(k, mode='scalar')¶
The primordial spectrum of curvature perturbations at
k, generated by inflation, in \((\mathrm{Mpc}/h)^{3}\). For scalar perturbations this is e.g. defined as:\[\mathcal{P_R}(k) = A_s \left (\frac{k}{k_0} \right )^{n_s - 1 + 1/2 \ln(k/k_0) (dn_s / d\ln k)}\]See also: eq. 2 of this reference.
- Parameters
k (array_like) – Wavenumbers, in \(h/\mathrm{Mpc}\).
mode (string, default='scalar') – ‘scalar’, ‘vector’ or ‘tensor’ mode.
- Returns
pk – The primordial power spectrum.
- Return type
array
- class cosmoprimo.camb.Thermodynamics(engine)¶
Bases:
cosmoprimo.cosmology.BaseSection- rs_z(z)¶
Comoving sound horizon.
- class cosmoprimo.camb.Transfer(engine)¶
Bases:
cosmoprimo.cosmology.BaseSection- table()¶
Return source functions.
- Returns
tk – Dictionary of perturbed quantities (in array of shape (k size, z size)).
- Return type
dict
- cosmoprimo.camb.enum(*sequential, **named)¶
Enumeration values to serve as ready flags.
Eisenstein & Hu¶
- class cosmoprimo.eisenstein_hu.Background(engine)¶
Bases:
cosmoprimo.cosmology.BaseBackgroundBackground quantities.
Note
Does not treat neutrinos.
- Omega_Lambda(z)¶
Density of cosmological constant, unitless.
- Omega_b(z)¶
Density parameter of baryons, unitless.
- Omega_cdm(z)¶
Density parameter of cold dark matter, unitless.
- Omega_de(z)¶
Density of total dark energy (fluid + cosmological constant), unitless.
- Omega_fld(z)¶
Density of cosmological constant, unitless.
- Omega_g(z)¶
Density parameter of photons, unitless.
- Omega_k(z)¶
Density parameter of curvature, unitless.
- Omega_m(z)¶
Density parameter of non-relativistic (matter-like) component, including non-relativistic part of massive neutrino, unitless.
- Omega_ncdm(z)¶
Density parameter of massive neutrinos, unitless. If
speciesisNonereturned shape is (N_ncdm,) ifzis a scalar, else (N_ncdm, len(z)). Else ifspeciesis between 0 and N_ncdm, return density for this species.
- Omega_ncdm_tot(z)¶
Total density parameter of massive neutrinos, unitless.
- Omega_pncdm(z, species=None)¶
Density parameter of pressure of non-relativistic part of massive neutrinos, unitless. If
speciesisNonereturned shape is (N_ncdm,) ifzis a scalar, else (N_ncdm, len(z)). Else ifspeciesis between 0 and N_ncdm, return density for this species.
- Omega_pncdm_tot(z)¶
Total density parameter of pressure of non-relativistic part of massive neutrinos, unitless.
- Omega_r(z)¶
Density parameter of relativistic (radiation-like) component, including relativistic part of massive neutrino and massless neutrino, unitless.
- Omega_ur(z)¶
Density parameter of ultra relativistic neutrinos, unitless.
- T_cmb(z)¶
The CMB temperature, in \(K\).
- T_ncdm(z)¶
Return the ncdm temperature (massive neutrinos), in \(K\). Returned shape is (N_ncdm,) if
zis a scalar, else (N_ncdm, len(z)).
- efunc(z)¶
Function giving \(E(z)\), where the Hubble parameter is defined as \(H(z) = H_{0} E(z)\), unitless.
- growth_factor(z)¶
Approximation of growth factor.
References
https://arxiv.org/abs/astro-ph/9709112, eq. 4 https://ui.adsabs.harvard.edu/abs/1992ARA%26A..30..499C/abstract, eq. 29
- growth_rate(z)¶
Approximation of growth rate.
References
- hubble_function(z)¶
Hubble function
ba.index_bg_H, in \(\mathrm{km}/\mathrm{s}/\mathrm{Mpc}\).
- p_ncdm(z, species=None)¶
Pressure of non-relativistic part of massive neutrinos for each species, in \(10^{10} M_{\odot}/h / (\mathrm{Mpc}/h)^{3}\). If
speciesisNonereturned shape is (N_ncdm,) ifzis a scalar, else (N_ncdm, len(z)). Else ifspeciesis between 0 and N_ncdm, return pressure for this species.
- p_ncdm_tot(z)¶
Total pressure of non-relativistic part of massive neutrinos, in \(10^{10} M_{\odot}/h / (\mathrm{Mpc}/h)^{3}\).
- rho_Lambda(z)¶
Comoving density of cosmological constant \(\rho_{\Lambda}\), in \(10^{10} M_{\odot}/h / (\mathrm{Mpc}/h)^{3}\).
- rho_b(z)¶
Comoving density of baryons \(\rho_{b}\), in \(10^{10} M_{\odot}/h / (\mathrm{Mpc}/h)^{3}\).
- rho_cdm(z)¶
Comoving density of cold dark matter \(\rho_{cdm}\), in \(10^{10} M_{\odot}/h / (\mathrm{Mpc}/h)^{3}\).
- rho_crit(z)¶
Comoving critical density excluding curvature \(\rho_{c}\), in \(10^{10} M_{\odot}/h / (\mathrm{Mpc}/h)^{3}\).
This is defined as:
\[\rho_{\mathrm{crit}}(z) = \frac{3 H(z)^{2}}{8 \pi G}.\]
- rho_de(z)¶
Total comoving density of dark energy \(\rho_{\mathrm{de}}\) (fluid + cosmological constant), in \(10^{10} M_{\odot}/h / (\mathrm{Mpc}/h)^{3}\).
- rho_fld(z)¶
Comoving density of dark energy fluid \(\rho_{\mathrm{fld}}\), in \(10^{10} M_{\odot}/h / (\mathrm{Mpc}/h)^{3}\).
- rho_g(z)¶
Comoving density of photons \(\rho_{g}\), in \(10^{10} M_{\odot}/h / (\mathrm{Mpc}/h)^{3}\).
- rho_k(z)¶
Comoving density of curvature \(\rho_{k}\), in \(10^{10} M_{\odot}/h / (\mathrm{Mpc}/h)^{3}\).
- rho_m(z)¶
Comoving density of matter \(\rho_{m}\), in \(10^{10} M_{\odot}/h / (\mathrm{Mpc}/h)^{3}\).
- rho_ncdm(z, species=None)¶
Comoving density of non-relativistic part of massive neutrinos for each species, in \(10^{10} M_{\odot}/h / (\mathrm{Mpc}/h)^{3}\). If
speciesisNonereturned shape is (N_ncdm,) ifzis a scalar, else (N_ncdm, len(z)). Else ifspeciesis between 0 and N_ncdm, return density for this species.
- rho_ncdm_tot(z)¶
Total comoving density of non-relativistic part of massive neutrinos, in \(10^{10} M_{\odot}/h / (\mathrm{Mpc}/h)^{3}\).
- rho_r(z)¶
Comoving density of radiation \(\rho_{r}\), in \(10^{10} M_{\odot}/h / (\mathrm{Mpc}/h)^{3}\).
- rho_tot(z)¶
Comoving total density \(\rho_{\mathrm{tot}}\), in \(10^{10} M_{\odot}/h / (\mathrm{Mpc}/h)^{3}\).
- rho_ur(z)¶
Comoving density of ultra-relativistic radiation (massless neutrinos) \(\rho_{ur}\), in \(10^{10} M_{\odot}/h / (\mathrm{Mpc}/h)^{3}\).
- class cosmoprimo.eisenstein_hu.EisensteinHuEngine(*args, **kwargs)¶
Bases:
cosmoprimo.cosmology.BaseEngineImplementation of Eisenstein & Hu analytic formulae.
References
https://arxiv.org/abs/astro-ph/9709112
Initialize engine.
- Parameters
extra_params (dict, default=None) – Extra engine parameters, typically precision parameters.
params (dict) – Engine parameters.
- compute()¶
Precompute coefficients for the transfer function.
- get(*args, **kwargs)¶
Return an input (or easily derived) parameter.
- get_background()¶
Return
Backgroundcalculations.
- get_harmonic()¶
Return
Harmoniccalculations.
- get_perturbations()¶
Return
Perturbationscalculations.
- get_primordial()¶
Return
Primordialcalculations.
- get_thermodynamics()¶
Return
Thermodynamicscalculations.
- class cosmoprimo.eisenstein_hu.Fourier(engine)¶
Bases:
cosmoprimo.cosmology.BaseSection- pk_interpolator(of='delta_m', ignore_norm=False, **kwargs)¶
Return
PowerSpectrumInterpolator2Dinstance.- Parameters
of (string, tuple) – Perturbed quantities: ‘delta_m’, ‘theta_m’. No distinction is made between baryons and CDM. Requesting velocity divergence ‘theta_xx’ will rescale the power spectrum by the growth rate as a function of
z.ignore_norm (bool) – Whether to ignore power spectrum normalisation. If
False,sigma8should be provided as part of the parameters.kwargs (dict) – Arguments for
PowerSpectrumInterpolator2D.
- property sigma8_m¶
Current r.m.s. of matter perturbations in a sphere of \(8 \mathrm{Mpc}/h\), unitless.
- sigma8_z(z, of='delta_m')¶
Return the r.m.s. of of perturbations in sphere of \(8 \mathrm{Mpc}/h\). No distinction is made between baryons and CDM.
- sigma_rz(r, z, of='delta_m', **kwargs)¶
Return the r.m.s. of of perturbations in sphere of \(r \mathrm{Mpc}/h\). No distinction is made between baryons and CDM.
- class cosmoprimo.eisenstein_hu.Primordial(engine)¶
Bases:
cosmoprimo.cosmology.BaseSectionInitialize
Primordial.
- class cosmoprimo.eisenstein_hu.Thermodynamics(engine)¶
Bases:
cosmoprimo.cosmology.BaseSectionInitialize
Thermodynamics.
- class cosmoprimo.eisenstein_hu.Transfer(engine)¶
Bases:
cosmoprimo.cosmology.BaseSection- transfer_k(k, frac_baryon=None)¶
Return matter transfer function.
- Parameters
k (array_like) – Wavenumbers.
frac_baryon (float, default=None) – If not
None, scale the baryon transfer function w.r.t. to the CDM one. May be useful to remove BAO.
- Returns
transfer
- Return type
array
Eisenstein & Hu no-wiggle¶
- class cosmoprimo.eisenstein_hu_nowiggle.EisensteinHuNoWiggleEngine(*args, **kwargs)¶
Bases:
cosmoprimo.eisenstein_hu.EisensteinHuEngineImplementation of Eisenstein & Hu no-wiggle analytic formulae.
References
https://arxiv.org/abs/astro-ph/9709112
Initialize engine.
- Parameters
extra_params (dict, default=None) – Extra engine parameters, typically precision parameters.
params (dict) – Engine parameters.
- compute()¶
Precompute coefficients for the transfer function.
- get(*args, **kwargs)¶
Return an input (or easily derived) parameter.
- get_background()¶
Return
Backgroundcalculations.
- get_fourier()¶
Return
Fouriercalculations.
- get_harmonic()¶
Return
Harmoniccalculations.
- get_perturbations()¶
Return
Perturbationscalculations.
- get_primordial()¶
Return
Primordialcalculations.
- get_thermodynamics()¶
Return
Thermodynamicscalculations.
- class cosmoprimo.eisenstein_hu_nowiggle.Transfer(engine)¶
Bases:
cosmoprimo.cosmology.BaseSection- transfer_k(k)¶
Return matter transfer function.
- Parameters
k (array_like) – Wavenumbers.
- Returns
transfer
- Return type
array
BBKS¶
- class cosmoprimo.bbks.BBKSEngine(*args, **kwargs)¶
Bases:
cosmoprimo.cosmology.BaseEngineImplementation of BBKS no-wiggle analytic formulae.
References
https://ui.adsabs.harvard.edu/abs/1986ApJ…304…15B/abstract https://arxiv.org/abs/astro-ph/9412025 https://arxiv.org/abs/1812.05995
Initialize engine.
- Parameters
extra_params (dict, default=None) – Extra engine parameters, typically precision parameters.
params (dict) – Engine parameters.
- compute()¶
Precompute coefficients for the transfer function.
- get(*args, **kwargs)¶
Return an input (or easily derived) parameter.
- get_background()¶
Return
Backgroundcalculations.
- get_fourier()¶
Return
Fouriercalculations.
- get_harmonic()¶
Return
Harmoniccalculations.
- get_perturbations()¶
Return
Perturbationscalculations.
- get_primordial()¶
Return
Primordialcalculations.
- get_thermodynamics()¶
Return
Thermodynamicscalculations.
- class cosmoprimo.bbks.Transfer(engine)¶
Bases:
cosmoprimo.cosmology.BaseSection- transfer_k(k)¶
Return matter transfer function.
- Parameters
k (array_like) – Wavenumbers.
- Returns
transfer
- Return type
array
Utilities¶
BAO filter¶
Different techniques to extra BAO from the power spectrum of correlation function.
For the power spectrum, the most accurate one is Wallish2018PowerSpectrumBAOFilter.
For the correlation function: Kirkby2013CorrelationFunctionBAOFilter.
- class cosmoprimo.bao_filter.BaseCorrelationFunctionBAOFilter(xi_interpolator, cosmo=None, **kwargs)¶
Bases:
cosmoprimo.utils.BaseClassBase BAO filter for correlation function.
Run BAO filter.
- Parameters
xi_interpolator (CorrelationFunctionInterpolator1D, CorrelationFunctionInterpolator2D) – Input correlation function to remove BAO peak from.
cosmo (Cosmology, default=None) – Cosmology instance, which may be used to tune filter settings (depending on
rs_drag).kwargs (dict) – Arguments for
set_s().
- property cosmo¶
Cosmology.
- rs_drag_ratio()¶
If
cosmois provided, return the ratio of itsrs_dragto the fiducial one (fromCosmology()), else 1.
- set_s(ns=1024)¶
Set separations where to evaluate the correlation function (between
xi_interpolator.extrap_sminandxi_interpolator.extrap_smax).- Parameters
ns (int, default=1024) – Number of separations.
- smooth_pk_interpolator(**kwargs)¶
Return smooth (i.e. no-wiggle) power spectrum using
FFTlog.- Parameters
kwargs (dict) – Override interpolation and extrapolation settings of return power spectrum interpolator.
- Returns
interp – 1D or 2D depending on
pk_interpolator.- Return type
- smooth_xi_interpolator(**kwargs)¶
Return smooth (i.e. no-peak) correlation function.
- Parameters
kwargs (dict) – Override interpolation settings of
xi_interpolator.- Returns
interp – 1D or 2D depending on
xi_interpolator.- Return type
CorrelationFunctionInterpolator1D, CorrelationFunctionInterpolator2D
- class cosmoprimo.bao_filter.BasePowerSpectrumBAOFilter(pk_interpolator, cosmo=None, **kwargs)¶
Bases:
cosmoprimo.utils.BaseClassBase BAO filter for power spectrum.
Run BAO filter.
- Parameters
pk_interpolator (PowerSpectrumInterpolator1D, PowerSpectrumInterpolator2D) – Input power spectrum to remove BAO wiggles from.
cosmo (Cosmology, default=None) – Cosmology instance, which may be used to tune filter settings (depending on
rs_drag).kwargs (dict) – Arguments for
set_k().
- property cosmo¶
Cosmology.
- rs_drag_ratio()¶
If
cosmois provided, return the ratio of itsrs_dragto the fiducial one (fromCosmology()), else 1.
- set_k(nk=1024)¶
Set wavenumbers where to evaluate the power spectrum (between
pk_interpolator.extrap_kminandpk_interpolator.extrap_kmax).- Parameters
nk (int, default=1024) – Number of wavenumbers.
- smooth_pk_interpolator(**kwargs)¶
Return smooth (i.e. no-wiggle) power spectrum.
- Parameters
kwargs (dict) – Override interpolation and extrapolation settings of
pk_interpolator.- Returns
interp – 1D or 2D depending on
pk_interpolator.- Return type
- smooth_xi_interpolator(**kwargs)¶
Return smooth (i.e. no-peak) correlation function using
FFTlog.- Parameters
kwargs (dict) – Override interpolation and extrapolation settings of returned correlation function interpolator.
- Returns
interp – 1D or 2D depending on
pk_interpolator.- Return type
CorrelationFunctionInterpolator1D, CorrelationFunctionInterpolator2D
- property wiggles¶
Extracted wiggles.
- cosmoprimo.bao_filter.CorrelationFunctionBAOFilter(xi_interpolator, engine='kirkby2013', **kwargs)¶
Run correlation function BAO filter corresponding to the provided engine.
- class cosmoprimo.bao_filter.EHNoWigglePolyPowerSpectrumBAOFilter(pk_interpolator, kbox=(0.005, 0.5), dampkbox=(0.01, 0.4), dampsigma=10, rescale_kbox=True, cosmo=None, **kwargs)¶
Bases:
cosmoprimo.bao_filter.BasePowerSpectrumBAOFilterRemove BAO wiggles using the Eisenstein & Hu no-wiggle analytic formula, emulated with a 6-th order polynomial.
Run BAO filter.
- Parameters
pk_interpolator (PowerSpectrumInterpolator1D, PowerSpectrumInterpolator2D) – Input power spectrum to remove BAO wiggles from.
kbox (tuple, default=(5e-3, 0.5)) – k-range to fit the Eisenstein & Hu no-wiggle power spectrum to the input one
pk_interpolator.dampkbox (tuple, default=(1e-2, 0.4)) – k-range to interpolate between the Eisenstein & Hu no-wiggle power spectrum and the input one
pk_interpolatorwith an Gaussian damping factor.dampsigma (float, default=10) – Standard deviation of the Gaussian damping factor.
rescale_kbox (bool, default=True) – Whether to rescale
kboxanddampkboxby the ratio ofrs_dragrelative to the fiducial cosmology (may help robustify the procedure for cosmologies far from the fiducial one).cosmo (Cosmology, default=None) – Cosmology instance, used to compute the Eisenstein & Hu no-wiggle power spectrum.
kwargs (dict) – Arguments for
set_k().
- compute()¶
Run filter.
- property cosmo¶
Cosmology.
- rs_drag_ratio()¶
If
cosmois provided, return the ratio of itsrs_dragto the fiducial one (fromCosmology()), else 1.
- set_k(nk=1024)¶
Set wavenumbers where to evaluate the power spectrum (between
pk_interpolator.extrap_kminandpk_interpolator.extrap_kmax).- Parameters
nk (int, default=1024) – Number of wavenumbers.
- smooth_pk_interpolator(**kwargs)¶
Return smooth (i.e. no-wiggle) power spectrum.
- Parameters
kwargs (dict) – Override interpolation and extrapolation settings of
pk_interpolator.- Returns
interp – 1D or 2D depending on
pk_interpolator.- Return type
- smooth_xi_interpolator(**kwargs)¶
Return smooth (i.e. no-peak) correlation function using
FFTlog.- Parameters
kwargs (dict) – Override interpolation and extrapolation settings of returned correlation function interpolator.
- Returns
interp – 1D or 2D depending on
pk_interpolator.- Return type
CorrelationFunctionInterpolator1D, CorrelationFunctionInterpolator2D
- property wiggles¶
Extracted wiggles.
- class cosmoprimo.bao_filter.Hinton2017PowerSpectrumBAOFilter(pk_interpolator, degree=13, sigma=1, weight=0.5, **kwargs)¶
Bases:
cosmoprimo.bao_filter.BasePowerSpectrumBAOFilterPower spectrum BAO filter consisting in fitting a high degree polynomial to the input power spectrum in log-log space.
References
https://github.com/Samreay/Barry/blob/master/barry/cosmology/power_spectrum_smoothing.py
Run BAO filter.
- Parameters
pk_interpolator (PowerSpectrumInterpolator1D, PowerSpectrumInterpolator2D) – Input power spectrum to remove BAO wiggles from.
degree (int, default=13) – Polynomial degree.
sigma (float, default=1) – Standard deviation of the Gaussian kernel that downweights the maximum of the power spectrum relative to the edges.
weight (float, default=0.5) – Normalisation of the Gaussian kernel.
- compute()¶
Run filter.
- property cosmo¶
Cosmology.
- rs_drag_ratio()¶
If
cosmois provided, return the ratio of itsrs_dragto the fiducial one (fromCosmology()), else 1.
- set_k(nk=1024)¶
Set wavenumbers where to evaluate the power spectrum (between
pk_interpolator.extrap_kminandpk_interpolator.extrap_kmax).- Parameters
nk (int, default=1024) – Number of wavenumbers.
- smooth_pk_interpolator(**kwargs)¶
Return smooth (i.e. no-wiggle) power spectrum.
- Parameters
kwargs (dict) – Override interpolation and extrapolation settings of
pk_interpolator.- Returns
interp – 1D or 2D depending on
pk_interpolator.- Return type
- smooth_xi_interpolator(**kwargs)¶
Return smooth (i.e. no-peak) correlation function using
FFTlog.- Parameters
kwargs (dict) – Override interpolation and extrapolation settings of returned correlation function interpolator.
- Returns
interp – 1D or 2D depending on
pk_interpolator.- Return type
CorrelationFunctionInterpolator1D, CorrelationFunctionInterpolator2D
- property wiggles¶
Extracted wiggles.
- class cosmoprimo.bao_filter.Kirkby2013CorrelationFunctionBAOFilter(xi_interpolator, sbox_left=(50.0, 82.0), sbox_right=(150.0, 190.0), rescale_sbox=True, cosmo=None, **kwargs)¶
Bases:
cosmoprimo.bao_filter.BaseCorrelationFunctionBAOFilterFilter BAO peak by cutting the peak and interpolating with 5-order polynomial.
References
https://arxiv.org/abs/1301.3456 https://github.com/igmhub/picca/blob/master/bin/picca_compute_pk_pksb.py
Run BAO filter.
- Parameters
xi_interpolator (CorrelationFunctionInterpolator1D, CorrelationFunctionInterpolator2D) – Input correlation function to remove BAO peak from.
sbox_left (tuple) – s-range to fit the polynomial on the left-hand side of the BAO peak.
sbox_right (tuple) – s-range to fit the polynomial on the right-hand side of the BAO peak.
cosmo (Cosmology) – Cosmology instance, which may be used to tune filter settings (depending on
rs_drag).rescale_sbox (bool) – Whether to rescale
sbox_leftandsbox_rightby the ratio ofrs_dragrelative to the fiducial cosmology (may help robustify the procedure for cosmologies far from the fiducial one).cosmo – Cosmology instance, used to compute the Eisenstein & Hu no-wiggle power spectrum.
kwargs (dict) – Arguments for
set_s().
- compute()¶
Run filter.
- property cosmo¶
Cosmology.
- rs_drag_ratio()¶
If
cosmois provided, return the ratio of itsrs_dragto the fiducial one (fromCosmology()), else 1.
- set_s(ns=1024)¶
Set separations where to evaluate the correlation function (between
xi_interpolator.extrap_sminandxi_interpolator.extrap_smax).- Parameters
ns (int, default=1024) – Number of separations.
- smooth_pk_interpolator(**kwargs)¶
Return smooth (i.e. no-wiggle) power spectrum using
FFTlog.- Parameters
kwargs (dict) – Override interpolation and extrapolation settings of return power spectrum interpolator.
- Returns
interp – 1D or 2D depending on
pk_interpolator.- Return type
- smooth_xi_interpolator(**kwargs)¶
Return smooth (i.e. no-peak) correlation function.
- Parameters
kwargs (dict) – Override interpolation settings of
xi_interpolator.- Returns
interp – 1D or 2D depending on
xi_interpolator.- Return type
CorrelationFunctionInterpolator1D, CorrelationFunctionInterpolator2D
- cosmoprimo.bao_filter.PowerSpectrumBAOFilter(pk_interpolator, engine='wallish2018', **kwargs)¶
Run power spectrum BAO filter corresponding to the provided engine.
- class cosmoprimo.bao_filter.RegisteredCorrelationFunctionBAOFilter(name, bases, class_dict)¶
Bases:
typeMetaclass registering
BaseCorrelationFunctionBAOFilter-derived classes.- mro()¶
Return a type’s method resolution order.
- class cosmoprimo.bao_filter.RegisteredPowerSpectrumBAOFilter(name, bases, class_dict)¶
Bases:
typeMetaclass registering
BasePowerSpectrumBAOFilter-derived classes.- mro()¶
Return a type’s method resolution order.
- class cosmoprimo.bao_filter.SavGolPowerSpectrumBAOFilter(pk_interpolator, cosmo=None, **kwargs)¶
Bases:
cosmoprimo.bao_filter.BasePowerSpectrumBAOFilterBAO smoothing with Savitzky-Golay filter.
References
Taken from https://github.com/sfschen/velocileptors/blob/master/velocileptors/EPT/ept_fullresum_fftw.py
Note
Contrary to the reference, we work in \(\log(k)\) - \(\log(k P(k))\) space.
Run BAO filter.
- Parameters
pk_interpolator (PowerSpectrumInterpolator1D, PowerSpectrumInterpolator2D) – Input power spectrum to remove BAO wiggles from.
cosmo (Cosmology, default=None) – Cosmology instance, which may be used to tune filter settings (depending on
rs_drag).kwargs (dict) – Arguments for
set_k().
- compute()¶
Run filter.
- property cosmo¶
Cosmology.
- rs_drag_ratio()¶
If
cosmois provided, return the ratio of itsrs_dragto the fiducial one (fromCosmology()), else 1.
- set_k(nk=1024)¶
Set wavenumbers where to evaluate the power spectrum (between
pk_interpolator.extrap_kminandpk_interpolator.extrap_kmax).- Parameters
nk (int, default=1024) – Number of wavenumbers.
- smooth_pk_interpolator(**kwargs)¶
Return smooth (i.e. no-wiggle) power spectrum.
- Parameters
kwargs (dict) – Override interpolation and extrapolation settings of
pk_interpolator.- Returns
interp – 1D or 2D depending on
pk_interpolator.- Return type
- smooth_xi_interpolator(**kwargs)¶
Return smooth (i.e. no-peak) correlation function using
FFTlog.- Parameters
kwargs (dict) – Override interpolation and extrapolation settings of returned correlation function interpolator.
- Returns
interp – 1D or 2D depending on
pk_interpolator.- Return type
CorrelationFunctionInterpolator1D, CorrelationFunctionInterpolator2D
- property wiggles¶
Extracted wiggles.
- class cosmoprimo.bao_filter.Wallish2018PowerSpectrumBAOFilter(pk_interpolator, cosmo=None, **kwargs)¶
Bases:
cosmoprimo.bao_filter.BasePowerSpectrumBAOFilterFilter BAO wiggles by sine-transforming the power spectrum to real space (where the BAO is better localised), cutting the peak and interpolating with a spline.
References
https://arxiv.org/pdf/1810.02800.pdf, Appendix D (thanks to Stephen Chen for the reference)
Note
We have hand-tune parameters w.r.t. to the reference.
Run BAO filter.
- Parameters
pk_interpolator (PowerSpectrumInterpolator1D, PowerSpectrumInterpolator2D) – Input power spectrum to remove BAO wiggles from.
cosmo (Cosmology, default=None) – Cosmology instance, which may be used to tune filter settings (depending on
rs_drag).kwargs (dict) – Arguments for
set_k().
- compute()¶
Run filter.
- property cosmo¶
Cosmology.
- rs_drag_ratio()¶
If
cosmois provided, return the ratio of itsrs_dragto the fiducial one (fromCosmology()), else 1.
- set_k(nk=1024)¶
Set wavenumbers where to evaluate the power spectrum (between
pk_interpolator.extrap_kminandpk_interpolator.extrap_kmax).- Parameters
nk (int, default=1024) – Number of wavenumbers.
- smooth_pk_interpolator(**kwargs)¶
Return smooth (i.e. no-wiggle) power spectrum.
- Parameters
kwargs (dict) – Override interpolation and extrapolation settings of
pk_interpolator.- Returns
interp – 1D or 2D depending on
pk_interpolator.- Return type
- smooth_xi_interpolator(**kwargs)¶
Return smooth (i.e. no-peak) correlation function using
FFTlog.- Parameters
kwargs (dict) – Override interpolation and extrapolation settings of returned correlation function interpolator.
- Returns
interp – 1D or 2D depending on
pk_interpolator.- Return type
CorrelationFunctionInterpolator1D, CorrelationFunctionInterpolator2D
- property wiggles¶
Extracted wiggles.
FFTlog¶
Implementation of the FFTlog algorithm, very much inspired by mcfit (https://github.com/eelregit/mcfit) and implementation in https://github.com/sfschen/velocileptors/blob/master/velocileptors/Utils/spherical_bessel_transform_fftw.py
- class cosmoprimo.fftlog.BaseBesselKernel(nu)¶
Bases:
cosmoprimo.fftlog.BaseKernelBase Bessel kernel.
- class cosmoprimo.fftlog.BaseFFTEngine(size, nparallel=1, nthreads=None)¶
Bases:
objectBase FFT engine.
Initialize FFT engine.
- Parameters
size (int) – Array size.
nparallel (int, default=1) – Number of FFTs to be performed in parallel.
nthreads (int, default=None) – Number of threads.
- class cosmoprimo.fftlog.BaseKernel¶
Bases:
objectBase kernel.
- class cosmoprimo.fftlog.BaseTophatKernel(ndim=1)¶
Bases:
cosmoprimo.fftlog.BaseKernelBase tophat kernel.
- class cosmoprimo.fftlog.BesselJKernel(nu)¶
Bases:
cosmoprimo.fftlog.BaseBesselKernel(Mellin transform of) Bessel kernel.
- class cosmoprimo.fftlog.CorrelationToPower(s, ell=0, q=0, complex=False, **kwargs)¶
Bases:
cosmoprimo.fftlog.FFTlogCorrelation function to power spectrum transform, defined as:
\[P_{\ell}(k) = 4 \pi i^{\ell} \int ds s^{2} \xi_{\ell}(s) j_{\ell}(ks)\]Initialize power to correlation transform.
- Parameters
s (array_like) – Input log-spaced separations. If 1D, is broadcast to the number of provided
ell.ell (int, list of int, default=0) – Poles. If a list is provided, will perform all transforms at once.
q (float, list of floats, default=0) – Power-law tilt(s) to regularise integration.
complex (bool, default=False) –
Falsereturns the real part of even poles, and the imaginary part of odd poles.kwargs (dict) – Arguments for
FFTlog.
- inv()¶
Inverse the transform.
- property nparallel¶
Number of transforms performed in parallel.
- set_fft_engine(engine='numpy', **engine_kwargs)¶
Set up FFT engine. See
get_fft_engine()- Parameters
engine (BaseEngine, string, default='numpy') – FFT engine, or one of [‘numpy’, ‘fftw’].
engine_kwargs (dict) – Arguments for FFT engine.
- setup()¶
Set up u funtions.
- class cosmoprimo.fftlog.FFTWEngine(size, nparallel=1, nthreads=None, wisdom=None, plan='measure')¶
Bases:
cosmoprimo.fftlog.BaseFFTEngineFFT engine based on
pyfftw.Initialize
pyfftwengine.- Parameters
size (int) – Array size.
nparallel (int, default=1) – Number of FFTs to be performed in parallel.
nthreads (int, default=None) – Number of threads.
wisdom (string, tuple, default=None) –
pyfftwwisdom, to speed up initialization of FFTs. If a string, should be a path to the save FFT wisdom (withnumpy.save()). If a tuple, directly corresponds to the wisdom.plan (string, default='measure') – Choices are [‘estimate’, ‘measure’, ‘patient’, ‘exhaustive’]. The increasing amount of effort spent during the planning stage to create the fastest possible transform. Usually ‘measure’ is a good compromise.
- backward(fun)¶
Backward transform of
fun.
- forward(fun)¶
Forward transform of
fun.
- class cosmoprimo.fftlog.FFTlog(x, kernel, q=0, minfolds=2, lowring=True, xy=1, check_level=0, engine='numpy', **engine_kwargs)¶
Bases:
objectImplementation of the FFTlog algorithm presented in https://jila.colorado.edu/~ajsh/FFTLog/, which computes the generic integral:
\[G(y) = \int_{0}^{\infty} x dx F(x) K(xy)\]with \(F(x)\) input function, \(K(xy)\) a kernel.
This transform is (mathematically) invariant under a power law transformation:
\[G_{q}(y) = \int_{0}^{\infty} x dx F_{q}(x) K_{q}(xy)\]where \(F_{q}(x) = G(x)x^{-q}\), \(K_{q}(t) = K(t)t^{q}\) and \(G_{q}(y) = G(y)y^{q}\).
Initialize
FFTlog, which can perform several transforms at once.- Parameters
x (array_like) – Input log-spaced coordinates. Must be strictly increasing. If 1D, is broadcast to the number of provided kernels.
kernel (callable, list of callables) – Mellin transform of the kernel: .. math:: U_{K}(z) = int_{0}^{infty} t^{z-1} K(t) dt If a list of kernels is provided, will perform all transforms at once.
q (float, list of floats, default=0) – Power-law tilt(s) to regularise integration.
minfolds (int, default=2) – The c is chosen with minimum \(n\) chosen such that
2**n > minfolds * x.size.lowring (bool, default=True) – If
Trueset output coordinates according to the low-ringing condition, otherwise set it withxy.xy (float, list of floats, default=1) – Enforce the reciprocal product (i.e.
x[0] * y[-1]) of the inputxand outputycoordinates.check_level (int, default=0) – If non-zero run sanity checks on input.
engine (string, default='numpy') – FFT engine. See
set_fft_engine().engine_kwargs (dict) – Arguments for FFT engine.
Note
Kernel definition is different from that of https://jila.colorado.edu/~ajsh/FFTLog/, which uses (eq. 10):
\[U_{K}(z) = \int_{0}^{\infty} t^{z} K(t) dt\]Therefore, one should use \(q = 1\) for Bessel functions to match \(q = 0\) in https://jila.colorado.edu/~ajsh/FFTLog/.
- inv()¶
Inverse the transform.
- property nparallel¶
Number of transforms performed in parallel.
- set_fft_engine(engine='numpy', **engine_kwargs)¶
Set up FFT engine. See
get_fft_engine()- Parameters
engine (BaseEngine, string, default='numpy') – FFT engine, or one of [‘numpy’, ‘fftw’].
engine_kwargs (dict) – Arguments for FFT engine.
- setup()¶
Set up u funtions.
- class cosmoprimo.fftlog.GaussianKernel¶
Bases:
cosmoprimo.fftlog.BaseKernel(Mellin transform of) Gaussian kernel.
- class cosmoprimo.fftlog.GaussianSqKernel¶
Bases:
cosmoprimo.fftlog.BaseKernel(Mellin transform of) square of Gaussian kernel.
- class cosmoprimo.fftlog.GaussianVariance(k, q=0, **kwargs)¶
Bases:
cosmoprimo.fftlog.FFTlogVariance in Gaussian window.
It relies on Gaussian kernel.
Initialize Gaussian variance transform.
- Parameters
k (array_like) – Input log-spaced wavenumbers. If 1D, is broadcast to the number of provided
ell.q (float, list of floats, default=0) – Power-law tilt(s) to regularise integration.
kwargs (dict) – Arguments for
FFTlog.
- inv()¶
Inverse the transform.
- property nparallel¶
Number of transforms performed in parallel.
- set_fft_engine(engine='numpy', **engine_kwargs)¶
Set up FFT engine. See
get_fft_engine()- Parameters
engine (BaseEngine, string, default='numpy') – FFT engine, or one of [‘numpy’, ‘fftw’].
engine_kwargs (dict) – Arguments for FFT engine.
- setup()¶
Set up u funtions.
- class cosmoprimo.fftlog.HankelTransform(x, nu=0, **kwargs)¶
Bases:
cosmoprimo.fftlog.FFTlogHankel transform implementation using
FFTlog.It relies on Bessel function kernels.
Initialize Hankel transform.
- Parameters
x (array_like) – Input log-spaced coordinates. If 1D, is broadcast to the number of provided
nu.nu (int, list of int, default=0) – Order of Bessel functions. If a list is provided, will perform all transforms at once.
kwargs (dict) – Arguments for
FFTlog.
- inv()¶
Inverse the transform.
- property nparallel¶
Number of transforms performed in parallel.
- set_fft_engine(engine='numpy', **engine_kwargs)¶
Set up FFT engine. See
get_fft_engine()- Parameters
engine (BaseEngine, string, default='numpy') – FFT engine, or one of [‘numpy’, ‘fftw’].
engine_kwargs (dict) – Arguments for FFT engine.
- setup()¶
Set up u funtions.
- class cosmoprimo.fftlog.NumpyFFTEngine(size, nparallel=1, nthreads=None)¶
Bases:
cosmoprimo.fftlog.BaseFFTEngineFFT engine based on
numpy.fft.Initialize FFT engine.
- Parameters
size (int) – Array size.
nparallel (int, default=1) – Number of FFTs to be performed in parallel.
nthreads (int, default=None) – Number of threads.
- backward(fun)¶
Backward transform of
fun.
- forward(fun)¶
Forward transform of
fun.
- class cosmoprimo.fftlog.PowerToCorrelation(k, ell=0, q=0, complex=False, **kwargs)¶
Bases:
cosmoprimo.fftlog.FFTlogPower spectrum to correlation function transform, defined as:
\[\xi_{\ell}(s) = \frac{(-i)^{\ell}}{2 \pi^{2}} \int dk k^{2} P_{\ell}(k) j_{\ell}(ks)\]Initialize power to correlation transform.
- Parameters
k (array_like) – Input log-spaced wavenumbers. If 1D, is broadcast to the number of provided
ell.ell (int, list of int, default=0) – Poles. If a list is provided, will perform all transforms at once.
q (float, list of floats, default=0) – Power-law tilt(s) to regularise integration.
complex (bool, default=False) –
Falseassumes the imaginary part of odd power spectrum poles is provided.kwargs (dict) – Arguments for
FFTlog.
- inv()¶
Inverse the transform.
- property nparallel¶
Number of transforms performed in parallel.
- set_fft_engine(engine='numpy', **engine_kwargs)¶
Set up FFT engine. See
get_fft_engine()- Parameters
engine (BaseEngine, string, default='numpy') – FFT engine, or one of [‘numpy’, ‘fftw’].
engine_kwargs (dict) – Arguments for FFT engine.
- setup()¶
Set up u funtions.
- class cosmoprimo.fftlog.SphericalBesselJKernel(nu)¶
Bases:
cosmoprimo.fftlog.BaseBesselKernel(Mellin transform of) spherical Bessel kernel.
- class cosmoprimo.fftlog.TophatKernel(ndim=1)¶
Bases:
cosmoprimo.fftlog.BaseTophatKernel(Mellin transform of) tophat kernel.
- class cosmoprimo.fftlog.TophatSqKernel(ndim=1)¶
Bases:
cosmoprimo.fftlog.BaseTophatKernel(Mellin transform of) square of tophat kernel.
- class cosmoprimo.fftlog.TophatVariance(k, q=0, **kwargs)¶
Bases:
cosmoprimo.fftlog.FFTlogVariance in tophat window.
It relies on tophat kernel.
Initialize tophat variance transform.
- Parameters
k (array_like) – Input log-spaced wavenumbers. If 1D, is broadcast to the number of provided
ell.q (float, list of floats, default=0) – Power-law tilt(s) to regularise integration.
kwargs (dict) – Arguments for
FFTlog.
- inv()¶
Inverse the transform.
- property nparallel¶
Number of transforms performed in parallel.
- set_fft_engine(engine='numpy', **engine_kwargs)¶
Set up FFT engine. See
get_fft_engine()- Parameters
engine (BaseEngine, string, default='numpy') – FFT engine, or one of [‘numpy’, ‘fftw’].
engine_kwargs (dict) – Arguments for FFT engine.
- setup()¶
Set up u funtions.
- cosmoprimo.fftlog.apply_along_last_axes(func, array, naxes=1, toret=None)¶
Apply callable
funcover the lastnaxesofarray.
- cosmoprimo.fftlog.get_fft_engine(engine, *args, **kwargs)¶
Return FFT engine.
- Parameters
engine (BaseFFTEngine, string) – FFT engine, or one of [‘numpy’, ‘fftw’].
args (tuple, dict) – Arguments for FFT engine.
kwargs (tuple, dict) – Arguments for FFT engine.
- Returns
engine
- Return type
- cosmoprimo.fftlog.pad(array, pad_width, axis=- 1, extrap=0)¶
Pad array along
axis.- Parameters
array (array_like) – Input array to be padded.
pad_width (int, tuple of ints) – Number of points to be added on both sides of the array. Pass a tuple to differentiate between left and right sides.
axis (int, default=-1) – Axis along which padding is to be applied.
extrap (string, float, default=0) – If ‘log’, performs a log-log extrapolation. If ‘edge’, pad
arraywith its edge values. Else, padarraywith the provided value. Pass a tuple to differentiate between left and right sides.
- Returns
array – Padded array.
- Return type
array
Interpolators¶
Utilities for power spectrum and correlation function interpolations.
Useful classes are PowerSpectrumInterpolator1D, PowerSpectrumInterpolator2D,
CorrelationFunctionInterpolator1D, CorrelationFunctionInterpolator2D.
- class cosmoprimo.interpolator.CorrelationFunctionInterpolator1D(s, xi, interp_s='log', interp_order_s=3)¶
Bases:
cosmoprimo.interpolator._BaseCorrelationFunctionInterpolator1D correlation funcion interpolator.
Initialize
CorrelationFunctionInterpolator1D.- Parameters
s (array_like) – Seperations.
xi (array_like) – Correlation function to be interpolated.
interp_s (string, default='log') – If ‘log’, interpolation is performed in log-s coordinates.
interp_order_s (int, default=3) – Interpolation order, i.e. degree of smoothing spline along
s.
- as_dict()¶
Return interpolator as a dictionary.
- clone(**kwargs)¶
Clone interpolator, i.e. return a deepcopy with (possibly) other attributes in
kwargs(clone()witout arguments is the same asdeepcopy()).See
deepcopy()doc for warning about interpolators built from callables.
- deepcopy()¶
Deep copy interpolator.
If interpolator
interp1is built from callable, requires its evaluation atk, such that e.g.: >>> interp2 = interp1.clone() will not be provide exactly the same interpolated values asinterp1(due to interpolation errors).
- property extrap_smax¶
Maximum (extrapolated)
svalue (same as maximum interpolated value).
- property extrap_smin¶
Minimum (extrapolated)
svalue (same as minimum interpolated value).
- classmethod from_callable(s=None, xi_callable=None)¶
Build
CorrelationFunctionInterpolator1Dfrom callable.- Parameters
s (array_like, default=None) – Array of separations where the provided
xi_callablecan be trusted. It will be used if:attr:xiis requested. Must be strictly increasing.xi_callable (callable) – Correlation function callable.
- Returns
self
- Return type
- params()¶
Return interpolator parameter dictionary.
- rescale_sigma8(sigma8=1.0)¶
Rescale the correlation function to the provided
sigma8normalisation.
- sigma8(**kwargs)¶
Return the r.m.s. of perturbations in a sphere of 8.
- sigma_d(**kwargs)¶
Return the r.m.s. of the displacement field by transforming correlation function into power spectrum.
See
PowerSpectrumInterpolator1D.sigma_d()arguments.
- sigma_r(r, **kwargs)¶
Return the r.m.s. of perturbations in a sphere of \(r\) by transforming correlation function into power spectrum.
See
PowerSpectrumInterpolator1D.sigma_r()arguments.
- property smax¶
Maximum (interpolated)
kvalue.
- property smin¶
Minimum (interpolated)
svalue.
- to_pk(ns=1024, fftlog_kwargs=None, **kwargs)¶
Transform correlation function into power spectrum using
FFTlog.- nsint, default=1024
Number of separations used in FFTlog transform.
- fftlog_kwargsdict, default=None
Arguments for
FFTlog.- kwargsdict
Arguments for the new
PowerSpectrumInterpolator1Dinstance.
- Returns
pk
- Return type
- property xi¶
Return correlation function array (if interpolator built from callable, evaluate it), with normalisation.
- class cosmoprimo.interpolator.CorrelationFunctionInterpolator2D(s, z=0, xi=None, interp_s='log', interp_order_s=3, interp_order_z=None, extrap_z=None, growth_factor_sq=None)¶
Bases:
cosmoprimo.interpolator._BaseCorrelationFunctionInterpolator2D correlation function interpolator.
Initialize
CorrelationFunctionInterpolator2D.growth_factor_sqis a callable that can be prodided to rescale the output of the base spline interpolation. Indeed, variations of \(z \rightarrow \xi(k,z)\) are (mostly) \(s\) scale independent, such that more accurate interpolation inzcan be achieved by providing the z variations separately in a well-sampledgrowth_factor_sq.- Parameters
s (array_like) – Separations.
z (array_like, float, default=0) – Redshifts.
xi (array_like) – Correlation function to be interpolated. If
zis scalar, should be 1D; else 2D, with shape(s.size, z.size).interp_s (string, default='log') – If ‘log’, interpolation is performed in log-s coordinates.
interp_order_s (int, default=3) – Interpolation order, i.e. degree of smoothing spline along
s.interp_order_z (int, default=None) – Interpolation order, i.e. degree of smoothing spline along
z. IfNone, the maximum order givenzsize (seeGenericSpline.min_spline_order()) is considered.extrap_z (bool, default=None) – If
True, clip out-of-boundszinput coordinates. IfNone, andgrowth_factor_sqis provided, defaults toTrue(hence assuminggrowth_factor_sqwill provide the extrapolation to out-of-boundszinput coordinates).growth_factor_sq (callable, default=None) – Function that takes
zas argument and returns the growth factor squared at that redshift. This will rescale the output of the base spline interpolation. Therefore, make sure that providedpkdoes not contain the redundantzvariations.
- as_dict()¶
Return interpolator as a dictionary.
- clone(**kwargs)¶
Clone interpolator, i.e. return a deepcopy with (possibly) other attributes in
kwargs(clone()witout arguments is the same asdeepcopy()).See
deepcopy()doc for warning about interpolators built from callables.
- deepcopy()¶
Deep copy interpolator.
If interpolator
interp1is built from callable, requires its evaluation atk, such that e.g.: >>> interp2 = interp1.clone() will not be provide exactly the same interpolated values asinterp1(due to interpolation errors).
- property extrap_smax¶
Maximum (extrapolated)
svalue (same as maximum interpolated value).
- property extrap_smin¶
Minimum (extrapolated)
svalue (same as minimum interpolated value).
- classmethod from_callable(s=None, z=None, xi_callable=None, growth_factor_sq=None)¶
Build
CorrelationFunctionInterpolator2Dfrom callable.- Parameters
s (array_like, default=None) – Array of separations where the provided
xi_callablecan be trusted. It will be used if:attr:xiis requested. Must be strictly increasing.z (array_like, default=None) – Array of redshifts where the provided
xi_callablecan be trusted. Same remark as fors.xi_callable (callable, default=None) – Correlation function callable. If
growth_factor_sqis not provided, should takes,z,gridas arguments (see__call__()) else, should takesas arguments.growth_factor_sq (callable, default=None) – See remark above.
- Returns
self
- Return type
- growth_rate_rz(r, z=0, **kwargs)¶
Evaluate the growth rate at the log-derivative of perturbations in a sphere of \(r\) by transforming correlation function into power spectrum.
See
PowerSpectrumInterpolator2D.growth_rate_rz()arguments.
- params()¶
Return interpolator parameter dictionary.
- rescale_sigma8(sigma8=1.0)¶
Rescale correlation function to the provided
sigma8normalisation at \(z = 0\).
- sigma8_z(z=0, **kwargs)¶
Return the r.m.s. of perturbations in a sphere of 8 by transforming correlation function into power spectrum.
See
PowerSpectrumInterpolator2D.sigma8_z()arguments.
- sigma_dz(z=0, **kwargs)¶
Return the r.m.s. of the displacement field by transforming correlation function into power spectrum.
See
PowerSpectrumInterpolator2D.sigma_dz()arguments.
- sigma_rz(r, z=0, **kwargs)¶
Return the r.m.s. of perturbations in a sphere of \(r\) by transforming correlation function into power spectrum.
See
PowerSpectrumInterpolator2D.sigma_rz()arguments.
- property smax¶
Maximum (interpolated)
kvalue.
- property smin¶
Minimum (interpolated)
svalue.
- to_1d(z=0, **kwargs)¶
Return
CorrelationFunctionInterpolator1Dinstance corresponding to interpolator atz.- Parameters
z (float, default=0) – Redshift.
kwargs (dict) – Arguments for the new
CorrelationFunctionInterpolator1Dinstance. By default, the new instance inherits the samesinterpolattion settings.
- Returns
interp
- Return type
- to_pk(ns=1024, fftlog_kwargs=None, **kwargs)¶
Transform correlation function into power spectrum using
FFTlog.- nsint, default=1024
Number of separations used in FFTlog transform.
- fftlog_kwargsdict, default=None
Arguments for
FFTlog.- kwargsdict
Arguments for the new
PowerSpectrumInterpolator2Dinstance.
- Returns
pk
- Return type
- property xi¶
Return
xi(if interpolator built from callable, evaluate it), without growth factor, but with normalisation.
- property zmax¶
Maximum (spline-interpolated) redshift.
- property zmin¶
Minimum (spline-interpolated) redshift.
- class cosmoprimo.interpolator.GenericSpline(x, y=0, fun=None, interp_x='log', extrap_fun='lin', extrap_xmin=1e-06, extrap_xmax=100.0, interp_order_x=3, interp_order_y=None, extrap_y=False)¶
Bases:
cosmoprimo.utils.BaseClassBase class that handles 1D and 2D splines.
Initialize
GenericSpline.- Parameters
x (array_like) – x-coordinates.
y (array_like, float, default=0) – y-coordinates.
fun (array_like, default=None) – Data to be interpolated. If
yis scalar, should be 1D; else 2D, with shape(x.size, y.size).interp_x (string, default='log') – If ‘log’, interpolation is performed in log-x coordinates.
extrap_fun (string, default='lin') – If ‘log’ (and
interp_xis ‘log’),funis log-log extrpolated up toextrap_xmin,extrap_xmax.extrap_xmin (float, default=1e-6) – Minimum extrapolation range in
x.extrap_xmax (float, default=1e2) – Maximum extrapolation range in
y.interp_order_x (int, default=3) – Interpolation order, i.e. degree of smoothing spline along
x.interp_order_y (int, default=None) – Interpolation order, i.e. degree of smoothing spline along
y. IfNone, the maximum order givenysize (seemin_spline_order()) is considered.extrap_y (bool, default=False) – If
True, clip out-of-boundsyinput coordinates in the 2D case.
- static min_spline_order(x)¶
Return maximum spline order given
xsize.
- property xmax¶
Maximum (interpolated)
xcoordinate.
- property xmin¶
Minimum (interpolated)
xcoordinate.
- property ymax¶
Maximum (interpolated)
ycoordinate.
- property ymin¶
Minimum (interpolated)
ycoordinate.
- class cosmoprimo.interpolator.PowerSpectrumInterpolator1D(k, pk, interp_k='log', extrap_pk='log', extrap_kmin=1e-06, extrap_kmax=100.0, interp_order_k=3)¶
Bases:
cosmoprimo.interpolator._BasePowerSpectrumInterpolator1D power spectrum interpolator, broadly adapted from CAMB’s P(k) interpolator by Antony Lewis in https://github.com/cmbant/CAMB/blob/master/camb/results.py, providing extra useful methods, such as
sigma_r()orto_xi().Initialize
PowerSpectrumInterpolator1D.- Parameters
k (array_like) – Wavenumbers.
pk (array_like) – Power spectrum to be interpolated.
interp_k (string, default='log') – If ‘log’, interpolation is performed in log-k coordinates.
extrap_pk (string, default='log') – If ‘log’ (and
interp_kis ‘log’),funis log-log extrapolated up toextrap_kmin,extrap_kmax.extrap_kmin (float, default=1e-6) – Minimum extrapolation range in
k.extrap_kmax (float, default=1e2) – Maximum extrapolation range in
k.interp_order_k (int, default=3) – Interpolation order, i.e. degree of smoothing spline along
k.
- as_dict()¶
Return interpolator as a dictionary.
- clone(**kwargs)¶
Clone interpolator, i.e. return a deepcopy with (possibly) other attributes in
kwargs(clone()witout arguments is the same asdeepcopy()).See
deepcopy()doc for warning about interpolators built from callables.
- deepcopy()¶
Deep copy interpolator.
If interpolator
interp1is built from callable, requires its evaluation atk, such that e.g.: >>> interp2 = interp1.clone() will not be provide exactly the same interpolated values asinterp1(due to interpolation errors).
- classmethod from_callable(k=None, pk_callable=None)¶
Build
PowerSpectrumInterpolator1Dfrom callable.- Parameters
k (array_like, default=None) – Array of wavenumbers where the provided
pk_callablecan be trusted. It will be used ifpkis requested. Must be strictly increasing.pk_callable (callable, default=None) – Power spectrum callable.
- Returns
new
- Return type
- property kmax¶
Maximum (interpolated)
kvalue.
- property kmin¶
Minimum (interpolated)
kvalue.
- params()¶
Return interpolator parameter dictionary.
- property pk¶
Return power spectrum array (if interpolator built from callable, evaluate it), with normalisation.
- rescale_sigma8(sigma8=1.0)¶
Rescale power spectrum to the provided
sigma8normalisation.
- sigma8(**kwargs)¶
Return the r.m.s. of perturbations in a sphere of 8.
- sigma_d(nk=1024, epsrel=1e-05)¶
Return the r.m.s. of the displacement field, i.e. the square root of:
\[\sigma_{d} = \frac{1}{6 \pi^{2}} \int dk P(k)\]- Parameters
nk (int, default=1024) – If not
None, performs trapezoidal integration withnkpoints betweenextrap_kminandextrap_kmax. Else, uses scipy.integrate.quad.epsrel (float, default=1e-5) – Relative precision (for
scipy.integrate.quad()integration).
- Returns
sigmad
- Return type
array_like
- sigma_r(r, nk=1024, epsrel=1e-05)¶
Return the r.m.s. of perturbations in a sphere of \(r\), i.e. the square root of:
\[\sigma_{r} = \frac{1}{2 \pi^{2}} \int dk k^{2} P(k) W^{2}(kr)\]- Parameters
r (array_like) – Sphere radii.
nk (int, default=1024) – If not
None, performs trapezoidal integration withnkpoints betweenextrap_kminandextrap_kmax. Else, uses scipy.integrate.quad.epsrel (float, default=1e-5) – Relative precision (for
scipy.integrate.quad()integration).
- Returns
sigmar – Array of shape
(r.size,)(null dimensions are squeezed).- Return type
array_like
- to_xi(nk=1024, fftlog_kwargs=None, **kwargs)¶
Transform power spectrum into correlation function using
FFTlog.- nkint, default=1024
Number of wavenumbers used in FFTlog transform.
- fftlog_kwargsdict, default=None
Arguments for
FFTlog.- kwargsdict
Arguments for the new
CorrelationFunctionInterpolator1Dinstance.
- Returns
xi
- Return type
- class cosmoprimo.interpolator.PowerSpectrumInterpolator2D(k, z=0, pk=None, interp_k='log', extrap_pk='log', extrap_kmin=1e-06, extrap_kmax=100.0, interp_order_k=3, interp_order_z=None, extrap_z=None, growth_factor_sq=None)¶
Bases:
cosmoprimo.interpolator._BasePowerSpectrumInterpolator2D power spectrum interpolator, broadly adapted from CAMB’s P(k) interpolator by Antony Lewis in https://github.com/cmbant/CAMB/blob/master/camb/results.py, providing extra useful methods, such as
sigma_rz()orto_xi().Initialize
PowerSpectrumInterpolator2D.growth_factor_sqis a callable that can be prodided to rescale the output of the base spline interpolation. Indeed, variations of \(z \rightarrow P(k,z)\) are (mostly) \(k\) scale independent, such that more accurate interpolation inzcan be achieved by providing the z variations separately in a well-sampledgrowth_factor_sq.- Parameters
k (array_like) – Wavenumbers.
z (array_like, float, default=0) – Redshifts.
pk (array_like) – Power spectrum to be interpolated. If
zis scalar, should be 1D; else 2D, with shape(k.size, z.size).interp_k (string, default='log') – If ‘log’, interpolation is performed in log-k coordinates.
extrap_pk (string, default='log') – If ‘log’ (and
interp_kis ‘log’),funis log-log extrpolated up toextrap_kmin,extrap_kmax.extrap_kmin (float, default=1e-6) – Minimum extrapolation range in
k.extrap_kmax (float, default=1e2) – Maximum extrapolation range in
k.interp_order_k (int, default=3) – Interpolation order, i.e. degree of smoothing spline along
k.interp_order_z (int, default=None) – Interpolation order, i.e. degree of smoothing spline along
z. IfNone, the maximum order givenzsize (seeGenericSpline.min_spline_order()) is considered.extrap_z (bool, default=None) – If
True, clip out-of-boundszinput coordinates. IfNone, andgrowth_factor_sqis provided, defaults toTrue(hence assuminggrowth_factor_sqwill provide the extrapolation to out-of-boundszinput coordinates).growth_factor_sq (callable, default=None) – Function that takes
zas argument and returns the growth factor squared at that redshift. This will rescale the output of the base spline interpolation. Therefore, make sure that providedpkdoes not contain the redundantzvariations.
- as_dict()¶
Return interpolator as a dictionary.
- clone(**kwargs)¶
Clone interpolator, i.e. return a deepcopy with (possibly) other attributes in
kwargs(clone()witout arguments is the same asdeepcopy()).See
deepcopy()doc for warning about interpolators built from callables.
- deepcopy()¶
Deep copy interpolator.
If interpolator
interp1is built from callable, requires its evaluation atk, such that e.g.: >>> interp2 = interp1.clone() will not be provide exactly the same interpolated values asinterp1(due to interpolation errors).
- classmethod from_callable(k=None, z=None, pk_callable=None, growth_factor_sq=None)¶
Build
PowerSpectrumInterpolator2Dfrom callable.- Parameters
k (array_like, default=None) – Array of wavenumbers where the provided
pk_callablecan be trusted. It will be used ifpkis requested. Must be strictly increasing.z (array_like, default=None) – Array of redshifts where the provided
pk_callablecan be trusted. Same remark as fork.pk_callable (callable, default=None) – Power spectrum callable. If
growth_factor_sqis not provided, should takek,z,gridas arguments (see__call__()) else, should takekas arguments.growth_factor_sq (callable, default=None) – Function that takes
zas argument and returns the growth factor squared at that redshift. See remark above.
- Returns
self
- Return type
- growth_rate_rz(r, z=0, dz=0.001, nk=1024, epsrel=1e-05)¶
Evaluate the growth rate at the log-derivative of perturbations in a sphere of \(r\), i.e.:
With \(z = ln(a)\).
- Parameters
r (array_like) – Sphere radii.
z (array_like, default=0) – Redshifts.
dz (float, default=1e-3) –
zinterval used for finite differentiation.nk (int, default=1024) – If not
None, performs trapezoidal integration withnkpoints betweenextrap_kminandextrap_kmax. Else, uses scipy.integrate.quad.epsrel (float, default=1e-5) – Relative precision (for
scipy.integrate.quad()integration).
- property kmax¶
Maximum (interpolated)
kvalue.
- property kmin¶
Minimum (interpolated)
kvalue.
- params()¶
Return interpolator parameter dictionary.
- property pk¶
Return power spectrum array (if interpolator built from callable, evaluate it), without growth factor, but with normalisation.
- rescale_sigma8(sigma8=1.0)¶
Rescale power spectrum to the provided
sigma8normalisation at \(z = 0\).
- sigma8_z(z=0, **kwargs)¶
Return the r.m.s. of perturbations in a sphere of 8.
- sigma_dz(z=0, nk=1024, epsrel=1e-05)¶
Return the r.m.s. of the displacement field, i.e. the square root of:
\[\sigma_{d}(z) = \frac{1}{6 \pi^{2}} \int dk P(k,z)\]- Parameters
z (array_like, default=0) – Redshifts.
nk (int, default=1024) – If not
None, performs trapezoidal integration withnkpoints betweenextrap_kminandextrap_kmax. Else, uses scipy.integrate.quad.epsrel (float, default=1e-5) – Relative precision (for
scipy.integrate.quad()integration).
- Returns
sigmadz
- Return type
array_like
- sigma_rz(r, z=0, nk=1024, epsrel=1e-05)¶
Return the r.m.s. of perturbations in a sphere of \(r\), i.e. the square root of:
\[\sigma_{r}(z) = \frac{1}{2 \pi^{2}} \int dk k^{2} P(k,z) W^{2}(kr)\]- Parameters
r (array_like) – Sphere radii.
z (array_like, default=0) – Redshifts.
nk (int, default=1024) – If not
None, performs trapezoidal integration withnkpoints betweenextrap_kminandextrap_kmax. Else, uses scipy.integrate.quad.epsrel (float, default=1e-5) – Relative precision (for
scipy.integrate.quad()integration).
- Returns
sigmarz – Array of shape
(r.size, z.size)(null dimensions are squeezed).- Return type
array_like
- to_1d(z=0, **kwargs)¶
Return
PowerSpectrumInterpolator1Dinstance corresponding to interpolator atz.- Parameters
z (float, default=0) – Redshift.
kwargs (dict) – Arguments for the new
PowerSpectrumInterpolator1Dinstance. By default, the new instance inherits the samekinterpolattion and extrapolation settings.
- Returns
interp
- Return type
- to_xi(nk=1024, fftlog_kwargs=None, **kwargs)¶
Transform power spectrum into correlation function using
FFTlog.- nkint, default=1024
Number of wavenumbers used in FFTlog transform.
- fftlog_kwargsdict, default=None
Arguments for
FFTlog.- kwargsdict
Arguments for the new
CorrelationFunctionInterpolator2Dinstance.
- Returns
xi
- Return type
- property zmax¶
Maximum (spline-interpolated) redshift.
- property zmin¶
Minimum (spline-interpolated) redshift.
- cosmoprimo.interpolator.wtophat_scalar(x)¶
Non vectorized tophat function.