Broad Overview of onepower#

In this tutorial/demo, we provide a broad overview of the way onepower works, and its features. This tutorial will go into a little more depth (without exploring more advanced niche features).

The Package Layout#

onepower is quite modular, and contains a number of sub-packages concerning each of the (optional) components that go into defining the resulting power spectra:

[1]:
from onepower import (
    hmi,      # Interacts with hod and halomod and sets the cosmology
    hod,      # Defines the HODs and returns them to the main class, calculates the observable functions as well (SMF/LF)
    bnl,      # Returns the non-linear halo bias function calculated from Dark Quest emulator
    ia,       # Returns the IA amplitudes for 1h and 2h terms and the fourier transform of the intrinsic alingment profile
    pk        # Defines routines that combine the above to obtain the resulting power spectra
)

While each of these modules has tools that can be useful for more advanced usage, the primary point of contact with onepower is the Spectra object, which essentially contains all the working of the full package. This lives in the pk submodule, but can be imported from the top level:

[2]:
from onepower import Spectra

Frameworks – Caching and Updating#

Each main entrypoint class in onepower (this includes HaloModelIngredients, NonLinearHaloBias, HOD, …) is what we call a Framework. This functionality is borrowed from the hmf and halomod directly by calling the relevant function from those packages. What this allows us is to have each of these objects to offer a number of similar points of functionality. Here, we’ll demonstrate a few of these bits of functionality on the HaloModelIngredients class, but it should be remembered that they are the same for all of these.

[3]:
from onepower import HaloModelIngredients
[4]:
hod = HaloModelIngredients()

The first common point is that each of the frameworks has defaults for all of its parameters, and a reasonable object can be created by passing no parameters, as we just did.

We can, like any object in Python, get some help with what parameters are available by using help:

[5]:
help(HaloModelIngredients)
Help on class HaloModelIngredients in module onepower.hmi:

