boltzmann_code#

class cosmicjellyfish.cosmology.cosmology.boltzmann_code(cosmopars, code='camb', *, configuration=None)[source]#

Bases: object

set_cosmicfish_defaults()[source]#

Fill up default values in the cosmopars dictionary if the values are not found.

This method sets default values for various cosmological parameters if they are not already present in the cosmopars dictionary.

static print_cosmo_params(cosmopars, feedback=1, text='---Cosmo pars---')[source]#

Print cosmological parameters.

Parameters:
  • cosmopars (dict) – Dictionary of cosmological parameters to print.

  • feedback (int, optional) – Feedback level determining whether to print (default is 1).

  • text (str, optional) – Header text for the parameter list (default is “—Cosmo pars—“).

static f_deriv(D_growth_zk, z_array, k_array, k_fix=False, fixed_k=0.001)[source]#

Calculate the growth rate f(z,k).

Parameters:
  • D_growth_zk (callable) – Function that returns the growth factor D(z,k).

  • z_array (array_like) – Array of redshift values.

  • k_array (array_like) – Array of wavenumbers.

  • k_fix (bool, optional) – If True, use a fixed k value (default is False).

  • fixed_k (float, optional) – Fixed k value to use if k_fix is True (default is 1e-3).

Returns:

Growth rate f(z,k) and the corresponding z array.

Return type:

tuple

static compute_sigma8(z_range, pk_interpolator, h_value, k_range)[source]#

Calculate sigma8 over a range of redshifts using a given power spectrum interpolator.

This function computes sigma8, which is the RMS matter fluctuation in spheres of 8 h^-1 Mpc radius, for a range of redshifts. It uses a provided power spectrum interpolator to perform the calculation.

Parameters:
  • z_range (numpy.ndarray) – Array of redshift values at which to calculate sigma8.

  • pk_interpolator (callable) – A function that takes (z, k) as arguments and returns the power spectrum P(k,z). It should be able to handle array inputs for both z and k.

Returns:

A 1-D interpolation function sigma8(z) that can be used to obtain sigma8 values for any redshift within the input range.

Return type:

scipy.interpolate.UnivariateSpline

camb_setparams(cosmopars, camb)[source]#

Set the parameters for CAMB computation.

Parameters:
  • cosmopars (dict) – Dictionary containing the cosmological parameters.

  • camb (module) – The CAMB module.

Notes

This method sets up CAMB parameters and prepares for power spectrum computation.

changebasis_camb(cosmopars, camb)[source]#

Convert cosmological parameters to CAMB format.

Parameters:
  • cosmopars (dict) – Dictionary of cosmological parameters.

  • camb (module) – The CAMB module.

Returns:

Dictionary of CAMB-formatted cosmological parameters.

Return type:

dict

rescale_LP(cambpars, camb, insigma8)[source]#

Rescale As to match a target sigma8 value.

Parameters:
  • cambpars (dict) – CAMB parameters.

  • camb (module) – The CAMB module.

  • insigma8 (float) – Target sigma8 value.

Returns:

Rescaled As value.

Return type:

float

camb_results(camb)[source]#

Compute and store CAMB results.

Parameters:

camb (module) – The CAMB module.

Notes

This method computes various cosmological quantities using CAMB and stores them in the results attribute.

class_setparams(cosmopars)[source]#

Set the parameters for CLASS computation.

Parameters:

cosmopars (dict) – Dictionary containing the cosmological parameters.

Notes

This method sets up CLASS parameters and prepares for power spectrum computation.

changebasis_class(cosmopars)[source]#

Convert cosmological parameters to CLASS format.

Parameters:

cosmopars (dict) – Dictionary of cosmological parameters.

Returns:

Dictionary of CLASS-formatted cosmological parameters.

Return type:

dict

class_results(Class)[source]#

Compute and store CLASS results.

Parameters:

Class (class) – The CLASS class.

Notes

This method computes various cosmological quantities using CLASS and stores them in the results attribute.

changebasis_symb(cosmopars)[source]#

Convert and adjust cosmological parameters for symbolic computation.

This method takes the input cosmological parameters and converts them to the format required for symbolic computation. It handles unit conversions, derives some parameters, and ensures consistency between different parameterizations (e.g., sigma8 and As).

Parameters:

cosmopars (dict) – Dictionary containing the input cosmological parameters.

Returns:

A new dictionary with the converted and adjusted parameters suitable for symbolic computation.

Return type:

dict

Raises:
  • ValueError – If there’s an issue with the sigma8 to As conversion or vice versa.

  • KeyError – If required parameters are missing from the input.

Notes

  • The method performs conversions between h and H0, ombh2 and Omegab, and handles various representations of the primordial power spectrum amplitude (As, sigma8).

  • Debug information is printed if the upr.debug flag is set.

symbolic_setparams()[source]#

Set up parameters for symbolic computation.

Notes

This method prepares the cosmological parameters and numerical settings for symbolic power spectrum computation.

Raises:

ValueError – If the cosmological model is not supported by the symbolic code.

symbolic_results()[source]#

Compute and store results using symbolic computation.

Returns:

Namespace containing the computed cosmological quantities.

Return type:

types.SimpleNamespace

Notes

This method computes various cosmological quantities using symbolic computation and stores them in the results attribute.