PTEmu — Comet 0.1 documentation

# PTEmu

Main PTEmu module.

class comet.PTEmu.PTEmu(model, use_Mpc=True, bias_basis='EggScoSmi', counterterm_basis='Comet')

  Bases: `object`

  Main class for the emulator of the power spectrum multipoles.

  The emulator makes use of evolution mapping (Sanchez 2020, Sanchez et al 2021,) to compress the information of evolution parameters \(\mathbf{\Theta_{e}}\) (e.g. \(h,\,\Omega_\mathrm{K},\,w_0,\,w_\mathrm{a},\,A_\mathrm{s},\, \ldots\)) into the single quantity \(\sigma_{12}\), defined as the rms fluctuation of the linear density contrast \(\delta\) within spheres of radius \(R=8\,\mathrm{Mpc}\).

  This parameter, together with the parameters affecting the shape of the power spectrum \(\mathbf{\Theta_{s}}\) (e.g. \(\omega_\mathrm{b},\,\omega_\mathrm{c},\,n_\mathrm{s}\)), and the linear growth rate \(f\), are used as base of the emulator.

  The redshift-dependency of the multipoles can also be treated similarly to the impact that different evolution parameters have on the power spectrum, that is, by a simple rescaling of the amplitude of the power spectrum in order to match the desired value of \(\sigma_{12}\).

  Internally to the emulator, the pair \(\left[k,P(k)\right]\) is expressed in \(\left[\mathrm{Mpc}^{-1},\mathrm{Mpc}^3\right]\) units, since this is the only set of units for which the evolution parameter degeneracy is present. If the user wishes to use the more conventional unit set \(\left[h\,\mathrm{Mpc}^{-1},h^{-3}\,\mathrm{Mpc}^3\right]\), they can do so by specifying it in the proper class attribute flag. In this case, the input/output are converted into \(\mathrm{Mpc}\) units before being used/returned.

  Geometrical distortions (AP corrections) are included a posteriori without the need of including them in the emulation. This process is carried out by first reconstructing the full anisotropic 2d galaxy power spectrum \(P_\mathrm{gg}(k,\mu)\), summing up all the even multipoles up to \(\ell=6\), applying distortions to \(k\) and \(\mu\), and then projecting again over the Legendre polynomials.

  Class constructor.

  Parameters:

    - model (str) – Identifier of the selected model.

    - use_Mpc (bool, optional) – Flag that determines if the input and output quantities are specified in \(\mathrm{Mpc}\) (True) or \(h^{-1}\mathrm{Mpc}\) (False) units. Defaults to True.

    - bias_basis (str, optional) – Identifier for the bias basis convention, possible choices are “EggScoSmi” (default), “AssBauGre”, and “AmiGleKok”.

    - counterterm_basis (str, optional) – Identifier for the counterterm basis convention, possible choices are “Comet” (default) and “ClassPT”.

  init_params_dict()

    Initialize params dictionary.

    Sets up the internal class attribute which stores the complete list of model parameters. This includes cosmological parameters as well as biases, noises, counterterms, and other nuisance parameters.

  define_units(use_Mpc)

    Define units for the power spectrum and number density.

    Sets the internal class attribute use_Mpc, clears all the data objects (if defined), and resets the number density to 1 in the units corresponding to the input flag. The number density value can be subsequently explicitly changed calling define_nbar.

    Parameters:

      use_Mpc (bool) – Flag that determines if the input and output quantities are specified in \(\mathrm{Mpc}\) (True) or \(h^{-1}\,\mathrm{Mpc}\) (False) units.

  change_bias_basis(bias_basis)
  change_counterterm_basis(counterterm_basis)
  change_gauss_legendre_degree(degree)
  change_cnloB_type(type)
  define_nbar(nbar)

    Define the number density of the sample.

    Sets the internal class attribute nbar to the value provided as input. The latter is intended to be in the set of units currently used by the emulator, that can be specified at class instanciation, or using the method define_units.

    Parameters:

      nbar (float) – Number density of the sample, in units of \(\mathrm{Mpc}^{-3}\) or \(h^3\,\mathrm{Mpc}^{-3}\), depending on the value of the class attribute use_Mpc.

  define_data_set(obs_id, **kwargs)

    Define data sample.

    If the identifier of the data sample is not present in the internal data dictionary, it assigns a new MeasuredData object to it. Otherwise it updates the already existing entry.

    Parameters:

      - obs_id (str) – Identifier of the data sample.

      - **kwargs (dict) – Dictionary of keyword arguments (check docs of MeasuredData class for the list of allowed keyword arguments).

  define_fiducial_cosmology(HDm_fid=None, params_fid=None, de_model='lambda')

    Define fiducial cosmology.

    Sets the internal attributes of the class to store the parameters of the fiducial cosmology, required for the calculation of the AP corrections.

    Parameters:

      - HDm_fid (list or numpy.ndarray, optional) – List containing the fiducial expansion factor \(H(z)\) and angular diameter distance \(D_\mathrm{A}(z)\), in the units defined by the class attribute use_Mpc. If None, this method expects to find a dictionary containing the parameters of the fiducial cosmology (see params_fid below). Defaults to None.

      - params_fid (dict, optional) – Dictionary containing the parameters of the fiducial cosmology, used to compute the expansion factor \(H(z)\) and angular diameter distance \(D_\mathrm{A}(z)\), in the units defined by the class attribute use_Mpc. Defaults to None.

      - de_model (str, optional) – String that determines the dark energy equation of state. Can be chosen form the list [“lambda”, “w0”, “w0wa”]. Defaults to “lambda”.

  W_kurt(k, mu)

    Large scale limit of the velocity difference generating function.

    Method used exclusively if the VDG_infty model is specified.

    In the large scale limit, \(r\rightarrow\infty\), the velocity difference generating function \(W_\mathrm{G}\) becomes scale-independent, with a gaussian limit given by

    \[W_\infty(\lambda)=e^{-\lambda^2\sigma_\mathrm{v}^2},\]

    where \(\lambda=fk\mu\), and \(\sigma_\mathrm{v}\) is the pairwise velocity dispersion. This method returns a modified version of the gaussian limit, which also allows for non-zero kurtosis of the pairwise velocity distribution,

    \[W_\infty(\lambda)=\frac{1}{\sqrt(1+a_\mathrm{vir}^2\lambda^2)} e^{-\frac{\lambda^2\sigma_\mathrm{v}^2} {1+a_\mathrm{vir}^2\lambda^2}},\]

    where \(a_\mathrm{vir}\) is a free parameter of the model, that can be specified in the list of model parameters when instantiating or updating the class.

    Parameters:

      - k (float) – Value of the wavemode \(k\).

      - mu (float) – Value of the cosine \(\mu\) of the angle between the pair separation and the line of sight.

    Returns:

      Winfty – Value of the pairwise velocity generating function in the large scale limit.

    Return type:

      float

  get_kmu_products(tri, mu1, mu2, mu3)

    Computes the products k1*mu1, k2*mu2, and k3*mu3.

    The method returns the products in a format needed for the computation of the bispectrum damping function. It also applies Alcock-Paczynski distortions to the wave modes and cosines.

    Parameters:

      - tri (numpy.ndarray) – Wavemodes \(k_1\), \(k_2\), \(k_3\).

      - mu1 (numpy.ndarray) – Cosines of the angle between \(k_1\) and the LOS.

      - mu2 (numpy.ndarray) – Cosines of the angle between \(k_2\) and the LOS.

      - mu3 (numpy.ndarray) – Cosines of the angle between \(k_3\) and the LOS.

    Returns:

      - kmu1 (numpy.ndarray) – Product of k1 and mu1.

      - kmu2 (numpy.ndarray) – Product of k2 and mu2.

      - kmu2 (numpy.ndarray) – Product of k3 and mu3.

  WB_kurt(tri, mu1, mu2, mu3)
  PL(k, params, de_model=None)

    Compute the linear power spectrum predictions.

    Evaluates the emulator calling _eval_emulator, and returns the linear power spectrum \(P_\mathrm{L}(k)\) at the specified wavemodes.

    Parameters:

      - k (float or numpy.ndarray) – Value of the requested wavemodes \(k\).

      - params (dict) – Dictionary containing the list of total model parameters which are internally used by the emulator. The keyword/value pairs of the dictionary specify the names and the values of the parameters, respectively.

      - de_model (str, optional) – String that determines the dark energy equation of state. Can be chosen from the list [“lambda”, “w0”, “w0wa”] to work with the standard cosmological parameters, or be left undefined to use only \(\sigma_{12}\). Defaults to None.

    Returns:

      PL – Linear power spectrum \(P_\mathrm{L}(k)\) evaluated at the input wavemodes \(k\).

    Return type:

      float or numpy.ndarray

  Pdw_2d(k, mu, params, de_model=None, ell_for_recon=None)

    Compute the anisotropic leading order IR-resummed power spectrum.

    Evaluates the emulator calling _eval_emulator, and returns the anisotropic leading order IR-resummed power spectrum \(P_\mathrm{IR-res}^\mathrm{LO}(k,\mu)\), defined as

    \[P_\mathrm{IR-res}^\mathrm{LO}(k,\mu) = P_\mathrm{nw}(k) + \ e^{-k^2\Sigma^2(f,\mu)}P_\mathrm{w}(k),\]

    where \(P_\mathrm{nw}\) and \(P_\mathrm{w}\) are the no-wiggle and wiggle-only component of the linear matter power spectrum, and \(\Sigma(f,\mu)\) is the anisotropic BAO damping factor due to infrared modes.

    Notice how this function does not include the leading order Kaiser effect due to the impact of the velocity field on the amplitude of the power spectrum.

    Parameters:

      - k (float or numpy.ndarray) – Value of the requested wavemodes \(k\).

      - mu (float or numpy.ndarray) – Value of the cosine \(\mu\) of the angle between the pair separation and the line of sight.

      - params (dict) – Dictionary containing the list of total model parameters which are internally used by the emulator. The keyword/value pairs of the dictionary specify the names and the values of the parameters, respectively.

      - de_model (str, optional) – String that determines the dark energy equation of state. Can be chosen from the list [“lambda”, “w0”, “w0wa”] to work with the standard cosmological parameters, or be left undefined to use only \(\sigma_{12}\). Defaults to None.

      - ell_for_recon (list, optional) – List of \(\ell\) values used for the reconstruction of the 2d leading-order IR-resummed power spectrum. If None, all the even multipoles up to \(\ell=6\) are used in the reconstruction. Defaults to None.

    Returns:

      Pdw_2d – Leading-order infrared resummed power spectrum \(P_\mathrm{IR-res}^\mathrm{LO}(k,\mu)\) evaluated at the input wavemodes \(k\) and angles \(\mu\).

    Return type:

      numpy.ndarray

  Pdw(k, params, de_model=None, ell_for_recon=None)

    Compute the real space leading order IR-resummed power spectrum.

    Evaluates the emulator calling _eval_emulator, and returns the real space (\(\mu = 0\)) leading order IR-resummed power spectrum \(P_\mathrm{IR-res}^\mathrm{LO}(k,\mu)\), defined as

    \[P_\mathrm{IR-res}^\mathrm{LO}(k,\mu) = P_\mathrm{nw}(k) + \ e^{-k^2\Sigma^2(f,\mu)}P_\mathrm{w}(k),\]

    where \(P_\mathrm{nw}\) and \(P_\mathrm{w}\) are the no-wiggle and wiggle-only component of the linear matter power spectrum, and \(\Sigma(f,\mu)\) is the anisotropic BAO damping factor due to infrared modes.

    Notice how this function does not include the leading order Kaiser effect due to the impact of the velocity field on the amplitude of the power spectrum.

    Parameters:

      - k (float or numpy.ndarray) – Value of the requested wavemodes \(k\).

      - mu (float or numpy.ndarray) – Value of the cosine \(\mu\) of the angle between the pair separation and the line of sight.

      - params (dict) – Dictionary containing the list of total model parameters which are internally used by the emulator. The keyword/value pairs of the dictionary specify the names and the values of the parameters, respectively.

      - de_model (str, optional) – String that determines the dark energy equation of state. Can be chosen from the list [“lambda”, “w0”, “w0wa”] to work with the standard cosmological parameters, or be left undefined to use only \(\sigma_{12}\). Defaults to None.

      - ell_for_recon (list, optional) – List of \(\ell\) values used for the reconstruction of the 2d leading-order IR-resummed power spectrum. If None, all the even multipoles up to \(\ell=6\) are used in the reconstruction. Defaults to None.

    Returns:

      Pdw_2d – Leading-order infrared resummed power spectrum \(P_\mathrm{IR-res}^\mathrm{LO}(k,\mu)\) evaluated at the input wavemodes \(k\) and angles \(\mu\).

    Return type:

      numpy.ndarray

  Pell_quad(k, params, ell, de_model=None, binning=None, obs_id=None, q_tr_lo=None, W_damping=None, ell_for_recon=None)

    Compute the power spectrum multipoles.

    Main method to compute the galaxy power spectrum multipoles. Returns the specified multipole at the given wavemodes \(k\).

    Parameters:

      - k (float or list or numpy.ndarray) – Wavemodes \(k\) at which to evaluate the multipoles. If a list is passed, it has to match the size of ell, and in that case each wavemode refer to a given multipole.

      - params (dict) – Dictionary containing the list of total model parameters which are internally used by the emulator. The keyword/value pairs of the dictionary specify the names and the values of the parameters, respectively.

      - ell (int or list) – Specific multipole order \(\ell\). Can be chosen from the list [0,2,4,6], whose entries correspond to monopole (\(\ell=0\)), quadrupole (\(\ell=2\)), hexadecapole (\(\ell=4\)) and octopole (\(\ell=6\)).

      - de_model (str, optional) – String that determines the dark energy equation of state. Can be chosen from the list [“lambda”, “w0”, “w0wa”] to work with the standard cosmological parameters, or be left undefined to use only \(\sigma_{12}\). Defaults to None.

      - binning (dict, optional)

      - obs_id (str, optional) – If not None the returned power spectrum will be convolved with a survey window function. In that case the string must be a valid data set identifier and the window function mixing matrix must have been loaded beforehand. Defaults to None.

      - q_tr_lo (list or numpy.ndarray, optional) – List containing the user-provided AP parameters, in the form \((q_\perp, q_\parallel)\). If provided, prevents computation from correct formulas (ratios of angular diameter distances and expansion factors wrt to the corresponding quantities of the fiducial cosmology). Defaults to None.

      - W_damping (Callable[[float, float], float], optional) – Function returning the shape of the pairwise velocity generating function in the large scale limit, \(r\rightarrow\infty\). The function accepts two floats as arguments, corresponding to the wavemode \(k\) and the cosinus of the angle between pair separation and line of sight \(\mu\), and returns a float. This function is used only with the VDG_infty model. If None, it uses the free kurtosis distribution defined by W_kurt. Defaults to None.

      - ell_for_recon (list, optional) – List of \(\ell\) values used for the reconstruction of the 2d leading-order IR-resummed power spectrum. If None, all the even multipoles up to \(\ell=6\) are used in the reconstruction. Defaults to None.

    Returns:

      Pell_dict – Dictionary containing all the requested power spectrum multipoles of order \(\ell\) at the specified \(k\).

    Return type:

      dict

  Pell(k, params, ell, de_model=None, binning=None, obs_id=None, q_tr_lo=None, W_damping=None, ell_for_recon=None)

    Compute the power spectrum multipoles.

    Main method to compute the galaxy power spectrum multipoles. Returns the specified multipole at the given wavemodes \(k\).

    Parameters:

      - k (float or list or numpy.ndarray) – Wavemodes \(k\) at which to evaluate the multipoles. If a list is passed, it has to match the size of ell, and in that case each wavemode refer to a given multipole.

      - params (dict) – Dictionary containing the list of total model parameters which are internally used by the emulator. The keyword/value pairs of the dictionary specify the names and the values of the parameters, respectively.

      - ell (int or list) – Specific multipole order \(\ell\). Can be chosen from the list [0,2,4,6], whose entries correspond to monopole (\(\ell=0\)), quadrupole (\(\ell=2\)), hexadecapole (\(\ell=4\)) and octopole (\(\ell=6\)).

      - de_model (str, optional) – String that determines the dark energy equation of state. Can be chosen from the list [“lambda”, “w0”, “w0wa”] to work with the standard cosmological parameters, or be left undefined to use only \(\sigma_{12}\). Defaults to None.

      - binning (dict, optional)

      - obs_id (str, optional) – If not None the returned power spectrum will be convolved with a survey window function. In that case the string must be a valid data set identifier and the window function mixing matrix must have been loaded beforehand. Defaults to None.

      - q_tr_lo (list or numpy.ndarray, optional) – List containing the user-provided AP parameters, in the form \((q_\perp, q_\parallel)\). If provided, prevents computation from correct formulas (ratios of angular diameter distances and expansion factors wrt to the corresponding quantities of the fiducial cosmology). Defaults to None.

      - W_damping (Callable[[float, float], float], optional) – Function returning the shape of the pairwise velocity generating function in the large scale limit, \(r\rightarrow\infty\). The function accepts two floats as arguments, corresponding to the wavemode \(k\) and the cosinus of the angle between pair separation and line of sight \(\mu\), and returns a float. This function is used only with the VDG_infty model. If None, it uses the free kurtosis distribution defined by W_kurt. Defaults to None.

      - ell_for_recon (list, optional) – List of \(\ell\) values used for the reconstruction of the 2d leading-order IR-resummed power spectrum. If None, all the even multipoles up to \(\ell=6\) are used in the reconstruction. Defaults to None.

    Returns:

      Pell_dict – Dictionary containing all the requested power spectrum multipoles of order \(\ell\) at the specified \(k\).

    Return type:

      dict

  Pell_fixed_cosmo_boost(k, params, ell, de_model=None, binning=None, obs_id=None, q_tr_lo=None, W_damping=None, ell_for_recon=None)

    Compute the power spectrum multipoles (fast for fixed cosmology).

    Main method to compute the galaxy power spectrum multipoles. Returns the specified multipole at the given wavemodes \(k\). Differently from Pell, if the cosmology has not been varied from the last call, this method simply reconstruct the final multipoles by multiplying the stored model ingredients (which, at fixed cosmology are the same) by the new bias parameters.

    Parameters:

      - k (float or list or numpy.ndarray) – Wavemodes \(k\) at which to evaluate the multipoles. If a list is passed, it has to match the size of ell, and in that case each wavemode refer to a given multipole.

      - params (dict) – Dictionary containing the list of total model parameters which are internally used by the emulator. The keyword/value pairs of the dictionary specify the names and the values of the parameters, respectively.

      - ell (int or list) – pecific multipole order \(\ell\). Can be chosen from the list [0,2,4,6], whose entries correspond to monopole (\(\ell=0\)), quadrupole (\(\ell=2\)), hexadecapole (\(\ell=4\)) and octopole (\(\ell=6\)).

      - de_model (str, optional) – String that determines the dark energy equation of state. Can be chosen from the list [“lambda”, “w0”, “w0wa”] to work with the standard cosmological parameters, or be left undefined to use only \(\sigma_{12}\). Defaults to None.

      - binning (dict, optional)

      - obs_id (str, optional) – If not None the returned power spectrum will be convolved with a survey window function. In that case the string must be a valid data set identifier and the window function mixing matrix must have been loaded beforehand. Defaults to None.

      - q_tr_lo (list or numpy.ndarray, optional) – List containing the user-provided AP parameters, in the form \((q_\perp, q_\parallel)\). If provided, prevents computation from correct formulas (ratios of angular diameter distances and expansion factors wrt to the corresponding quantities of the fiducial cosmology). Defaults to None.

      - W_damping (Callable[[float, float], float], optional) – Function returning the shape of the pairwise velocity generating function in the large scale limit, \(r\rightarrow\infty\). The function accepts two floats as arguments, corresponding to the wavemode \(k\) and the cosinus of the angle between pair separation and line of sight \(\mu\), and returns a float. This function is used only with the VDG_infty model. If None, it uses the free kurtosis distribution defined by W_kurt. Defaults to None.

      - ell_for_recon (list, optional) – List of \(\ell\) values used for the reconstruction of the 2d leading-order IR-resummed power spectrum. If None, all the even multipoles up to \(\ell=6\) are used in the reconstruction. Defaults to None.

    Returns:

      Pell_dict – Dictionary containing all the requested power spectrum multipoles of order \(\ell\) at the specified \(k\).

    Return type:

      dict

  PX(k, mu, params, X, de_model=None)

    Compute the individual contribution X to the galaxy power spectrum.

    Returns the individual anisotropic contribution X to the galaxy power spectrum \(P_\mathrm{gg}(k,\mu)\).

    Parameters:

      - k (float or list or numpy.ndarray) – Wavemodes \(k\) at which to evaluate the X contribution.

      - mu (float or list or numpy.ndarray) – Cosinus \(\mu\) between the pair separation and the line of sight at which to evaluate the X contribution.

      - params (dict) – Dictionary containing the list of total model parameters which are internally used by the emulator. The keyword/value pairs of the dictionary specify the names and the values of the parameters, respectively.

      - X (str) – Identifier of the contribution to the galaxy power spectrum. Can be chosen from the list [“P0L_b1b1”, “PNL_b1”, “PNL_id”, “Pctr_c0”, “Pctr_c2”, “Pctr_c4”, “Pctr_b1b1cnlo”, “Pctr_b1cnlo”, “Pctr_cnlo”, “P1L_b1b1”, “P1L_b1b2”, “P1L_b1g2”, “P1L_b1g21”, “P1L_b2b2”, “P1L_b2g2”, “P1L_g2g2”, “P1L_b2”, “P1L_g2”, “P1L_g21”].

      - de_model (str, optional) – String that determines the dark energy equation of state. Can be chosen from the list [“lambda”, “w0”, “w0wa”] to work with the standard cosmological parameters, or be left undefined to use only \(\sigma_{12}\). Defaults to None.

    Returns:

      PX_2d – 2-d array containing the X contribution to the galaxy power spectrum at the specified \(k\) and \(\mu\).

    Return type:

      numpy.ndarray

  PX_ell(k, params, ell, X, de_model=None, binning=None, obs_id=None, q_tr_lo=None, W_damping=None, ell_for_recon=None)

    Get the individual contribution to the power spectrum multipoles.

    Computes the individual contribution X to the galaxy power spectrum multipoles. Returns the contribution to the specified multipole at the specified wavemodes \(k\).

    Parameters:

      - k (float or list or numpy.ndarray) – Wavemodes \(k\) at which to evaluate the multipoles. If a list is passed, it has to match the size of ell, and in that case each wavemode refer to a given multipole.

      - params (dict) – Dictionary containing the list of total model parameters which are internally used by the emulator. The keyword/value pairs of the dictionary specify the names and the values of the parameters, respectively.

      - ell (int or list) – pecific multipole order \(\ell\). Can be chosen from the list [0,2,4,6], whose entries correspond to monopole (\(\ell=0\)), quadrupole (\(\ell=2\)), hexadecapole (\(\ell=4\)) and octopole (\(\ell=6\)).

      - X (str) – Identifier of the contribution to the galaxy power spectrum. Can be chosen from the list [“P0L_b1b1”, “PNL_b1”, “PNL_id”, “Pctr_c0”, “Pctr_c2”, “Pctr_c4”, “Pctr_b1b1cnlo”, “Pctr_b1cnlo”, “Pctr_cnlo”, “P1L_b1b1”, “P1L_b1b2”, “P1L_b1g2”, “P1L_b1g21”, “P1L_b2b2”, “P1L_b2g2”, “P1L_g2g2”, “P1L_b2”, “P1L_g2”, “P1L_g21”, “Pnoise_NP0”, “Pnoise_NP20”, “Pnoise_NP22”].

      - de_model (str, optional) – String that determines the dark energy equation of state. Can be chosen from the list [“lambda”, “w0”, “w0wa”] to work with the standard cosmological parameters, or be left undefined to use only \(\sigma_{12}\). Defaults to None.

      - binning (dict, optional)

      - obs_id (str, optional) – If not None the returned power spectrum contribution will be convolved with a survey window function. In that case the string must be a valid data set identifier and the window function mixing matrix must have been loaded beforehand. Defaults to None.

      - q_tr_lo (list or numpy.ndarray, optional) – List containing the user-provided AP parameters, in the form \((q_\perp, q_\parallel)\). If provided, prevents computation from correct formulas (ratios of angular diameter distances and expansion factors wrt to the corresponding quantities of the fiducial cosmology). Defaults to None.

      - W_damping (Callable[[float, float], float], optional) – Function returning the shape of the pairwise velocity generating function in the large scale limit, \(r\rightarrow\infty\). The function accepts two floats as arguments, corresponding to the wavemode \(k\) and the cosinus of the angle between pair separation and line of sight \(\mu\), and returns a float. This function is used only with the VDG_infty model. If None, it uses the free kurtosis distribution defined by W_kurt. Defaults to None.

      - ell_for_recon (list, optional) – List of \(\ell\) values used for the reconstruction of the 2d leading-order IR-resummed power spectrum. If None, all the even multipoles up to \(\ell=6\) are used in the reconstruction. Defaults to None.

    Returns:

      PX_ell_dict – Dictionary containing the contributions to all the requested power spectrum multipoles of order \(\ell\) at the specified \(k\).

    Return type:

      dict

  Bell(tri, params, ell, de_model=None, kfun=None, binning=None, q_tr_lo=None, W_damping=None, ell_for_recon=None, gl_deg=8, cnloB_mapping=None)
  Avg_covariance(l1, l2, k, Pl, sigma_d, avg_los=3)
  Pell_covariance(k, params, ell, dk, de_model=None, q_tr_lo=None, W_damping=None, volume=None, zmin=None, zmax=None, fsky=0.36361026083215203, Nmodes=None, volfac=1.0, avg_cov=False, avg_los=3)

    Compute the Gaussian covariance of the power spectrum multipoles.

    Generates the selected power spectrum multipoles for the specified set of parameters, and returns their Gaussian covariance predictions at the specified wavemodes \(k\).

    Parameters:

      - k (float or list or numpy.ndarray) – Wavemodes \(k\) at which to evaluate the multipoles. If a list is passed, it has to match the size of ell, and in that case each wavemode refer to a given multipole.

      - params (dict) – Dictionary containing the list of total model parameters which are internally used by the emulator. The keyword/value pairs of the dictionary specify the names and the values of the parameters, respectively.

      - ell (int or list) – pecific multipole order \(\ell\). Can be chosen from the list [0,2,4,6], whose entries correspond to monopole (\(\ell=0\)), quadrupole (\(\ell=2\)), hexadecapole (\(\ell=4\)) and octopole (\(\ell=6\)).

      - dk (float) – Width of the \(k\) bins.

      - de_model (str, optional) – String that determines the dark energy equation of state. Can be chosen from the list [“lambda”, “w0”, “w0wa”] to work with the standard cosmological parameters, or be left undefined to use only \(\sigma_{12}\). Defaults to None.

      - q_tr_lo (list or numpy.ndarray, optional) – List containing the user-provided AP parameters, in the form \((q_\perp, q_\parallel)\). If provided, prevents computation from correct formulas (ratios of angular diameter distances and expansion factors wrt to the corresponding quantities of the fiducial cosmology). Defaults to None.

      - W_damping (Callable[[float, float], float], optional) – Function returning the shape of the pairwise velocity generating function in the large scale limit, \(r\rightarrow\infty\). The function accepts two floats as arguments, corresponding to the wavemode \(k\) and the cosinus of the angle between pair separation and line of sight \(\mu\), and returns a float. This function is used only with the VDG_infty model. If None, it uses the free kurtosis distribution defined by W_kurt. Defaults to None.

      - volume (float, optional) – Reference volume to be used in the calculation of the gaussian covariance. Defaults to None.

      - zmin (float, optional) – Minimum redshift of the volume used in the calculation of the gaussian covariance. Defaults to None.

      - zmin – Maximum redshift of the volume used in the calculation of the gaussian covariance. Defaults to None.

      - fsky (float, optional) – Sky fraction of the volume used in the calculation of the gaussian covariance (in units of radians). Defaults to \(15000\mathrm{deg}^2\).

      - Nmodes (numpy.ndarray, optional) – Number of fundamental modes per \(k-shell. The size of the array should match the size of ``k`\). Defaults to \(4\pi/3\,\left[(k+\Delta k/2)^3 - (k-\Delta k/2)^3\right] /k_f^3\), where \(k_f^3 = (2 \pi)^3/V\).

      - volfac (float, optional) – Rescaling volume fraction. Defaults to \(1\).

    Returns:

      cov – Gaussian covariance of the selected power spectrum multipoles.

    Return type:

      numpy.ndarray

  Bell_covariance(tri, params, ell, dk, de_model=None, kfun=None, q_tr_lo=None, W_damping=None, volume=None, zmin=None, zmax=None, fsky=0.36361026083215203, Ntri=None, volfac=1.0)

    Compute the Gaussian covariance of the bispectrum multipoles.

    Returns the Gaussian covariance predictions for the specified multipole numbers at the given parameters and triangle configurations \(k_1\), \(k_2\), \(k_3\).

    Parameters:

      - tri (numpy.ndarray or list of numpy.ndarray) – Wavemodes \(k_1\), \(k_2\), \(k_3\) at which to evaluate the predictions. If a list is passed, it has to match the size of ell, and in that case each set of configurations refers to a given multipole.

      - params (dict) – Dictionary containing the list of total model parameters which are internally used by the emulator. The keyword/value pairs of the dictionary specify the names and the values of the parameters, respectively.

      - ell (int or list) – pecific multipole order \(\ell\). Can be chosen from the list [0,2,4], whose entries correspond to monopole (\(\ell=0\)), quadrupole (\(\ell=2\)), hexadecapole (\(\ell=4\)) and octopole (\(\ell=6\)).

      - dk (float) – Width of the \(k\) bins.

      - de_model (str, optional) – String that determines the dark energy equation of state. Can be chosen from the list [“lambda”, “w0”, “w0wa”] to work with the standard cosmological parameters, or be left undefined to use only \(\sigma_{12}\). Defaults to None.

      - k_fun (float, optional) – Fundamental frequency of the grid that was used to compute the bispectrum measurements. This is useful to specify if the triangle configurations are not given in multiples of the fundamental frequency, in which case a compression of the unique \(k\) modes is performed. Should not be much larger than the bin width. Defaults to \(\Delta k\).

      - q_tr_lo (list or numpy.ndarray, optional) – List containing the user-provided AP parameters, in the form \((q_\perp, q_\parallel)\). If provided, prevents computation from correct formulas (ratios of angular diameter distances and expansion factors wrt to the corresponding quantities of the fiducial cosmology). Defaults to None.

      - W_damping (Callable[[float, float], float], optional) – Function returning the shape of the pairwise velocity generating function in the large scale limit, \(r\rightarrow\infty\). The function accepts two floats as arguments, corresponding to the wavemode \(k\) and the cosinus of the angle between pair separation and line of sight \(\mu\), and returns a float. This function is used only with the VDG_infty model. If None, it uses the free kurtosis distribution defined by W_kurt. Defaults to None.

      - volume (float, optional) – Reference volume to be used in the calculation of the gaussian covariance. Defaults to None.

      - zmin (float, optional) – Minimum redshift of the volume used in the calculation of the gaussian covariance. Defaults to None.

      - zmin – Maximum redshift of the volume used in the calculation of the gaussian covariance. Defaults to None.

      - fsky (float, optional) – Sky fraction of the volume used in the calculation of the gaussian covariance (in units of radians). Defaults to \(15000\mathrm{deg}^2\).

      - Ntri (numpy.ndarray, optional) – Number of fundamental triangles per bin. The size of this array should match the size of `tri`, or the longest array in `tri` if given as a list. Defaults to \(8 \pi^2 k_1\,k_2\,k_3\,\Delta k^3\k_f^6\), where \(k_f^3 = (2\pi)^3/V\).

      - volfac (float, optional) – Rescaling volume fraction. Defaults to \(1\).

    Returns:

      cov – Gaussian covariance of the selected bispectrum multipoles.

    Return type:

      numpy.ndarray

  chi2(obs_id, params, kmax, de_model=None, binning=None, convolve_window=False, q_tr_lo=None, W_damping=None, chi2_decomposition=False, ell_for_recon=None, cnloB_mapping=None)

    Compute the \(\chi^2 for the given configurations\).

    Generates the selected power spectrum multipoles for the specified set of parameters, and returns the \(\chi^2\) evaluated with the specified \(k_\mathrm{max}\) for the specified data sample.

    Parameters:

      - obs_id (str) – Identifier of the data sample.

      - params (dict) – Dictionary containing the list of total model parameters which are internally used by the emulator. The keyword/value pairs of the dictionary specify the names and the values of the parameters, respectively.

      - kmax (float or list) – Maximum wavemode up to which the \(\chi^2\) is computed. If a float is passed, this is used for all the multipoles, else each value refers to a given multipoles.

      - de_model (str, optional) – String that determines the dark energy equation of state. Can be chosen from the list [“lambda”, “w0”, “w0wa”] to work with the standard cosmological parameters, or be left undefined to use only \(\sigma_{12}\). Defaults to None.

      - binning (dict, optional)

      - convolve_window (bool, optional)

      - q_tr_lo (list or numpy.ndarray, optional) – List containing the user-provided AP parameters, in the form \((q_\perp, q_\parallel)\). If provided, prevents computation from correct formulas (ratios of angular diameter distances and expansion factors wrt to the corresponding quantities of the fiducial cosmology). Defaults to None.

      - W_damping (Callable[[float, float], float], optional) – Function returning the shape of the pairwise velocity generating function in the large scale limit, \(r\rightarrow\infty\). The function accepts two floats as arguments, corresponding to the wavemode \(k\) and the cosinus of the angle between pair separation and line of sight \(\mu\), and returns a float. This function is used only with the VDG_infty model. If None, it uses the free kurtosis distribution defined by W_kurt. Defaults to None.

      - chi2_decomposition (bool, optional) – Flag to determine if the \(\chi^2\) is computed using the fast \(\chi^2\) decomposition (True) or not (False). Defaults to False.

      - ell_for_recon (list, optional) – List of \(\ell\) values used for the reconstruction of the 2d leading-order IR-resummed power spectrum. If None, all the even multipoles up to \(\ell=6\) are used in the reconstruction. Defaults to None.

    Returns:

      chi2 – Value of the \(\chi^2\).

    Return type:

      float

# bispectrum

Bispectrum module.

class comet.bispectrum.Bispectrum(real_space, model, use_Mpc)

  Bases: `object`

  Main class for the emulator of the bispectrum multipoles.

  Class constructor

  Parameters:

    - real_space (bool) – Flag that determines if the model bispectrum is computed in real- (False) or redshift-space (True).

    - use_Mpc (bool) – Flag that determines if the input and output quantities are specified in \(\mathrm{Mpc}\) (True) or \(h^{-1}\mathrm{Mpc}\) (False) units. Defaults to True.

  change_RSD_model(model)
  change_cnlo_type(type)
  define_units(use_Mpc)

    Define units for the bispectrum.

    Sets the internal class attribute use_Mpc.

    Parameters:

      use_Mpc (bool) – Flag that determines if the input and output quantities are specified in \(\mathrm{Mpc}\) (True) or \(h^{-1}\,\mathrm{Mpc}\) (False) units.

  define_nbar(nbar)

    Define the number density of the sample.

    Sets the internal class attribute nbar to the value provided as input. The latter is intended to be in the set of units currently used by the emulator, that can be specified at class instanciation, or using the method define_units.

    Parameters:

      nbar (float) – Number density of the sample, in units of \(\mathrm{Mpc}^{-3}\) or \(h^3\,\mathrm{Mpc}^{-3}\), depending on the value of the class attribute use_Mpc.

  set_tri(tri, ell, kfun, gl_deg=8, binning=None)

    Define triangular configurations and compute kernels.

    Reads the list of triangular configurations and the request fundamental frequency, and sotres them into class attributes. Additionaly computes the necessary kernels (and the angular integrals if working in redshift-space).

    Parameters:

      - tri – List of triangular configurations.

      - ell – List of multipoles for which the triangular configurations correspond to.

      - kfun (float) – Fundamental frequency.

  set_fiducial_cosmology(params)
  init_Pdw(Pdw, ell)
  init_Pdw_eff(Pdw_eff)
  F2(k1, k2, k3)

    Compute the second-order density kernel.

    Computes the second order density kernel \(F_2\) on the triangular configuration defined by the input wavemodes \((k_1,k_2,k_3)\), using the angle between \(k_1\) and \(k_2\).

    Parameters:

      - k1 (float) – Wavemode \(k_1\).

      - k2 (float) – Wavemode \(k_2\).

      - k3 (float) – Wavemode \(k_3\).

    Returns:

      F2 – Second-order density kernel \(F_2\) between the wavemodes \(k_1\) and \(k_2\).

    Return type:

      float

  G2(k1, k2, k3)

    Compute the second-order velocity divergence kernel.

    Computes the second order velocity divergence kernel \(G_2\) on the triangular configuration defined by the input wavemodes \((k_1,k_2,k_3)\), using the angle between \(k_1\) and \(k_2\).

    Parameters:

      - k1 (float) – Wavemode \(k_1\).

      - k2 (float) – Wavemode \(k_2\).

      - k3 (float) – Wavemode \(k_3\).

    Returns:

      G2 – Second-order velocity divergence kernel \(G_2\) between the wavemodes \(k_1\) and \(k_2\).

    Return type:

      float

  K(k1, k2, k3)

    Compute the Fourier-space kernel of the second-order Galileon.

    Computes the Fourier-space kernel of the second-order Galileon \(K\) on the triangular configuration defined by the input wavemodes \((k_1,k_2,k_3)\), using the angle between \(k_1\) and \(k_2\).

    Parameters:

      - k1 (float) – Wavemode \(k_1\).

      - k2 (float) – Wavemode \(k_2\).

      - k3 (float) – Wavemode \(k_3\).

    Returns:

      K – Fourier-space kernel of the second-order Galileon \(K\) between the wavemodes \(k_1\) and \(k_2\).

    Return type:

      float

  kernels_real_space(k1, k2, k3)

    Compute the kernels for the real-space bispectrum.

    Computes the kernels required for the real-space bispectrum, and returns them in a dictionary format. This includes only the second-order density kernel \(F_2\) and the Fourier-space kernel of the second-order galileon \(K\)

    Parameters:

      - k1 (float) – Wavemode \(k_1\).

      - k2 (float) – Wavemode \(k_2\).

      - k3 (float) – Wavemode \(k_3\).

    Returns:

      kernels – Dictionary containing the kernels required to model the real-space bispectrum.

    Return type:

      dict

  kernels_redshift_space(k1, k2, k3)

    Compute the kernels for the redshift-space bispectrum.

    Computes the kernels required for the redshift-space bispectrum, and returns them in a dictionary format. This includes the second-order density and velocity divergence kernels, \(F_2\) and \(G_2\), the Fourier-space kernel of the second-order galileon \(K\), the ratios of \(k_3\) to the other two wavemodes, and the logarithmic derivatives of the previous kernels with respect to \(k_1\), \(k_2\) and \(k_3\).

    Parameters:

      - k1 (float) – Wavemode \(k_1\).

      - k2 (float) – Wavemode \(k_2\).

      - k3 (float) – Wavemode \(k_3\).

    Returns:

      kernels – Dictionary containing the kernels required to model the redshift-space bispectrum.

    Return type:

      dict

  mu123_integrals(n1, n2, n3, k1, k2, k3)

    Angular integration.

    Computes the integral

    \[\frac{1}/{4\pi} \int {\rm{d}}\mu \int {\rm{d}}\phi \ \mu_1^{n_1}\mu_2^{n_2}\mu_3^{n_3},\]

    where

    \[\begin{split}\begin{flalign*} & \mu_1 = \mu, \\ & \mu_2 = \mu\nu - \sqrt(1-\mu^2)\sqrt(1-\nu^2)\cos(\phi), \\ & \mu_3 = -\frac{k_1}{k_3}\mu_1 - \frac{k_2}{k_3}\mu_2, \end{flalign*}\end{split}\]

    and \(\mu_n\) is the cosinus of the angle bewteen the wavemode \(k_n\) and the line of sight, and \(\nu\) is the cosinus of the angle between \(k_1\) and \(k_2\).

    Parameters:

      - n1 (int) – Power of wavemode \(k_1\).

      - n2 (int) – Power of wavemode \(k_2\).

      - n3 (int) – Power of wavemode \(k_3\).

      - k1 (float) – Wavemode \(k_1\).

      - k2 (float) – Wavemode \(k_2\).

      - k3 (float) – Wavemode \(k_3\).

    Returns:

      I – Angular integration of the different powers of the input angles.

    Return type:

      float

  compute_kernels(tri)

    Compute kernels for all triangle configurations.

    Computes the kernels for the various triangle configurations, by calling the corresponding class method (depending if the model is in real- or redshift-space), and stores them into a class attribute.

  Gauss_Legendre_mu123_integrals(tri, deg)
  compute_mu123_integrals(tri)

    Compute angular integrals for all triangle configurations.

    Computes the angular integrals for the various triangle configurations, by calling the class method mu123_integrals, and stores them into a class attribute.

  compute_damped_mu123_integrals(tri, W_damping)
  compute_kernels_shell_average(max_ell)
  load_kernels_shell_average()
  compute_covariance_mixing_kernel(l1, l2, l3, l4, l5)
  generate_index_arrays(round_decimals=2)

    Generate arrays of indeces of triangular configurations.

    Determines the unique wavemode bins in the triangle configurations, approximating them to the ratio with respect to a given fundamental frequency.

    Parameters:

      round_decimals (int, optional) – Number of decimal digits used in the approximation of the ratios with respect to the fundamental frequency. Deafults to 2.

  generate_eff_index_arrays(round_decimals=2)

    Generate arrays of indeces of effective triangular configurations.

    Determines the unique wavemode bins in the effective triangle configurations, approximating them to the ratio with respect to a given fundamental frequency.

    Parameters:

      round_decimals (int, optional) – Number of decimal digits used in the approximation of the ratios with respect to the fundamental frequency. Deafults to 2.

  join_kernel_mu123_integral(K, n123_tuples, ell, neff, coeff, q_tr, q_lo, cnloB=None)
  join_kernel_mu123_integral_indv(K, n123_tuples, ell, neff, coeff, q_tr, q_lo)
  join_stoch_kernel_mu123_integral(n123_tuples, ell, neff, coeff, q_tr, q_lo, cnloB_stoch=0)
  join_stoch_kernel_mu123_integral_indv(n123_tuples, ell, neff, coeff, q_tr, q_lo)
  join_kernel_mu123_shell_average(K, n123_tuples, ell, neff, coeff, q_tr, q_lo, cnloB=None)
  join_stoch_kernel_mu123_shell_average(n123_tuples, ell, neff, coeff, q_tr, q_lo, cnloB_stoch=0)
  Bell(PL_dw, neff, params, ell=[0], W_damping=None)
  BX_ell(PL_dw, neff, params, ell=[0], W_damping=None)
  Gaussian_covariance(l1, l2, dk, Pell, volume, Ntri=None)

# cosmology

Cosmology module.

class comet.cosmology.Cosmology(Om0, H0, Ok0=0.0, Or0=0.0, de_model='lambda', w0=-1.0, wa=0.0)

  Bases: `object`

  Class containing cosmological parameters and background quantities.

  This object is used to compute background quantities (expansion, growth) of the specific cosmology passed as input.

  In all cases including an evolving dark energy density, its equation of state is parametrized as \(w(a)=w_0+w_a(1-a)\) (Chevalier & Polansky 2001, Linder 2003).

  Class constructor.

  Parameters:

    - Om0 (float) – Fractional total matter density at present time, \(\Omega_\mathrm{m,0}\).

    - H0 (float) – Hubble constant at present time, \(H_0\).

    - Ok0 (float, optional) – Fractional curvature density at present time, \(\Omega_\mathrm{k,0}\). Defaults to 0.0.

    - Or0 (float, optional) – Fractional radiation density at present time, \(\Omega_\mathrm{r,0}\), Defaults to 0.0.

    - de_model (str, optional) – Selected dark energy model. It can be chosen from the list [“lambda”, “w0”, “w0wa”], whose entries correspond to a LCDM, \(w\) CDM, and quintessence model, respectively. Defaults to “lambda”.

    - w0 (float, optional) – Dark energy equation of state at present time, \(w_0\). Only used if de_model is not “lambda”. Defaults to -1.0.

    - wa (float, optional) – Negative derivative of the dark energy equation of state with respect to the scale factor, \(w_a\). Only used if de_model is “w0wa”. Defaults to 0.0.

  update_cosmology(Om0, H0, Ok0=0.0, Or0=0.0, de_model='lambda', w0=-1.0, wa=0.0)

    Update the class to a new cosmology.

    Overwrites the current class attributes to assign the new cosmological parameters passed as input.

    Parameters:

      - Om0 (float) – Fractional total matter density at present time, \(\Omega_\mathrm{m,0}\).

      - H0 (float) – Hubble constant at present time, \(H_0\).

      - Ok0 (float, optional) – Fractional curvature density at present time, \(\Omega_\mathrm{k,0}\). Defaults to 0.0.

      - Or0 (float, optional) – Fractional radiation density at present time, \(\Omega_\mathrm{r,0}\), Defaults to 0.0.

      - de_model (str, optional) – Selected dark energy model. It can be chosen from the list [“lambda”, “w0”, “w0wa”], whose entries correspond to a LCDM, \(w\) CDM, and quintessence model, respectively. Defaults to “lambda”.

      - w0 (float, optional) – Dark energy equation of state at present time, \(w_0\). Only used if de_model is not “lambda”. Defaults to -1.0.

      - wa (float, optional) – Negative derivative of the dark energy equation of state with respect to the scale factor, \(w_a\). Only used if de_model is “w0wa”. Defaults to 0.0.

  DE_z(z)

    Dark energy density as a function of redshift.

    Returns the energy density of the specified dark energy component, normalised to the value at present time,

    \[\frac{\rho_\mathrm{DE}(z)}{\rho_\mathrm{DE}(0)} = \ \exp\left[-\int_0^z \frac{dz'}{1+z'}\left(1+w\left(z'\right)\ \right) \right]\,.\]
    Parameters:

      z (float or numpy.ndarray) – Redshifts at which to evaluate the dark energy density.

    Returns:

      de_z – Energy density of the dark energy component at the specified redshifts.

    Return type:

      float or numpy.ndarray

  wz(z)

    Dark energy equation of state as a function of redshift.

    Returns the equation of state of the dark energy component,

    \[w(z) = w_0+w_a\frac{z}{1+z}\,.\]
    Parameters:

      z (float or numpy.ndarray) – Redshifts at which to evaluate the dark energy equation of state.

    Returns:

      w – Dark energy equation of state at the specified redshifts.

    Return type:

      float or numpy.ndarray

  Ez(z)

    Normalised expansion factor as a function of redshift.

    Returns the value of the Hubble factor at the specified redshift, normalised to the value at present time,

    \begin{split} E(z) = \frac{H(z)}{H_0} = \bigg[ \ &\Omega_\mathrm{m,0}(1+z)^3 \ + \Omega_\mathrm{r,0}(1+z)^4 \ + \Omega_\mathrm{k,0}(1+z)^2 \\ &+ \Omega_\mathrm{DE,0}\exp\Big[-\int_0^z \ \frac{dz'}{1+z'} \left(1+w\left(z'\right)\right) \Big] \bigg]^\frac{1}{2}\,. \end{split}
    Parameters:

      z (float or numpy.ndarray) – Redshifts at which to evaluate the normalised expansion factor.

    Returns:

      Ez – Normalised expansion factor at the specified redshifts.

    Return type:

      float or numpy.ndarray

  one_over_Ez(z)

    Inverse normalised expansion factor as a function of redshift.

    Return the inverse of the normalised expansion factor defined in Ez.

    Parameters:

      z (float or numpy.ndarray) – Redshifts at which to evaluate the inverse expansion factor.

    Returns:

      inv_Ez – Inverse normalised expansion factor at the specified redshifts.

    Return type:

      float or numpy.ndarray

  Hz(z)

    Hubble expansion factor.

    Returns the Hubble parameter \(H(z)\), defined as

    \[H(z) = H_0\, E(z) \, .\]
    Parameters:

      z (float or numpy.ndarray) – Redshifts at which to evaluate the Hubble factor.

    Returns:

      Hz – Hubble expansion factor at the specified redshifts.

    Return type:

      float or numpy.ndarray

  Om(z)

    Fractional total matter density as a function of redshift.

    Returns the total matter density at the specified redshifts in units of the critical density \(\rho_\mathrm{crit}(z)=\frac{3H^2(z)}{8\pi G}\), as

    \[\Omega_\mathrm{m}(z) = \ \frac{\rho_\mathrm{m}(z)}{\rho_\mathrm{crit}(z)} = \ \frac{\Omega_\mathrm{m,0}\,(1+z)^3}{E^2(z)} \, .\]
    Parameters:

      z (float or numpy.ndarray) – Redshifts at which to evaluate the fractional matter density.

    Returns:

      Om – Fractional matter density at the specified redshifts.

    Return type:

      float or numpy.ndarray

  Ode(z)

    Fractional dark energy density as a function of redshift.

    Returns the dark energy density at the specified redshifts in units of the critical density \(\rho_\mathrm{crit}(z)=\frac{3H^2(z)}{8\pi G}\), as

    \[\Omega_\mathrm{DE}(z) = \ \frac{\rho_\mathrm{DE}(z)}{\rho_\mathrm{crit}(z)} = \ \frac{\Omega_\mathrm{DE,0}\exp\left[ \ -\int_0^z \frac{dz'}{1+z'}\left(1+w\left(z'\right)\right) \ \right]}{E^2(z)} \, .\]
    Parameters:

      z (float or numpy.ndarray) – Redshifts at which to evaluate the fractional dark energy density.

    Returns:

      Ode – Fractional dark energy density at the specified redshifts.

    Return type:

      float or numpy.ndarray

  comoving_transverse_distance(z)

    Transverse comoving distance as a function of redshift.

    Returns the transverse comoving distance defined as

    \begin{gather*} D_\mathrm{M}(z) = \begin{cases} \frac{D_H}{\sqrt{-\Omega_\mathrm{k,0}}}\sin \left(\ \frac{\sqrt{-\Omega_\mathrm{k,0}}D_\mathrm{C}(z)}{D_H}\ \right), & \text{if}\ \Omega_\mathrm{k,0}<0 \\ D_\mathrm{C}(z), & \text{if}\ \Omega_\mathrm{k,0}=0 \, ,\\ \frac{D_H}{\sqrt{\Omega_\mathrm{k,0}}}\sinh \left(\ \frac{\sqrt{\Omega_\mathrm{k,0}}D_\mathrm{C}(z)}{D_H}\ \right), & \text{if}\ \Omega_\mathrm{k,0}>0 \end{cases} \end{gather*}

    where

    \[D_\mathrm{C}(z) = D_H \int_0^z \frac{dz'}{E(z')}\]

    is the comoving distance, and

    \[D_H = \frac{c}{H_0}\]

    is the Hubble distance.

    Parameters:

      z (float) – Redshift at which to evaluate the transverse comoving distance.

    Returns:

      dm – Transverse comoving distance at the specified redshift.

    Return type:

      float

  angular_diameter_distance(z)

    Angular diameter distance as a function of redshift.

    Returns the angular diameter distance defined as

    \[D_\mathrm{A}(z) = \frac{1}{1+z}D_\mathrm{M}(z) \, .\]
    Parameters:

      z (float) – Redshift at which to evaluate the angular diameter distance.

    Returns:

      da – Angular diameter distance at the specified redshift.

    Return type:

      float

  growth_factor(z, get_growth_rate=False)

    Linear growth factor as a function of redshift.

    Returns the linear growth factor \(D(z)\) (and the linear growth rate \(f(z)\) at user request).

    Parameters:

      - z (float) – Redshift at which to evaluate the growth factor.

      - get_growth_rate (bool, optional) – Flag specifying whether to return only the linear growth factor (if False) or also the linear growth rate (if True). Defaults to False.

    Returns:

      Dz – Linear growth factor, or list containing both the linear growth factor and growth rate, at the specified redshift.

    Return type:

      float or list

  growth_rate(z)

    Linear growth rate as a function of redshift.

    Returns the linear growth rate \(f(z)\).

    Parameters:

      z (float) – Redshift at which to evaluate the linear growth rate.

    Returns:

      f – Linear growth rate at the specified redshift.

    Return type:

      float

  comoving_volume(zmin, zmax, fsky)

    Comoving volume as a function of redshift and sky fraction.

    Computes the transverse comoving volume between \(z_\mathrm{min}\) and \(z_\mathrm{max}\) for a given sky fraction \(f_\mathrm{sky}\), as

    \[V_\mathrm{M}(z_\mathrm{min}, z_\mathrm{max}, f_\mathrm{sky}) = \ \frac{4\pi f_\mathrm{sky}}{3} \left[D_\mathrm{M}^3 \ (z_\mathrm{max}) - D_\mathrm{M}^3(z_\mathrm{min})\right]\]
    Parameters:

      - zmin (float) – Lower redshift limit \(z_\mathrm{min}\).

      - zmax (float) – Upper redshift limit \(z_\mathrm{max}\).

      - fsky (float) – Sky fraction \(f_\mathrm{sky}\).

    Returns:

      vol – Transverse comoving volume between the specified minimum and maximum redshifts, and for the given sky fraction.

    Return type:

      float

# data

Data module.

class comet.data.MeasuredData(**kwargs)

  Bases: `object`

  Class for handling data structures (data vectors and covariances).

  Class constructor.

  Keywords argument kwargs are summarised in the Parameters section below. An instance of the class can be created without specifying any of the keyword arguments, and subsequently updated with the update method.

  Parameters:

    - bins (numpy.ndarray, optional) – Array containing the sampled wavemodes \(k\).

    - signal (numpy.ndarray, optional) – Array containing the power spectrum multipoles \(P_{\ell}(k)\). If more than one multipole is provided, the first and second index of the array runs over the different \(k\) and the different multipole \(\ell\), respectively.

    - cov (numpy.ndarray, optional) – Covariance matrix corresponding to signal. The covariance is in the form of a 2d array, whose blocks correspond to the auto- (along the diagonal) and cross-covariances of the multipoles.

    - theory_cov (bool, optional) – Flag to determine if the provided covariance matrix is theoretical (True) or estimated from simulations (False). Defaults to True.

    - n_realizations (int, optional) – If the provided covariance is estimated from numerical simulations, this parameter is required, and specifies the total number of resamplings (needed for Hartlap corrections).

  update(**kwargs)

    Update the class with new data.

    Keywords argument kwargs are summarised in the Parameters section below.

    Parameters:

      - bins (numpy.ndarray, optional) – Array containing the sampled wavemodes \(k\).

      - signal (numpy.ndarray, optional) – Array containing the power spectrum multipoles \(P_{\ell}(k)\). If more than one multipole is provided, the first and second index of the array runs over the different \(k\) and the different multipole \(\ell\), respectively.

      - cov (numpy.ndarray, optional) – Covariance matrix corresponding to signal. The covariance is in the form of a 2d array, whose blocks correspond to the auto- (along the diagonal) and cross-covariances of the multipoles.

      - theory_cov (bool, optional) – Flag to determine if the provided covariance matrix is theoretical (True) or estimated from simulations (False). Defaults to True.

      - n_realizations (int, optional) – If the provided covariance is estimated from numerical simulations, this parameter is required, and specifies the total number of resamplings (needed for Hartlap corrections).

  clear_data()

    Clear the data.

    Sets to None the class attributes.

  is_block_diagonal(arr, nblock)
  set_kmax(kmax)

    Set the maximum mode used in the computation of the \(\chi^2\).

    Sets the class attribute corresponding to the maximum wavemode \(k_\mathrm{max}\) to be used in the calculation of the \(\chi^2\). In addition, it applies the corresponding scale cuts to both data vectors and covariance matrix.

    Parameters:

      kmax (float or list) – Maximum wavemode \(k_\mathrm{max}\) for the individual multipoles. If a float is provided, \(k_\mathrm{max}\) is assumed to be the same for all the multipoles selected by the user. On the contrary, each entry of the list object is specific for a given multipole.

  AHfactor(nbins)

    Compute corrections to the inverse covariance matrix.

    Depending on the value of the theory_cov attribute, returns the correction factor to the inverse covariance matrix (to take into account the limited number of independent realizations, in case the covariance is estimated from numerical simulations).

    Returns 1 if the class attribute theory_cov is set to True. Otherwise, returns

    \[\frac{N_\mathrm{sim}-N_\mathrm{bins}-2}{N_\mathrm{sim}-1}\,,\]

    with \(N_\mathrm{sim}\) and \(N_\mathrm{bins}\) being the number of independent realizations from which the covariance has been estimated and the total number of bins at which it is sampled, respectively (see Hartlap 2007).

    Parameters:

      nbins (int) – Number of \(k\) bins at which the power spectrum multipoles are sampled.

    Returns:

      AHfactor – Correcting factor to the inverse covariance matrix.

    Return type:

      float

  get_signal(ell, kmax=None)

    Get power spectrum multipole from data sample.

    Returns the input data power spectrum multipole of order \(\ell\) up to \(k_\mathrm{max}\).

    Parameters:

      - ell (int) – Specific multipole order \(\ell\). Can be chosen from the list [0,2,4], whose entries correspond to monopole (\(\ell=0\)), quadrupole (\(\ell=2\)) and hexadecapole (\(\ell=4\)).

      - kmax (float, optional) – Maximum wavemode \(k_\mathrm{max}\) up to which the multipole is provided. If None, the corresponding class attribute is used instead.

    Returns:

      signal_kmax – Data power spectrum multipole of order \(\ell\) up to \(k_\mathrm{max}\).

    Return type:

      numpy.ndarray

  get_std(ell, kmax=None)

    Get standard deviation of power spectrum multipole from sample.

    Returns the standard deviation of the input data power spectrum multipole of order \(\ell\) up to \(k_\mathrm{max}\).

    Parameters:

      - ell (int) – Specific multipole order \(\ell\). Can be chosen from the list [0,2,4], whose entries correspond to monopole (\(\ell=0\)), quadrupole (\(\ell=2\)) and hexadecapole (\(\ell=4\)).

      - kmax (float, optional) – Maximum wavemode \(k_\mathrm{max}\) up to which the standard deviation is provided. If None, the corresponding class attribute is used instead.

    Returns:

      std_kmax – Standard deviation of the data power spectrum multipole of order \(\ell\) up to \(k_\mathrm{max}\).

    Return type:

      numpy.ndarray

# tables

Tables module.

class comet.tables.Tables(params)

  Bases: `object`

  Class for handling the tables of the emulator.

  It handles both the training and validation sets, in the form of tables containing the different contributions to \(P_\mathrm{gg}(k,\mu)\). Provides routine to convert the raw tables into their transformed versions, which span a shorter dynamical range (to increase the accuracy of the emulator), to train the emulator, and to transform back the emulator predictions in the original metric.

  Class constructor.

  Parameters:

    params (list) – List of parameters used to train the emulator.

  set_param_ranges(ranges)

    Set ranges for the parameters of the emulator.

    Sets the internal class attribute defining the prior for the parameters of the emulator.

    Parameters:

      ranges (dict) – Dictionary containing the parameter ranges. Keys correspond to the name of the parameters, while values are list with two entries, which correspond to the minimum and maximum value of the parameter.

  assign_samples(samples_hdu)

    Read parameter sample from HDU object.

    Reads parameter sample from a Header Data Unit object, and stores it as class attribute. If the sample is meant for validation, determines the parameters from the header of the HDU object, otherwise uses the parameters defined as class attributes.

    Parameters:

      samples_hdu (astropy.io.fits.BinTableHDU) – Header Data Unit containing the parameter sample.

  assign_table(table_hdu, nk, nkloop)

    Read model table from HDU object.

    Reads a model table from a Header Data Unit object, and stores it as class attribute. If the sample is a training one, additionally calls the routine to convert the model table into its transformed version.

    Parameters:

      - table_hdu (astropy.io.fits.BinTableHDU) – Header Data Unit containing the model table.

      - nk (int) – Number of \(k\) bins of the table.

      - nkloop (int) – Number of \(k\) bins of the table corresponding to the loop predictions.

  get_flip_and_offset(table)

    Compute flip and offset to rescale an input model table.

    Parameters:

      table (numpy.ndarray) – Model table containing a given term as a function of \(k\) (first index) and the different parameter sample (second index).

    Returns:

      - flip (list) – Flip value for each \(k\) entry.

      - max_offset (list) – Maximum offset for each \(k\) entry.

  transform(table, data_type)

    Rescale the dynamical range of a table for the emulation.

    Applies flip, offset, and rescales the model table. This step is performed by first taking the logarithm of the model table, and then subtracting its mean and dividing by its standard deviation.

    Parameters:

      - table (numpy.ndarray) – Model table containing a given term as a function of \(k\) (first index) and the different parameter sample (second index).

      - data_type (str) – Type of the table that is passed as input. This is used as a keyword for the dictionary where the values of flip, offset, mean and standard deviation are stored.

    Returns:

      resc_table – Rescaled table.

    Return type:

      numpy.ndarray

  transform_inv(table, data_type)

    Rescale back the dynamical range of a table.

    Performs the inverse operations defined in the transform method. Needed to obtain predictions from the emulator in the original metric.

    Parameters:

      - table (numpy.ndarray) – Table containing a given term as a function of \(k\) (first index) and the different parameter sample (second index).

      - data_type (str) – Type of the table that is passed as input. This is used as a keyword for the dictionary where the values of flip, offset, mean and standard deviation are stored.

    Returns:

      resc_table – Rescaled table.

    Return type:

      numpy.ndarray

  transform_emulator_data(data_type=None)

    Rescale class attribute tables.

    Transforms the class attribute model tables from the original metric into the emulator one.

    Parameters:

      data_type (str or list, optional) – Types of the tables which have to be rescaled. If None, trasform the full set of model tables. Defaults to None.