class HaloModelIngredients(CosmologyBase)
 |  HaloModelIngredients(*args, **kwargs)
 |
 |  A class to compute various ingredients for the halo model.
 |  This includes halo mass functions, bias models, halo profiles, and concentration models.
 |  Based on the hmf and halomod packages.
 |
 |  Parameters:
 |  -----------
 |  k_vec : array_like, optional
 |      Array of wavenumbers.
 |  z_vec : array_like, optional
 |      Array of redshifts.
 |  lnk_min : float, optional
 |      Minimum natural log of wavenumber (for hmf).
 |  lnk_max : float, optional
 |      Maximum natural log of wavenumber (for hmf).
 |  dlnk : float, optional
 |      Spacing in natural log of wavenumber (for hmf).
 |  Mmin : float, optional
 |      Minimum halo mass (for hmf).
 |  Mmax : float, optional
 |      Maximum halo mass (for hmf).
 |  dlog10m : float, optional
 |      Spacing in log10 of halo mass (for hmf).
 |  mdef_model : str, optional
 |      Mass definition model (for hmf).
 |  hmf_model : str, optional
 |      Halo mass function model (for hmf).
 |  bias_model : str, optional
 |      Halo bias model (for halomod).
 |  halo_profile_model_dm : str, optional
 |      Halo profile model for dark matter / central galaxies (for halomod).
 |  halo_profile_model_sat : str, optional
 |      Halo profile model for satellite galaxies (for halomod).
 |  halo_concentration_model_dm : str, optional
 |      Halo concentration model for dark matter / central galaxies (for halomod).
 |  halo_concentration_model_sat : str, optional
 |      Halo concentration model for satellite galaxies (for halomod).
 |  transfer_model : str, optional
 |      Transfer function model (for hmf).
 |  transfer_params : dict, optional
 |      Parameters for the transfer function (for hmf).
 |  growth_model : str, optional
 |      Growth function model (for hmf).
 |  growth_params : dict, optional
 |      Parameters for the growth function (for hmf).
 |  norm_cen : float, optional
 |      Normalization of c(M) relation for central galaxies.
 |  norm_sat : float, optional
 |      Normalization of c(M) relation for satellite galaxies.
 |  eta_cen : float, optional
 |      Bloating parameter for central galaxies.
 |  eta_sat : float, optional
 |      Bloating parameter for satellite galaxies.
 |  overdensity : float, optional
 |      Overdensity parameter.
 |  delta_c : float, optional
 |      Critical density threshold for collapse.
 |  mead_correction : str, optional
 |      Correction model from Mead et al.
 |
 |  Method resolution order:
 |      HaloModelIngredients
 |      CosmologyBase
 |      hmf._internals._framework.Framework
 |      builtins.object
 |
 |  Methods defined here:
 |
 |  Tk_cold_ratio(self, k, g, ommh2, h, f_nu, N_nu, T_CMB=2.7255)
 |      Ratio of cold to matter transfer function from Eisenstein & Hu (1999).
 |      This can be used to get the cold-matter spectrum approximately from the matter spectrum.
 |      Captures the scale-dependent growth with neutrino free-streaming scale.
 |
 |      Parameters:
 |      -----------
 |      k : float
 |          Wavenumber.
 |      g : float
 |          Growth factor.
 |      ommh2 : float
 |          Omega_m * h^2.
 |      h : float
 |          Hubble parameter.
 |      f_nu : float
 |          Fraction of neutrino density.
 |      N_nu : float
 |          Number of neutrino species.
 |      T_CMB : float, optional
 |          Temperature of the CMB.
 |
 |      Returns:
 |      --------
 |      float
 |          Ratio of cold to matter transfer function.
 |
 |  __init__(self, k_vec=array([1.00000000e-04, 1.20450354e-04, 1.45082878e-04, 1.74752840e-04,
 |         2.10490414e-04, 2.53536449e-04, 3.05385551e-04, 3.67837977e-04,
 |         4.43062146e-04, 5.33669923e-04, 6.42807312e-04, 7.74263683e-04,
 |         9.32603347e-04, 1.12332403e-03, 1.35304777e-03, 1.62975083e-03,
 |         1.96304065e-03, 2.36448941e-03, 2.84803587e-03, 3.43046929e-03,
 |         4.13201240e-03, 4.97702356e-03, 5.99484250e-03, 7.22080902e-03,
 |         8.69749003e-03, 1.04761575e-02, 1.26185688e-02, 1.51991108e-02,
 |         1.83073828e-02, 2.20513074e-02, 2.65608778e-02, 3.19926714e-02,
 |         3.85352859e-02, 4.64158883e-02, 5.59081018e-02, 6.73415066e-02,
 |         8.11130831e-02, 9.77009957e-02, 1.17681195e-01, 1.41747416e-01,
 |         1.70735265e-01, 2.05651231e-01, 2.47707636e-01, 2.98364724e-01,
 |         3.59381366e-01, 4.32876128e-01, 5.21400829e-01, 6.28029144e-01,
 |         7.56463328e-01, 9.11162756e-01, 1.09749877e+00, 1.32194115e+00,
 |         1.59228279e+00, 1.91791026e+00, 2.31012970e+00, 2.78255940e+00,
 |         3.35160265e+00, 4.03701726e+00, 4.86260158e+00, 5.85702082e+00,
 |         7.05480231e+00, 8.49753436e+00, 1.02353102e+01, 1.23284674e+01,
 |         1.48496826e+01, 1.78864953e+01, 2.15443469e+01, 2.59502421e+01,
 |         3.12571585e+01, 3.76493581e+01, 4.53487851e+01, 5.46227722e+01,
 |         6.57933225e+01, 7.92482898e+01, 9.54548457e+01, 1.14975700e+02,
 |         1.38488637e+02, 1.66810054e+02, 2.00923300e+02, 2.42012826e+02,
 |         2.91505306e+02, 3.51119173e+02, 4.22924287e+02, 5.09413801e+02,
 |         6.13590727e+02, 7.39072203e+02, 8.90215085e+02, 1.07226722e+03,
 |         1.29154967e+03, 1.55567614e+03, 1.87381742e+03, 2.25701972e+03,
 |         2.71858824e+03, 3.27454916e+03, 3.94420606e+03, 4.75081016e+03,
 |         5.72236766e+03, 6.89261210e+03, 8.30217568e+03, 1.00000000e+04]), z_vec=array([0.        , 0.21428571, 0.42857143, 0.64285714, 0.85714286,
 |         1.07142857, 1.28571429, 1.5       , 1.71428571, 1.92857143,
 |         2.14285714, 2.35714286, 2.57142857, 2.78571429, 3.        ]), lnk_min=-9.210340371976182, lnk_max=9.210340371976184, dlnk=0.18420680743952367, Mmin=9.0, Mmax=16.0, dlog10m=0.05, mdef_model='SOMean', hmf_model='Tinker10', bias_model='Tinker10', halo_profile_model_dm='NFW', halo_concentration_model_dm='Duffy08', halo_profile_model_sat='NFW', halo_concentration_model_sat='Duffy08', transfer_model='CAMB', transfer_params: dict | None = {}, growth_model='CambGrowth', growth_params: dict | None = {}, norm_cen=1.0, norm_sat=1.0, eta_cen=0.0, eta_sat=0.0, overdensity=200, delta_c=1.686, mead_correction: str | None = None, **cosmology_kwargs)
 |      Initialize self.  See help(type(self)) for accurate signature.
 |
 |  get_halo_collapse_redshifts(self, M, z, dc, g, cosmo, mf)
 |      Calculate halo collapse redshifts according to the Bullock et al. (2001) prescription.
 |
 |      Parameters:
 |      -----------
 |      M : array_like
 |          Halo mass.
 |      z : float
 |          Redshift.
 |      dc : float
 |          Critical density threshold for collapse.
 |      g : float
 |          Growth factor.
 |      cosmo : astropy cosmology model
 |          Cosmology model.
 |      mf : hmf Mass function object
 |          Mass function object.
 |
 |      Returns:
 |      --------
 |      array_like
 |          Collapse redshifts for halos.
 |
 |  sigmaR_cc(self, power, k, r)
 |      Calculate the variance of the cold matter density field smoothed on scale R.
 |
 |      Parameters:
 |      -----------
 |      power : array_like
 |          Power spectrum.
 |      k : array_like
 |          Wavenumber.
 |      r : float
 |          Scale.
 |
 |      Returns:
 |      --------
 |      float
 |          Variance of the density field.
 |
 |  ----------------------------------------------------------------------
 |  Readonly properties defined here:
 |
 |  K
 |      Sets the c(M) normalisations to the one used in HMCode.
 |      Overrides the default passed value in this case.
 |
 |      Returns:
 |      --------
 |      array_like
 |          normalisation of the Bullock 2001 c(M) relation, if mead_corrections is True
 |
 |  conc_cen
 |      Return the concentration for matter/central galaxies.
 |
 |      Returns:
 |      --------
 |      ndarray
 |          concentration for matter/central galaxies
 |
 |  conc_sat
 |      Return the concentration for satellite galaxies.
 |
 |      Returns:
 |      --------
 |      ndarray
 |          concenctration for satellite galaxies
 |
 |  disable_mass_conversion
 |      Dissables the mass conversion for the mass definitions defined in HMCode.
 |
 |      Returns:
 |      --------
 |      bool
 |
 |  dndlnm
 |      Return the differential mass function.
 |
 |      Returns:
 |      --------
 |      ndarray
 |          dndlnm
 |
 |  fnu
 |      Return the neutrino density fraction.
 |
 |      Returns:
 |      --------
 |      array_like
 |          neutrino density fraction
 |
 |  growth_factor
 |      Return the growth factor.
 |
 |      Returns:
 |      --------
 |      array_like
 |          growth factor at z
 |
 |  halo_bias
 |      Return the halo bias.
 |
 |      Returns:
 |      --------
 |      ndarray
 |          halo bias function
 |
 |  halo_overdensity_mean
 |      Return the mean halo overdensity.
 |
 |      Returns:
 |      --------
 |      ndarray
 |          meah halo overdensity
 |
 |  halo_profile_params
 |      Packs the cosmology to a dictionary to be passed to the hmf.
 |      Can in principle have more parameters that need to be passed to hmf that are not explicitly set.
 |
 |      Returns:
 |      --------
 |      dict
 |          astropy cosmology object for hmf package
 |
 |  kh
 |      Return the k vector defined using lnk in hmf.
 |
 |      Returns:
 |      --------
 |      array_like
 |          k vector from hmf
 |
 |  mass
 |      Return the masses.
 |
 |      Returns:
 |      --------
 |      ndarray
 |          halo masses
 |
 |  mdef_params
 |      Sets the overdensity parameter to the one used in HMCode or to the one for virial collapse.
 |      Overrides the default passed value in those two cases.
 |
 |      Returns:
 |      --------
 |      array_like
 |          array of mass mass definition dictionaries, one for each redshift
 |
 |  mean_density0
 |      Return the mean density at redshift zero.
 |
 |      Returns:
 |      --------
 |      array_like
 |          mean density at z=0
 |
 |  mean_density_z
 |      Return the mean density at the given redshifts.
 |
 |      Returns:
 |      --------
 |      array_like
 |          mean density at z
 |
 |  neff
 |      Return the effective spectral index.
 |
 |      Returns:
 |      --------
 |      array_like
 |          effective spectral index
 |
 |  nfw_cen
 |      Return the density profile for matter/central galaxies.
 |
 |      Returns:
 |      --------
 |      ndarray
 |          density profile for matter/central galaxies.
 |
 |  nfw_sat
 |      Return the density profile for satellite galaxies.
 |
 |      Returns:
 |      --------
 |      ndarray
 |          density profile for satellite galaxies
 |
 |  nonlinear_power
 |      Return the non-linear power spectrum at z (if options passed).
 |
 |      Returns:
 |      --------
 |      ndarray
 |          non-linear power spectrum at z
 |
 |  nu
 |      Return the peak height parameter.
 |
 |      Returns:
 |      --------
 |      ndarray
 |          peak heights
 |
 |  power
 |      Return the linear power spectrum at z.
 |
 |      Returns:
 |      --------
 |      ndarray
 |          linear power spectrum at z
 |
 |  r_s_cen
 |      Return the scale radius for matter/central galaxies.
 |
 |      Returns:
 |      --------
 |      ndarray
 |          scale radius for matter/central galaxies
 |
 |  r_s_sat
 |      Return the scale radius for satellite galaxies.
 |
 |      Returns:
 |      --------
 |      ndarray
 |          scale radius for satellite galaxies
 |
 |  rho_halo
 |      Return the halo density.
 |
 |      Returns:
 |      --------
 |      array_like
 |          halo density at z
 |
 |  rvir_cen
 |      Return the virial radius for matter/central galaxies.
 |
 |      Returns:
 |      --------
 |      ndarray
 |          virial radius for matter/central galaxies
 |
 |  rvir_sat
 |      Return the virial radius for satellite galaxies.
 |
 |      Returns:
 |      --------
 |      ndarray
 |          virial radius for satellite galaxies
 |
 |  scale_factor
 |      Return the scale factor.
 |
 |      Returns:
 |      --------
 |      array_like
 |          scale factor array
 |
 |  sigma8_z
 |      Return the amplitude of matter fluctuations on 8 Mpc scales at the given redshifts.
 |
 |      Returns:
 |      --------
 |      array_like
 |          sigma8(z)
 |
 |  u_dm
 |      Return the normalized density profile for dark matter.
 |
 |      Returns:
 |      --------
 |      ndarray
 |          normalised density profile for matter/central galaxies.
 |
 |  u_sat
 |      Return the normalized density profile for satellite galaxies.
 |
 |      Returns:
 |      --------
 |      ndarray
 |          normalised density profile for satellite galaxies
 |
 |  ----------------------------------------------------------------------
 |  Data descriptors defined here:
 |
 |  Mmax
 |      **Parameter**: Maximum halo mass (for hmf).
 |
 |      :type: float
 |
 |  Mmin
 |      **Parameter**: Minimum halo mass (for hmf).
 |
 |      :type: float
 |
 |  bias_model
 |      **Parameter**: Halo bias model (for halomod).
 |
 |      :type: str
 |
 |  delta_c
 |      **Parameter**: Critical density threshold for collapse :math:`\delta_c`.
 |
 |      :type: float
 |
 |  dlnk
 |      **Parameter**: Spacing in natural log of wavenumber (for hmf).
 |
 |      :type: float
 |
 |  dlog10m
 |      **Parameter**: Spacing in log10 of halo mass (for hmf).
 |
 |      :type: float
 |
 |  eta_cen
 |      **Parameter**: Bloating parameter for central galaxies.
 |
 |      :type: float
 |
 |  eta_sat
 |      **Parameter**: eta_sat : float
 |      Bloating parameter for satellite galaxies.
 |
 |  growth_model
 |      **Parameter**: Growth function model (for hmf).
 |
 |      :type: str
 |
 |  growth_params
 |      **Parameter**: Parameters for the growth function (for hmf).
 |
 |      :type: dict
 |
 |  halo_concentration_model_dm
 |      **Parameter**: Halo concentration model of dark matter / central galaxies (for halomod).
 |
 |      :type: str
 |
 |  halo_concentration_model_sat
 |      **Parameter**: Halo concentration model of satellite galaxies (for halomod).
 |
 |      :type: str
 |
 |  halo_profile_model_dm
 |      **Parameter**: Halo profile model of dark matter / central galaxies (for halomod).
 |
 |      :type: str
 |
 |  halo_profile_model_sat
 |      **Parameter**: Halo profile model of satellite galaxies (for halomod).
 |
 |      :type: str
 |
 |  hmf_model
 |      **Parameter**: Halo mass function model (for hmf).
 |
 |      :type: str
 |
 |  k_vec
 |      **Parameter**: Array of wavenumbers.
 |
 |      :type: array_like
 |
 |  lnk_max
 |      **Parameter**: Maximum natural log of wavenumber (for hmf).
 |
 |      :type: float
 |
 |  lnk_min
 |      **Parameter**: Minimum natural log of wavenumber (for hmf).
 |
 |      :type: float
 |
 |  mdef_model
 |      **Parameter**: Mass definition model (for hmf).
 |
 |      :type: str
 |
 |  mead_correction
 |      **Parameter**: Correction model from Mead et al.
 |
 |      :type: str
 |
 |  norm_cen
 |      **Parameter**: Normalization of c(M) relation for central galaxies.
 |
 |      :type: float
 |
 |  norm_sat
 |      **Parameter**: Normalization of c(M) relation for satellite galaxies.
 |
 |      :type: float
 |
 |  overdensity
 |      **Parameter**: Overdensity parameter.
 |
 |      :type: float
 |
 |  transfer_model
 |      **Parameter**: Transfer function model (for hmf).
 |
 |      :type: str
 |
 |  transfer_params
 |      **Parameter**: Parameters for the transfer function (for hmf).
 |
 |      :type: dict
 |
 |  z_vec
 |      **Parameter**: Array of redshifts.
 |
 |      :type: array_like
 |
 |  ----------------------------------------------------------------------
 |  Methods inherited from CosmologyBase:
 |
 |  f_Mead(self, x, y, p0, p1, p2, p3)
 |      Fitting function from Mead et al. 2021 (2009.01858), eq A3,
 |      used in :math:`\delta_c` and :math:`\Delta_{\rm v}` calculations.
 |
 |      Parameters:
 |      -----------
 |      x : float
 |          First variable.
 |      y : float
 |          Second variable.
 |      p0, p1, p2, p3 : float
 |          Fitting parameters.
 |
 |      Returns:
 |      --------
 |      float
 |          Value of the fitting function.
 |
 |  ----------------------------------------------------------------------
 |  Readonly properties inherited from CosmologyBase:
 |
 |  Dv_Mead
 |      Overdensity :math:`\Delta_{\rm v}` fitting function from Mead et al. 2021 (2009.01858), eq A.2.
 |      All input parameters should be evaluated as functions of a/z.
 |
 |      Returns:
 |      --------
 |      array_like
 |          Overdensities at given redshifs
 |
 |  cosmo_model
 |      Return the astropy cosmology object assuming Flatw0waCDM model.
 |
 |      Returns:
 |      --------
 |      object
 |          astropy cosmology object
 |
 |  dc_Mead
 |      The critical overdensity for collapse :math:`\delta_c`
 |      fitting function from Mead et al. 2021 (2009.01858).
 |      All input parameters should be evaluated as functions of a/z.
 |
 |      Returns:
 |      --------
 |      array_like
 |          Delta_c at redshifrs z
 |
 |  get_mead_accumulated_growth
 |      Calculates the accumulated growth at scale factor 'a'.
 |
 |      Returns:
 |      --------
 |      array_like
 |          accumulated growth at scale factor 'a'
 |
 |  get_mead_growth
 |      Return the Mead growth factor at the scale factors.
 |
 |      Returns:
 |      --------
 |      array_like
 |          Mead 2020 growth factor as a function of scale factor 'a'
 |
 |  get_mead_growth_fnc
 |      Solve the linear growth ODE and returns an interpolating function for the solution.
 |      TODO: w dependence for initial conditions; f here is correct for w=0 only.
 |      TODO: Could use d_init = a(1+(w-1)/(w(6w-5))*(Om_w/Om_m)*a**-3w) at early times with w = w(a<<1).
 |
 |      Returns:
 |      --------
 |      object
 |          interpolating function g(a)
 |
 |  ----------------------------------------------------------------------
 |  Data descriptors inherited from CosmologyBase:
 |
 |  h0
 |      **Parameter**: Hubble parameter (small h).
 |
 |      :type: float
 |
 |  log10T_AGN
 |      **Parameter**: Log10 of AGN temperature.
 |
 |      :type: float
 |
 |  m_nu
 |      **Parameter**: Neutrino mass.
 |
 |      :type: float
 |
 |  n_s
 |      **Parameter**: Spectral index.
 |
 |      :type: float
 |
 |  omega_b
 |      **Parameter**: Baryon density parameter.
 |
 |      :type: float
 |
 |  omega_c
 |      **Parameter**: Cold dark matter density parameter.
 |
 |      :type: float
 |
 |  omega_m
 |      **Parameter**: Matter density parameter.
 |
 |      :type: float
 |
 |  sigma_8
 |      **Parameter**: Amplitude of matter fluctuations on 8 Mpc scales.
 |
 |      :type: float
 |
 |  tcmb
 |      **Parameter**: Temperature of the CMB.
 |
 |      :type: float
 |
 |  w0
 |      **Parameter**: Dark energy equation of state parameter.
 |
 |      :type: float
 |
 |  wa
 |      **Parameter**: Dark energy equation of state parameter.
 |
 |      :type: float
 |
 |  ----------------------------------------------------------------------
 |  Methods inherited from hmf._internals._framework.Framework:
 |
 |  clone(self, **kwargs)
 |      Create and return an updated clone of the current object.
 |
 |  get_dependencies(self, *q)
 |      Determine all parameter dependencies of the quantities in q.
 |
 |      Parameters
 |      ----------
 |      q : str
 |          String(s) labelling a quantity
 |
 |      Returns
 |      -------
 |      deps : set
 |          A set containing all parameters on which quantities in q are dependent.
 |
 |  update(self, **kwargs)
 |      Update parameters of the framework with kwargs.
 |
 |  validate(self)
 |      Perform validation of the input parameters as they relate to each other.
 |
 |  ----------------------------------------------------------------------
 |  Class methods inherited from hmf._internals._framework.Framework:
 |
 |  get_all_parameter_defaults(recursive=True) from hmf._internals._framework._Validator
 |      Dictionary of all parameters and defaults.
 |
 |  get_all_parameter_names() from hmf._internals._framework._Validator
 |      Yield all parameter names in the class.
 |
 |  parameter_info(names=None) from hmf._internals._framework._Validator
 |      Prints information about each parameter in the class.
 |
 |      Optionally, restrict printed parameters to those found in the list of names
 |      provided.
 |
 |  quantities_available() from hmf._internals._framework._Validator
 |      Obtain a list of all available output quantities.
 |
 |  ----------------------------------------------------------------------
 |  Readonly properties inherited from hmf._internals._framework.Framework:
 |
 |  parameter_values
 |      Dictionary of all parameters and their current values
 |
 |  ----------------------------------------------------------------------
 |  Data descriptors inherited from hmf._internals._framework.Framework:
 |
 |  __dict__
 |      dictionary for instance variables (if defined)
 |
 |  __weakref__
 |      list of weak references to the object (if defined)

