Calculate useful values for a given cosmology. This module uses code adapted from (James Schombert) which is a Python version of the Cosmology Calculator (Ned Wright).

The following values are calculated:

Name Value Units
z Input redshift  
H0 Hubble constant  
WR Omega(radiation)  
WK Omega curvaturve = 1-Omega(total)  
WM Omega matter  
WV Omega vacuum  
DTT Time from z to now Gyr
age Age of Universe Gyr
zage Age of Universe at redshift z Gyr
DCMR Comoving radial distance Gyr Mpc cm
VCM Comoving volume within redshift Gpc3
DA Angular size distance Gyr Mpc cm
DL Luminosity distance Gyr Mpc cm
PS Plate scale - distance per arcsec kpc cm
Copyright:Smithsonian Astrophysical Observatory (2009)
Author:Tom Aldcroft (


From the unix command line:

% --help                        # Print help
% 2.5                           # All values for z=2.5
% 10 --H0=50 --WM=0.2 --WV=0.5  # Arbitrary cosmology
% --H0 75 1.25 DA_cm DL_cm      # Ang. size and lum. distance

Within Python:

% python
>>> from cosmocalc import cosmocalc

>>> ccvals = cosmocalc(3.2, H0=71)
>>> print ccvals['DL_cm'], ccvals['age_Gyr']
8.62139764564e+28 13.6653103344

>>> redshifts = [0.5, 1.0, 1.5]
>>> angdists = [cosmocalc(z)['DA_Mpc'] for z in redshifts]
>>> print angdists
[1254.4772859453024, 1658.5477822022472, 1761.3880061524251]

Download and Installation

The full cosmocalc package is available in the downloads directory as cosmocalc-<version>.tar.gz.

The first step is to untar the package tarball and change into the source directory:

tar zxvf cosmocalc-<version>.tar.gz
cd cosmocalc-<version>

There are three methods for installing. Choose ONE of the three.


The very simplest installation strategy is to just leave the module files in the source directory and set the PYTHONPATH environment variable to point to the source directory:


This method is fine in the short term but you always have to make sure PYTHONPATH is set appropriately (perhaps in your ~/.cshrc file). And if you start doing much with Python you will have PYTHONPATH conflicts and things will get messy.


If you cannot write into the system python library directory then do the following. These commands create a python library in your home directory and installs the cosmocalc module there. You could of course choose another directory instead of $HOME as the root of your python library.

mkdir -p $HOME/lib/python
python install --home=$HOME
setenv PYTHONPATH $HOME/lib/python

Although you still have to set PYTHONPATH this method allows you to install other Python packages to the same library path. In this way you can make a local repository of packages.


If you have write access to the system python library directory you can just install there:

python install

This puts the new module straight in to the python library so it will always be available. You do NOT need to set PYTHONPATH.


cosmocalc.cosmocalc(z, H0=71, WM=0.27000000000000002, WV=None)

Calculate useful values for the supplied cosmology.

This routine returns a dictionary of values in the form <name>: <value>, where the values are supplied in “natural” units for cosmology, e.g. 1/H0. In addition various useful unit conversions are done and stored in the dictionary as <name>_<unit>: <value>. E.g. angular size distance:

'DA': 0.38250549415474988,
'DA_Gyr': 5.2678010166833023,
'DA_Mpc': 1615.1022857909447,
'DA_cm': 4.9836849147807571e+27


>>> from cosmocalc import cosmocalc
>>> from pprint import pprint
>>> pprint(cosmocalc(3, H0=75, WM=.25))
{'DA': 0.39103776375786625,
 'DA_Gyr': 5.0980896720325548,
 'DA_Mpc': 1563.0689649039205,
 'DA_cm': 4.8231268630387788e+27,
 'DCMR': 1.564151055031465,
 'DCMR_Gyr': 20.392358688130219,
 'DCMR_Mpc': 6252.2758596156818,
 'DCMR_cm': 1.9292507452155115e+28,
 'DL': 6.25660422012586,
 'DL_Gyr': 81.569434752520877,
 'DL_Mpc': 25009.103438462727,
 'DL_cm': 7.717002980862046e+28,
 'DTT': 0.84826379084317027,
 'DTT_Gyr': 11.059097795819358,
 'H0': 75,
 'PS_cm': 2.3383178917293232e+22,
 'PS_kpc': 7.5779721961095019,
 'VCM': 1.2756009121294902,
 'VCM_Gpc3': 1023.7714254161302,
 'WK': 0.0,
 'WM': 0.25,
 'WR': 7.4044444444444448e-05,
 'WV': 0.74992595555555552,
 'age': 1.0133755371756261,
 'age_Gyr': 13.211714670004362,
 'z': 3,
 'zage': 0.16511174633245579,
 'zage_Gyr': 2.1526168741850036}
  • z – redshift
  • H0 – Hubble constant (default = 71)
  • WM – Omega matter (default = 0.27)
  • WV – Omega vacuum (default = 1.0 - WM - 0.4165/(H0*H0))
Return type:

dictionary of cosmology values (name_unit = value)

cosmocalc.get_options() [options] redshift [name_unit [name_unit2 ...]]

Allowed name_unit values:

DA DA_Gyr DA_Mpc DA_cm
DL DL_Gyr DL_Mpc DL_cm
PS_kpc PS_cm
age age_Gyr
zage zage_Gyr

If no name_unit values are supplied then all the above will be printed.

Table Of Contents

This Page