cosmicfishpie.cosmology package
Submodules
cosmicfishpie.cosmology.cosmology module
COSMOLOGY.
This module contains useful cosmological functions.
- class cosmicfishpie.cosmology.cosmology.boltzmann_code(cosmopars, code='camb')[source]
Bases:
object- 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.
- 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_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:
- 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.
- 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.
- 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.
- 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
- 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:
- static print_cosmo_params(cosmopars, feedback=1, text='---Cosmo pars---')[source]
Print cosmological parameters.
- 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.
- symbolic_results()[source]
Compute and store results using symbolic computation.
- Returns:
Namespace containing the computed cosmological quantities.
- Return type:
Notes
This method computes various cosmological quantities using symbolic computation and stores them in the results attribute.
- 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.
- hardcoded_Neff = 3.044
- hardcoded_mnu_massive_min = 0.001
- hardcoded_neutrino_mass_fac = 94.07
- class cosmicfishpie.cosmology.cosmology.cosmo_functions(cosmopars, input=None)[source]
Bases:
object- Omegam_of_z(z)[source]
Omega matter fraction as a function of redshift
- Parameters:
z (
float) – redshift- Returns:
Omega matter (total) at the redshifts of the input redshift z
- Return type:
Note
Assumes standard matter evolution Implements the following equation:
\[Omega_m(z) = Omega_{m,0}*(1+z)^3 / E^2(z)\]
- Pcb(z, k, nonlinear=False)[source]
Compute the power spectrum of the clustering matter species (CB) at a given redshift and wavenumber.
- Parameters:
self – An instance of the current class.
z – The redshift at which to compute the CB power spectrum.
k – The wavenumber at which to compute the CB power spectrum in 1/Mpc.
nonlinear (
bool, optional) – If True, include nonlinear effects in the computation. Default is False.
- Returns:
The value of the CB power spectrum at the given redshift and wavenumber.
- Pmm(z, k, nonlinear=False)[source]
Compute the power spectrum of the total matter species (MM) at a given redshift and wavenumber.
- Parameters:
self – An instance of the current class.
z – The redshift at which to compute the MM power spectrum.
k – The wavenumber at which to compute the MM power spectrum in 1/Mpc.
nonlinear (
bool, optional) – If True, include nonlinear effects in the computation. Default is False.
- Returns:
The value of the MM power spectrum at the given redshift and wavenumber.
- Return type:
- f_growthrate(z, k=None, gamma=False, tracer='matter')[source]
Growth rate in LCDM gamma approximation
- Parameters:
z (
float) – redshift- Returns:
Growth rate values at the redshifts of the input redshift, using self.gamma as gamma value.
- Return type:
Note
Implements the following equation:
\[f(z) = Omega_m(z)^{\gamma}\]
- fsigma8_of_z(z, k=None, gamma=False, tracer='matter')[source]
Growth rate in LCDM gamma approximation
- Parameters:
z (
float) – redshift- Returns:
Growth rate values at the redshifts of the input redshift, using self.gamma as gamma value.
- Return type:
Note
Implements the following equation:
\[f(z) = Omega_m(z)^{\gamma}\]
- matpow(z, k, nonlinear=False, tracer='matter')[source]
Calculates the power spectrum of a given tracer quantity at a specific redshift and wavenumber.
- Parameters:
z (
float) – The redshift of interest.k (
array_like) – An array of wavenumbers at which to compute the power spectrum. These must be in units of 1/Mpc and should be sorted in increasing order.nonlinear (
bool, optional) – A boolean indicating whether or not to include nonlinear corrections to the matter power spectrum. The default value is False.tracer (
str, optional) – A string indicating which trace quantity to use for computing the power spectrum. If this argument is “matter” or anything other than “clustering”, the power spectrum functions Pmm will be used to compute the power spectrum. If the argument is “clustering”, the power spectrum function Pcb will be used instead. The default value is “matter”.
- Returns:
Array containing the calculated power spectrum values.
- Return type:
np.ndarray
Warning
If tracer is not “matter” or “clustering”, a warning message is printed to the console saying the provided tracer was not recognized and the function defaults to using Pmm to calculate the power spectrum of matter.
- nonwiggle_pow(z, k, nonlinear=False, tracer='matter')[source]
Calculate the power spectrum at a specific redshift and wavenumber, after smoothing to remove baryonic acoustic oscillations (BAO).
- Parameters:
z – The redshift of interest.
k – An array of wavenumbers at which to compute the power spectrum. Must be in units of Mpc^-1/h. Should be sorted in increasing order.
nonlinear (default:
False) – Whether to include nonlinear corrections to the matter power spectrum. Default is False.tracer (default:
'matter') – Which perturbations to use for computing the power spectrum. Options are ‘matter’ or ‘clustering’. Default is ‘matter’.
- Returns:
An array of power spectrum values corresponding to the input wavenumbers. Units are (Mpc/h)^3.
Note
This function computes the power spectrum of a given tracer quantity at a specific redshift, using the matter power spectrum function matpow. It then applies a Savitzky-Golay filter to smooth out the BAO features in the power spectrum. This is done by first taking the natural logarithm of the power spectrum values at a set of logarithmic wavenumbers spanning from kmin_loc to kmax_loc. The smoothed power spectrum is then returned on a linear (not logarithmic) grid of wavenumbers given by the input array k.
- sigma8_of_z(z, tracer='matter')[source]
sigma_8
- Parameters:
z (
float) – redshifttracer (
String) – either ‘matter’ if you want sigma_8 calculated from the total matter power spectrum or ‘clustering’ if you want it from the Powerspectrum with massive neutrinos substracted
- Returns:
The Variance of the matter perturbation smoothed over a scale of 8 Mpc/h
- Return type:
- c = 299792.458
- class cosmicfishpie.cosmology.cosmology.external_input(cosmopars, fiducialcosmopars={}, external={}, extra_settings={})[source]
Bases:
object- calculate_interpol_results(parameter_string='fiducial_eps_0')[source]
Calculate interpolated results from the input data.
- Parameters:
parameter_string (
str, optional) – String representing the parameter set to use (default is “fiducial_eps_0”).
cosmicfishpie.cosmology.nuisance module
Nuisance
This module contains nuisance parameter functions.
- class cosmicfishpie.cosmology.nuisance.Nuisance(configuration=None, spectrobiasparams=None, spectrononlinearpars=None, IMbiasparams=None)[source]
Bases:
object- IA(IApars, cosmo)[source]
Intrinsic Alignment
- Parameters:
z – float redshift
- Returns:
float: Value of IA window at redshift z
- Notes:
Implements the following equation:
\[W_i^{IA} = -\frac{\mathcal{A}_{\rm IA}C_{\rm IA}\Omega_m\mathcal{F}_{\rm IA}}{D(z)} \frac{n_i(z)}{\bar{n}}\frac{H(z)}{c}\]
- IM_THI_noise()[source]
Create interpolation function for HI intensity mapping system noise temperature.
Creates a spline interpolation of the system noise temperature (T_sys) as a function of redshift for HI intensity mapping observations. The noise temperature data is read from the survey specifications.
- Returns:
Interpolation function that takes redshift as input and returns the corresponding system noise temperature in Kelvin.
- Return type:
UnivariateSpline
Notes
- The survey specifications must contain a ‘THI_sys_noise’ dictionary with:
- ‘z_vals_THI’array-like
Redshift values where noise temperature is defined
- ‘THI_sys_noise’array-like
System noise temperature values in Kelvin corresponding to each redshift
- IM_bias_fitting(z)[source]
IM 21cm HI bias function from http://arxiv.org/abs/2006.05996
- gcph_bias(biaspars, ibin=1)[source]
Galaxy bias
- Parameters:
z (
array) – redshift- Returns:
Value galaxy bias at redshift z
- Return type:
- gcsp_bias_interp()[source]
Galaxy bias for the galaxies used in spectroscopic Galaxy Clustering
- Returns:
Interpolating functionofbias for the redshift bins given
Note
Reads from file and interpolates for a given survey
- luminosity_ratio()[source]
Luminosity ratio function used for Intrinsic Alignment eNLA model.
This function reads and interpolates the luminosity ratio <L(z)>/L*(z) from a file. The ratio is used in the extended nonlinear alignment (eNLA) model for intrinsic alignments.
- Parameters:
None
- Returns:
An interpolation function that takes redshift z as input and returns the luminosity ratio. If the luminosity ratio file cannot be loaded, returns a function that always returns 1.0.
- Return type:
callable
Notes
Attempts to read the luminosity ratio from ‘lumratio_file.dat’ in the specs directory
The file should contain two columns: redshift and luminosity ratio values
- The luminosity ratio represents <L(z)>/L*(z), where:
<L(z)> is the mean luminosity at redshift z
L*(z) is the characteristic luminosity at redshift z
Uses linear interpolation between data points