That’s a lot of help! You can also consult the API documentation. However, since many of the parameters to HaloModelIngredients merely get passed through to CosmologyBase and to the hmf / halomod, they get lost in this documentation. You can get a list of all possible parameters for a framework like this:

[6]:
HaloModelIngredients.get_all_parameter_defaults(recursive=False)
[6]:
{'h0': 0.7,
 'omega_c': 0.25,
 'omega_b': 0.05,
 'omega_m': 0.3,
 'w0': -1.0,
 'wa': 0.0,
 'n_s': 0.9,
 'tcmb': 2.7255,
 'm_nu': 0.06,
 'sigma_8': 0.8,
 'log10T_AGN': 7.8,
 'mead_correction': None,
 'k_vec': array([1.00000000e-04, 1.20450354e-04, 1.45082878e-04, 1.74752840e-04,
        2.10490414e-04, 2.53536449e-04, 3.05385551e-04, 3.67837977e-04,
        4.43062146e-04, 5.33669923e-04, 6.42807312e-04, 7.74263683e-04,
        9.32603347e-04, 1.12332403e-03, 1.35304777e-03, 1.62975083e-03,
        1.96304065e-03, 2.36448941e-03, 2.84803587e-03, 3.43046929e-03,
        4.13201240e-03, 4.97702356e-03, 5.99484250e-03, 7.22080902e-03,
        8.69749003e-03, 1.04761575e-02, 1.26185688e-02, 1.51991108e-02,
        1.83073828e-02, 2.20513074e-02, 2.65608778e-02, 3.19926714e-02,
        3.85352859e-02, 4.64158883e-02, 5.59081018e-02, 6.73415066e-02,
        8.11130831e-02, 9.77009957e-02, 1.17681195e-01, 1.41747416e-01,
        1.70735265e-01, 2.05651231e-01, 2.47707636e-01, 2.98364724e-01,
        3.59381366e-01, 4.32876128e-01, 5.21400829e-01, 6.28029144e-01,
        7.56463328e-01, 9.11162756e-01, 1.09749877e+00, 1.32194115e+00,
        1.59228279e+00, 1.91791026e+00, 2.31012970e+00, 2.78255940e+00,
        3.35160265e+00, 4.03701726e+00, 4.86260158e+00, 5.85702082e+00,
        7.05480231e+00, 8.49753436e+00, 1.02353102e+01, 1.23284674e+01,
        1.48496826e+01, 1.78864953e+01, 2.15443469e+01, 2.59502421e+01,
        3.12571585e+01, 3.76493581e+01, 4.53487851e+01, 5.46227722e+01,
        6.57933225e+01, 7.92482898e+01, 9.54548457e+01, 1.14975700e+02,
        1.38488637e+02, 1.66810054e+02, 2.00923300e+02, 2.42012826e+02,
        2.91505306e+02, 3.51119173e+02, 4.22924287e+02, 5.09413801e+02,
        6.13590727e+02, 7.39072203e+02, 8.90215085e+02, 1.07226722e+03,
        1.29154967e+03, 1.55567614e+03, 1.87381742e+03, 2.25701972e+03,
        2.71858824e+03, 3.27454916e+03, 3.94420606e+03, 4.75081016e+03,
        5.72236766e+03, 6.89261210e+03, 8.30217568e+03, 1.00000000e+04]),
 'z_vec': array([0.        , 0.21428571, 0.42857143, 0.64285714, 0.85714286,
        1.07142857, 1.28571429, 1.5       , 1.71428571, 1.92857143,
        2.14285714, 2.35714286, 2.57142857, 2.78571429, 3.        ]),
 'lnk_min': -9.210340371976182,
 'lnk_max': 9.210340371976184,
 'dlnk': 0.18420680743952367,
 'Mmin': 9.0,
 'Mmax': 16.0,
 'dlog10m': 0.05,
 'mdef_model': 'SOMean',
 'hmf_model': 'Tinker10',
 'bias_model': 'Tinker10',
 'halo_concentration_model_dm': 'Duffy08',
 'halo_concentration_model_sat': 'Duffy08',
 'halo_profile_model_dm': 'NFW',
 'halo_profile_model_sat': 'NFW',
 'transfer_model': 'CAMB',
 'transfer_params': {},
 'growth_model': 'CambGrowth',
 'growth_params': {},
 'norm_cen': array([1.]),
 'norm_sat': array([1.]),
 'eta_cen': array([0.]),
 'eta_sat': array([0.]),
 'overdensity': 200,
 'delta_c': 1.686}

