pynbody.analysis.cosmology.rho_crit#
- pynbody.analysis.cosmology.rho_crit(f, z=None, unit=None)[source]#
Calculate the critical density of the universe in the snapshot f.
Warning
You can get slightly confusing results if your simulation is in comoving units and you specify a different redshift z. Specifically, the physical density for the redshift you specify is calulated, but expressed as a comoving density at the redshift of the snapshot. This is intentional, but can be surprising.
- Parameters:
f (SimSnap) – The snapshot from which to obtain the cosmological parameters.
z (float, optional) – The redshift at which to calculate the critical density. If None, the redshift of the snapshot is used.
unit (str, optional) – The units in which to return the critical density. If None, the returned density will be in the units of f[“mass”].units/f[“pos”].units**3. If that unit cannot be calculated, the returned units are Msol kpc^-3 comoving.
- Returns:
The critical density of the universe at the specified redshift.
- Return type:
float