News


angular diameter distance versus redshift and Omega_M

CosmoloPy

a cosmology package for Python.
Features | Download and Install | Usage | Documentation | Contribute | Status | Acknowledgment | Authors | Other Resources

Features

CosmoloPy is built on and designed for use with NumPy and SciPy.

Capabilities include:

cosmolopy.density
Various cosmological densities.
cosmolopy.distance
Various cosmological distance measures.
cosmolopy.luminosityfunction
Galaxy luminosity functions (Schechter functions).
cosmolopy.magnitudes
Conversion in and out of the AB magnitude system.
cosmolopy.parameters
Pre-defined sets of cosmological parameters (e.g. from WMAP).
cosmolopy.perturbation
Perturbation theory and the power spectrum.
cosmolopy.reionization
The reionization of the IGM.

Download and Install

Email the group with any questions about downloading and installation.

The easiest way to download and install CosmoloPy is to use easy_install or pip.

Install with pip or easy_install (recommended)

Latest release

You can install the latest release from PyPI by running:

$ easy_install CosmoloPy
or
$ pip install CosmoloPy
or download the source package manually from PyPI, unpack it, and run
$ python setup.py install

If you have trouble compiling from source, it's probably the EH.power module (everything else is pure python). You can install without it by running:

$ sudo python setup_alt.py install

Download with git clone

If you need bleeding-edge features or want to help with development, you can clone the CosmoloPy project (latest development version) with Git by running:

$ git clone git://github.com/roban/CosmoloPy
or view the source code on GitHub: roban/CosmoloPy

Download as a tar or zip bundle

You can download the source package of the release version from PyPI, or you also can download the development version of the package from GitHub in a zip or tar file.

Installation from source

If you've downloaded or cloned the source package (i.e., not using easy_install or pip):

$ python setup.py build
$ python setup.py nosetests
$ sudo python setup.py install

Documentation

Email the group with any questions not answered by the documentation.

The API documentation is generated from the docstrings with Epydoc.

The Module Tree gives an overview of the organization and capabilities of the package.

The source code is fairly well-commented, and should serve as the ultimate reference. See "source code" links in the API docs or view the source on GitHub.

Usage

Functions take cosmological parameters (which can be numpy arrays) as keywords, and ignore any extra keywords. This means you can make a dictionary of all of your cosmological parameters and pass it to any function using the ** syntax.

>>> import cosmolopy.distance as cd
>>> cosmo = {'omega_M_0':0.3, 'omega_lambda_0':0.7, 'omega_k_0':0.0, 'h':0.72}
>>> d_co = cd.comoving_distance(6., **cosmo)
>>> print "Comoving distance to z=6 is %.1f Mpc" % (d_co)
Comoving distance to z=6 is 8017.8 Mpc

The cosmolopy package also defines some convenient shortcuts, including a fiducial cosmology (currently the WMAP7+BAO+H0 mean), so you can just do this:

>>> from cosmolopy import *
>>> d_a = cd.angular_diameter_distance(6, **fidcosmo)
>>> print "Angluar-diameter distance to z=6 is %.1f Mpc" % (d_a)
Angluar-diameter distance to z=6 is 1209.9 Mpc
>>> d_light = cd.light_travel_distance(6, **fidcosmo)
>>> print "Light-travel distance to z=6 is %.1f Mpc" % (d_light)
Light-travel distance to z=6 is 3922.9 Mpc

Calculate the mass of a halo with Virial temperature of 10^4 kelvin, then verify the Virial temperature for a halo of that mass:

>>> import cosmolopy.perturbation as cp
>>> cosmo = {'omega_M_0' : 0.27, 
... 'omega_lambda_0' : 1-0.27, 
... 'omega_b_0' : 0.045, 
... 'omega_n_0' : 0.0,
... 'N_nu' : 0,
... 'h' : 0.72,
... 'n' : 1.0,
... 'sigma_8' : 0.9
... } 
>>> mass = cp.virial_mass(1e4, 6.0, **cosmo)
>>> temp = cp.virial_temp(mass, 6.0, **cosmo)
>>> print "Mass = %.3g M_sun" % mass
Mass = 1.68e+08 M_sun
>>> print round(temp, 4)
10000.0

Calculate the critical and matter densities:

>>> from cosmolopy import *
>>> 'rho_crit=%.3g Msun/Mpc^3, rho_0=%.3g Msun/Mpc^3' % cden.cosmo_densities(**fidcosmo)
'rho_crit=1.38e+11 Msun/Mpc^3, rho_0=3.75e+10 Msun/Mpc^3'

Look in the tests/ and examples/ directories for more examples.

propper motion distance vs. redshift and Omega_M

Contribute

The best way to contribute to the development of CosmoloPy is to use the code and provide feedback, request new features, or add features yourself.

Please join the developer discussion group and help turn CosmoloPy into a comprehensive community-maintained package of basic cosmology routines. Whether you plan to be a casual user or frequent contributor, this is the place to introduce yourself and discuss the future of the package.

Status

CosmoloPy is under active development, but is quite usable.

Feel free to join the discussion group and ask about the status of the routines you are interested in using, if you are curious.

Acknowledgment

Please consider including the URL of this page (http://roban.github.com/CosmoloPy/) in work benefiting from CosmoloPy. The use of CosmoloPy in general does not require any acknowledgment, but it is nice as a courtesy to the authors and as a service to others who might benefit from finding out about the package.

If you use any of the routines that make use of power spectrum calculations, please cite

Eisenstein, D. J., & Hu, W. 1999, ApJ, 511, 5 [1999ApJ...511....5E; astro-ph/9710252]
as the source of the matter power spectrum.

Authors

Roban Hultman Kramer (roban@astro.columbia.edu)

Please consider contributing to this project. Introduce yourself on the CosmoloPy developer discussion group.

Other resources

See the AstroPython resources page for a nice up-to-date list of python astronomy resources.

I've also made a list of some other Python cosmology software that I've come across.