Again, you can consult the API docs for information on each one, bu you can also use this special function:

[7]:
HaloModelIngredients.parameter_info()
h0 : float
    Hubble parameter (small h).

omega_c : float
    Cold dark matter density parameter.

omega_b : float
    Baryon density parameter.

omega_m : float
    Matter density parameter.

w0 : float
    Dark energy equation of state parameter.

wa : float
    Dark energy equation of state parameter.

n_s : float
    Spectral index.

tcmb : float
    Temperature of the CMB.

m_nu : float
    Neutrino mass.

sigma_8 : float
    Amplitude of matter fluctuations on 8 Mpc scales.

log10T_AGN : float
    Log10 of AGN temperature.

mead_correction : str
    Correction model from Mead et al.

k_vec : array_like
    Array of wavenumbers.

z_vec : array_like
    Array of redshifts.

lnk_min : float
    Minimum natural log of wavenumber (for hmf).

lnk_max : float
    Maximum natural log of wavenumber (for hmf).

dlnk : float
    Spacing in natural log of wavenumber (for hmf).

Mmin : float
    Minimum halo mass (for hmf).

Mmax : float
    Maximum halo mass (for hmf).

dlog10m : float
    Spacing in log10 of halo mass (for hmf).

mdef_model : str
    Mass definition model (for hmf).

