pynbody.analysis.cosmology.age#
- pynbody.analysis.cosmology.age(f, z=None, unit='Gyr')[source]#
Calculate the age of the universe in the snapshot f by integrating the Friedmann equation.
The output is given in the specified units. If a redshift z is specified, it is used in place of the redshift in the output f.
If a long array of redshifts is provided, interpolation is used to speed up the calculation. Specifically, the number of interpolation points is controlled by the configuration parameter ‘cosmo-interpolation-points’.
- Parameters:
f (SimSnap) – The snapshot from which to obtain the cosmological parameters.
z (float, list, or np.ndarray, optional) – The redshift(s) at which to calculate the age of the universe. If None, the redshift of the snapshot is used.
unit (str, optional) – The units in which to return the age of the universe. Default is ‘Gyr’.
- Returns:
The age of the universe at the specified redshift(s).
- Return type:
SimArray | float