rubix.cosmology package#
Submodules#
rubix.cosmology.base module#
- class rubix.cosmology.base.BaseCosmology(Om0: float, w0: float, wa: float, h: float)[source]#
Bases:
Module
Class to handle cosmological calculations.
The methods in this class are mainly taken from ArgonneCPAC/dsps. Here they are wrapped in a class to be used in JAX.
Once initialized with the cosmological parameters, the class can be used to calculate various cosmological quantities.
- Parameters:
Om0 (float) – The present day matter density.
w0 (float) – The present day dark energy equation of state.
wa (float) – The dark energy equation of state parameter.
h (float) – The Hubble constant.
- Return type:
A Cosmology instance.
Example
>>> # Create Planck15 cosmology >>> cosmo = Cosmology(0.3089, -1.0, 0.0, 0.6774)
- age_at_z(redshift: Float[Array, '...'] | float) Float[Array, '...'] [source]#
The function calculates the age of the universe at a given redshift.
- Parameters:
redshift (float) – The redshift.
- Returns:
The age of the universe at the redshift (float).
Example
>>> from rubix.cosmology import PLANCK15 as cosmo >>> # Calculate the age of the universe at redshift 0.5 >>> cosmo.age_at_z(0.5)
- age_at_z0() Float[Array, '...'] [source]#
The function calculates the age of the universe at redshift 0.
- Returns:
The age of the universe at redshift 0 (float).
Example
>>> from rubix.cosmology import PLANCK15 as cosmo >>> # Calculate the age of the universe at redshift 0 >>> cosmo.age_at_z0()
- angular_diameter_distance_to_z(redshift: Float[Array, '...'] | float) Float[Array, '...'] [source]#
The function calculates the angular diameter distance to a given redshift.
- Parameters:
redshift (float) – The redshift.
- Returns:
The angular diameter distance to the redshift (float).
Example
>>> from rubix.cosmology import PLANCK15 as cosmo >>> # Calculate the angular diameter distance to redshift 0.5 >>> cosmo.angular_diameter_distance_to_z(0.5)
- angular_scale(z: Float[Array, '...'] | float) Float[Array, '...'] [source]#
Angular scale in kpc/arcsec at redshift z.
- Parameters:
z (float) – Redshift
- Returns:
Angular scale in kpc/arcsec at redshift z (float).
Example
>>> from rubix.cosmology import PLANCK15 as cosmo >>> # Calculate the angular scale at redshift 0.5 >>> cosmo.angular_scale(0.5)
- comoving_distance_to_z(redshift: Float[Array, '...'] | float) Float[Array, '...'] [source]#
The function calculates the comoving distance to a given redshift.
- Parameters:
redshift (float) – The redshift.
- Returns:
The comoving distance to a given redshift (float).
Example
>>> from rubix.cosmology import PLANCK15 as cosmo >>> # Calculate the comoving distance to redshift 0.5 >>> cosmo.comoving_distance_to_z(0.5)
- distance_modulus_to_z(redshift: Float[Array, '...'] | float) Float[Array, '...'] [source]#
The function calculates the distance modulus to a given redshift.
- Parameters:
redshift (float) – The redshift.
- Returns:
The distance modulus to the redshift (float).
Example
>>> from rubix.cosmology import PLANCK15 as cosmo >>> # Calculate the distance modulus to redshift 0.5 >>> cosmo.distance_modulus_to_z(0.5)
- lookback_to_z(redshift: Float[Array, '...'] | float) Float[Array, '...'] [source]#
The function calculates the lookback time to a given redshift.
- Parameters:
redshift (float) – The redshift.
- Returns:
The lookback time to the redshift (float).
Example
>>> from rubix.cosmology import PLANCK15 as cosmo >>> # Calculate the lookback time to redshift 0.5 >>> cosmo.lookback_to_z(0.5)
- luminosity_distance_to_z(redshift: Float[Array, '...'] | float) Float[Array, '...'] [source]#
The function calculates the luminosity distance to a given redshift.
- Parameters:
redshift (float) – The redshift.
- Returns:
The luminosity distance to the redshift (float).
Example
>>> from rubix.cosmology import PLANCK15 as cosmo >>> # Calculate the luminosity distance to redshift 0.5 >>> cosmo.luminosity_distance_to_z(0.5)
- scale_factor_to_redshift(a: Float[Array, '...'] | float) Float[Array, '...'] [source]#
The function converts the scale factor to redshift.
- Parameters:
a (float) – The scale factor.
- Returns:
The redshift (float).
Example
>>> from rubix.cosmology import PLANCK15 as cosmo >>> # Convert scale factor 0.5 to redshift >>> cosmo.scale_factor_to_redshift(jnp.array(0.5))
rubix.cosmology.utils module#
- rubix.cosmology.utils.trapz(xarr: Array | Float[Array, 'n'], yarr: Array | Float[Array, 'n']) Array [source]#
The function performs the trapezoidal integration using the
_cumtrapz_scan_func
helper function.- Parameters:
xarr (ndarray) – The x-coordinates of the data points in shape (n, ).
yarr (ndarray) – The y-coordinates of the data points in shape (n, ).
- Returns:
The result of the trapezoidal integration.
Example
>>> from rubix.cosmology.utils import trapz >>> import jax.numpy as jnp
>>> x = jnp.array([0, 1, 2, 3]) >>> y = jnp.array([0, 1, 4, 9]) >>> print(trapz(x, y))