hmf_model : str
    Halo mass function model (for hmf).

bias_model : str
    Halo bias model (for halomod).

halo_concentration_model_dm : str
    Halo concentration model of dark matter / central galaxies (for halomod).

halo_concentration_model_sat : str
    Halo concentration model of satellite galaxies (for halomod).

halo_profile_model_dm : str
    Halo profile model of dark matter / central galaxies (for halomod).

halo_profile_model_sat : str
    Halo profile model of satellite galaxies (for halomod).

transfer_model : str
    Transfer function model (for hmf).

transfer_params : dict
    Parameters for the transfer function (for hmf).

growth_model : str
    Growth function model (for hmf).

growth_params : dict
    Parameters for the growth function (for hmf).

norm_cen : float
    Normalization of c(M) relation for central galaxies.

norm_sat : float
    Normalization of c(M) relation for satellite galaxies.

eta_cen : float
    Bloating parameter for central galaxies.

eta_sat : eta_sat : float
    Bloating parameter for satellite galaxies.

overdensity : float
    Overdensity parameter.

delta_c : float
    Critical density threshold for collapse :math:`\delta_c`.

Almost all of the things that a framework can calculate – whether they be transfer functions, growth factors or mass functions – will appear to be attributes of the object. That is, you don’t “call” them like functions, but instead just access them like data. In fact, they are lazily calculated as needed, and then stored in memory once calculated. So, for example, let’s calculate the matter power spectrum:

[8]:
power = Spectra()
%time power.power_spectrum_mm
CPU times: user 6min 21s, sys: 1.35 s, total: 6min 23s
Wall time: 5.51 s
[8]:
<onepower.pk.PowerSpectrumResult at 0x7f1fc32eb250>

This took almost 6 seconds on this system, as it called CAMB in the background to calculate the power spectrum, and DarkQuest Emulator to calculate the non-linear halo bias. However, it is now cached, and if we call it again:

[9]:
%time power.power_spectrum_mm
CPU times: user 29 µs, sys: 1e+03 ns, total: 30 µs
Wall time: 47.4 µs
[9]:
<onepower.pk.PowerSpectrumResult at 0x7f1fc32eb250>

It takes less than 1/1000 of a second, as its just accessing memory. More than that, each (non-trivial) quantity that the power spectrum depends on is also cached, so to access the halo mass function:

[10]:
%time power.dndlnm.max()
CPU times: user 68 µs, sys: 3 µs, total: 71 µs
Wall time: 81.5 µs
[10]:
2.0094286715138026

Also returns the desired result instanty.

Updating parameters#

Similarly as in hmf and halomod on which we have based most of functionality, we can update the parameters with the .update() method. For more information on this consult the documentation of those packages. For instance, we can update the HOD model by:

[11]:
power.update(hod_model = 'Zheng')

Which will update the model and recalculate all the quantities that depend on it. In other words, it will not recalculate the cosmology or halo mass functions, but the HOD and power spectra will be recomputed. If we would to update the cosmological parameters, then a lot of quantities will be recomputed:

[12]:
power.update(omega_m = 0.5)

We relly on this functionality to vectorize the hmf and halomod so that the onepower can predict all quantities for an array of redshifts as well.