<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Cosmological Calculations (astropy.cosmology) — Astropy v0.2.4</title> <link rel="stylesheet" href="../_static/bootstrap-astropy.css" type="text/css" /> <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> <script type="text/javascript"> var DOCUMENTATION_OPTIONS = { URL_ROOT: '../', VERSION: '0.2.4', COLLAPSE_INDEX: false, FILE_SUFFIX: '.html', HAS_SOURCE: true }; </script> <script type="text/javascript" src="../_static/jquery.js"></script> <script type="text/javascript" src="../_static/underscore.js"></script> <script type="text/javascript" src="../_static/doctools.js"></script> <script type="text/javascript" src="../_static/sidebar.js"></script> <link rel="shortcut icon" href="../_static/astropy_logo.ico"/> <link rel="top" title="Astropy v0.2.4" href="../index.html" /> <link rel="next" title="H" href="../_generated/astropy.cosmology.funcs.H.html" /> <link rel="prev" title="write_table_hdf5" href="../_generated/astropy.io.misc.hdf5.write_table_hdf5.html" /> </head> <body> <div class="topbar"> <a class="brand" title="Documentation Home" href="../index.html"></a> <ul> <li><a class="homelink" title="AstroPy Homepage" href="http://www.astropy.org"></a></li> <li><a title="General Index" href="../genindex.html">Index</a></li> <li><a title="Python Module Index" href="../py-modindex.html">Modules</a></li> <li> <form action="../search.html" method="get"> <input type="text" name="q" placeholder="Search" /> <input type="hidden" name="check_keywords" value="yes" /> <input type="hidden" name="area" value="default" /> </form> </li> </ul> </div> <div class="related"> <h3>Navigation</h3> <ul> <li class="right"> <a href="../_generated/astropy.cosmology.funcs.H.html" title="H"> next » </a> </li> <li class="right"> <a href="../_generated/astropy.io.misc.hdf5.write_table_hdf5.html" title="write_table_hdf5"> « previous </a> | </li> <li> <a href="../index.html">Astropy v0.2.4</a> » </li> <li>Cosmological Calculations (<tt class="docutils literal"><span class="pre">astropy.cosmology</span></tt>)</li> </ul> </div> <div class="document"> <div class="documentwrapper"> <div class="bodywrapper"> <div class="body"> <div class="section" id="cosmological-calculations-astropy-cosmology"> <span id="astropy-cosmology"></span><h1>Cosmological Calculations (<a class="reference internal" href="#module-astropy.cosmology" title="astropy.cosmology"><tt class="xref py py-obj docutils literal"><span class="pre">astropy.cosmology</span></tt></a>)<a class="headerlink" href="#cosmological-calculations-astropy-cosmology" title="Permalink to this headline">¶</a></h1> <div class="section" id="introduction"> <h2>Introduction<a class="headerlink" href="#introduction" title="Permalink to this headline">¶</a></h2> <p>The <a class="reference internal" href="#module-astropy.cosmology" title="astropy.cosmology"><tt class="xref py py-obj docutils literal"><span class="pre">astropy.cosmology</span></tt></a> subpackage contains classes for representing cosmologies, and utility functions for calculating commonly used quantities that depend on a cosmological model. This includes distances, ages and lookback times corresponding to a measured redshift or the transverse separation corresponding to a measured angular separation.</p> </div> <div class="section" id="getting-started"> <h2>Getting Started<a class="headerlink" href="#getting-started" title="Permalink to this headline">¶</a></h2> <p>There are many functions available to calculate cosmological quantities. They generally take a redshift as input. For example, the two cases below give you the value of the hubble constant at z=0 (i.e., <tt class="xref py py-obj docutils literal"><span class="pre">H0</span></tt>), and the number of transverse proper kpc corresponding to an arcminute at z=3:</p> <div class="highlight-python"><div class="highlight"><pre><span class="gp">>>> </span><span class="kn">from</span> <span class="nn">astropy</span> <span class="kn">import</span> <span class="n">cosmology</span> <span class="gp">>>> </span><span class="n">cosmology</span><span class="o">.</span><span class="n">H</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span> <span class="go">70.4</span> <span class="gp">>>> </span><span class="n">cosmology</span><span class="o">.</span><span class="n">kpc_proper_per_arcmin</span><span class="p">(</span><span class="mi">3</span><span class="p">)</span> <span class="go">472.8071851564037</span> </pre></div> </div> <p>All the functions available are listed in the <a class="reference internal" href="#reference-api">Reference/API</a> section. These will use the “current” cosmology to calculate the values (see <a class="reference internal" href="#the-current-cosmology">The Current Cosmology</a> section below for more details). If you haven’t set this explicitly, they will use the 7-year WMAP cosmological parameters and print a warning message.</p> <p>There are also several standard cosmologies already defined. These are objects with methods and attributes that calculate cosmological values. For example, the comoving distance in Mpc to redshift 4 using the 5-year WMAP parameters:</p> <div class="highlight-python"><div class="highlight"><pre><span class="gp">>>> </span><span class="kn">from</span> <span class="nn">astropy.cosmology</span> <span class="kn">import</span> <span class="n">WMAP5</span> <span class="gp">>>> </span><span class="n">WMAP5</span><span class="o">.</span><span class="n">comoving_distance</span><span class="p">(</span><span class="mi">4</span><span class="p">)</span> <span class="go">7329.328120760829</span> </pre></div> </div> <p>A full list of the pre-defined cosmologies is given by <tt class="xref py py-obj docutils literal"><span class="pre">cosmology.parameters.available</span></tt>.</p> <p>An important point is that the cosmological parameters of each instance are immutable – that is, if you want to change, say, <tt class="xref py py-obj docutils literal"><span class="pre">Om</span></tt>, you need to make a new instance of the class.</p> </div> <div class="section" id="using-cosmology"> <h2>Using <tt class="xref py py-obj docutils literal"><span class="pre">cosmology</span></tt><a class="headerlink" href="#using-cosmology" title="Permalink to this headline">¶</a></h2> <p>Most of the functionality is enabled by the <a class="reference internal" href="../_generated/astropy.cosmology.core.FLRW.html#astropy.cosmology.core.FLRW" title="astropy.cosmology.core.FLRW"><tt class="xref py py-obj docutils literal"><span class="pre">FLRW</span></tt></a> object. This represents a homogenous and isotropic cosmology (a cosmology characterized by the Friedmann-Lemaitre-Robertson-Walker metric, named after the people who solved Einstein’s field equation for this special case). However, you can’t work with this class directly, as you must specify a dark energy model by using one of its subclasses instead, such as <a class="reference internal" href="../_generated/astropy.cosmology.core.FlatLambdaCDM.html#astropy.cosmology.core.FlatLambdaCDM" title="astropy.cosmology.core.FlatLambdaCDM"><tt class="xref py py-obj docutils literal"><span class="pre">FlatLambdaCDM</span></tt></a>.</p> <p>You can create a new <a class="reference internal" href="../_generated/astropy.cosmology.core.FlatLambdaCDM.html#astropy.cosmology.core.FlatLambdaCDM" title="astropy.cosmology.core.FlatLambdaCDM"><tt class="xref py py-obj docutils literal"><span class="pre">FlatLambdaCDM</span></tt></a> object with arguments giving the hubble parameter and omega matter (both at z=0):</p> <div class="highlight-python"><div class="highlight"><pre><span class="gp">>>> </span><span class="kn">from</span> <span class="nn">astropy.cosmology</span> <span class="kn">import</span> <span class="n">FlatLambdaCDM</span> <span class="gp">>>> </span><span class="n">cosmo</span> <span class="o">=</span> <span class="n">FlatLambdaCDM</span><span class="p">(</span><span class="n">H0</span><span class="o">=</span><span class="mi">70</span><span class="p">,</span> <span class="n">Om0</span><span class="o">=</span><span class="mf">0.3</span><span class="p">)</span> <span class="gp">>>> </span><span class="n">cosmo</span> <span class="go">LambdaCDM(H0=70, Om0=0.3, Ode0=0.7)</span> </pre></div> </div> <p>A number of additional dark energy models are provided (described below). Note that photons and neutrinos are included in these models, so Om0 + Ode0 is not quite one.</p> <p>The pre-defined cosmologies described in the <a class="reference internal" href="#getting-started">Getting Started</a> section are instances of <a class="reference internal" href="../_generated/astropy.cosmology.core.FlatLambdaCDM.html#astropy.cosmology.core.FlatLambdaCDM" title="astropy.cosmology.core.FlatLambdaCDM"><tt class="xref py py-obj docutils literal"><span class="pre">FlatLambdaCDM</span></tt></a>, and have the same methods. So we can find the luminosity distance in Mpc to redshift 4 by:</p> <div class="highlight-python"><div class="highlight"><pre><span class="gp">>>> </span><span class="n">cosmo</span><span class="o">.</span><span class="n">luminosity_distance</span><span class="p">(</span><span class="mi">4</span><span class="p">)</span> <span class="go">35842.35374316948</span> </pre></div> </div> <p>or the age of the universe at z = 0 in Gyr:</p> <div class="highlight-python"><div class="highlight"><pre><span class="gp">>>> </span><span class="n">cosmo</span><span class="o">.</span><span class="n">age</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span> <span class="go">13.461701807287566</span> </pre></div> </div> <p>They also accept arrays of redshifts:</p> <div class="highlight-python"><div class="highlight"><pre><span class="gp">>>> </span><span class="n">cosmo</span><span class="o">.</span><span class="n">age</span><span class="p">([</span><span class="mf">0.5</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mf">1.5</span><span class="p">])</span> <span class="go">array([ 8.42128059, 5.74698062, 4.1964541 ])</span> </pre></div> </div> <p>See the <a class="reference internal" href="../_generated/astropy.cosmology.core.FLRW.html#astropy.cosmology.core.FLRW" title="astropy.cosmology.core.FLRW"><tt class="xref py py-obj docutils literal"><span class="pre">FLRW</span></tt></a> and <a class="reference internal" href="../_generated/astropy.cosmology.core.FlatLambdaCDM.html#astropy.cosmology.core.FlatLambdaCDM" title="astropy.cosmology.core.FlatLambdaCDM"><tt class="xref py py-obj docutils literal"><span class="pre">FlatLambdaCDM</span></tt></a> object docstring for all the methods and attributes available. In addition to flat Universes, non-flat varieties are supported such as <a class="reference internal" href="../_generated/astropy.cosmology.core.LambdaCDM.html#astropy.cosmology.core.LambdaCDM" title="astropy.cosmology.core.LambdaCDM"><tt class="xref py py-obj docutils literal"><span class="pre">LambdaCDM</span></tt></a>. There are also a variety of standard cosmologies with the parameters already defined:</p> <div class="highlight-python"><div class="highlight"><pre><span class="gp">>>> </span><span class="kn">from</span> <span class="nn">astropy.cosmology</span> <span class="kn">import</span> <span class="n">WMAP7</span> <span class="c"># WMAP 7-year cosmology</span> <span class="gp">>>> </span><span class="n">WMAP7</span><span class="o">.</span><span class="n">critical_density</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span> <span class="c"># critical density at z = 0 in g/cm^3</span> <span class="go">9.31000313202047e-30</span> </pre></div> </div> <div class="highlight-python"><div class="highlight"><pre><span class="gp">>>> </span><span class="kn">from</span> <span class="nn">astropy.cosmology</span> <span class="kn">import</span> <span class="n">WMAP5</span> <span class="c"># WMAP 5-year</span> <span class="gp">>>> </span><span class="n">WMAP5</span><span class="o">.</span><span class="n">H</span><span class="p">(</span><span class="mi">3</span><span class="p">)</span> <span class="c"># Hubble parameter at z = 3 in km/s/Mpc</span> <span class="go">301.71804314602889</span> </pre></div> </div> <p>You can see how the density parameters evolve with redshift as well</p> <div class="highlight-python"><div class="highlight"><pre><span class="gp">>>> </span><span class="kn">from</span> <span class="nn">astropy.cosmology</span> <span class="kn">import</span> <span class="n">WMAP7</span> <span class="c"># WMAP 7-year cosmology</span> <span class="gp">>>> </span><span class="n">WMAP7</span><span class="o">.</span><span class="n">Om</span><span class="p">([</span><span class="mi">0</span><span class="p">,</span><span class="mf">1.0</span><span class="p">,</span><span class="mf">2.0</span><span class="p">]),</span> <span class="n">WMAP7</span><span class="o">.</span><span class="n">Ode</span><span class="p">([</span><span class="mf">0.</span><span class="p">,</span><span class="mf">1.0</span><span class="p">,</span><span class="mf">2.0</span><span class="p">])</span> <span class="go">(array([ 0.272 , 0.74898525, 0.9090524 ]),</span> <span class="go"> array([ 0.72791572, 0.25055062, 0.09010261]))</span> </pre></div> </div> <p>Note that these don’t quite add up to one even though WMAP7 assumes a flat Universe because photons and neutrinos are included.</p> <p>In addition to the <a class="reference internal" href="../_generated/astropy.cosmology.core.LambdaCDM.html#astropy.cosmology.core.LambdaCDM" title="astropy.cosmology.core.LambdaCDM"><tt class="xref py py-obj docutils literal"><span class="pre">LambdaCDM</span></tt></a> object, there are convenience functions that calculate some of these quantities without needing to explicitly give a cosmology - but there are more methods available if you work directly with the cosmology object.</p> <div class="highlight-python"><div class="highlight"><pre><span class="gp">>>> </span><span class="kn">from</span> <span class="nn">astropy</span> <span class="kn">import</span> <span class="n">cosmology</span> <span class="gp">>>> </span><span class="n">cosmology</span><span class="o">.</span><span class="n">kpc_proper_per_arcmin</span><span class="p">(</span><span class="mi">3</span><span class="p">)</span> <span class="go">472.8071851564037</span> <span class="gp">>>> </span><span class="n">cosmology</span><span class="o">.</span><span class="n">arcsec_per_kpc_proper</span><span class="p">(</span><span class="mi">3</span><span class="p">)</span> <span class="go">0.12690162477152736</span> </pre></div> </div> <p>These functions will perform calculations using the “current” cosmology. This is a specific cosmology that is currently active in <tt class="xref py py-obj docutils literal"><span class="pre">astropy</span></tt> and it’s described further in the following section. They can also be explicitly given a cosmology using the <tt class="xref py py-obj docutils literal"><span class="pre">cosmo</span></tt> keyword argument. A full list of convenience functions is included below, in the <a class="reference internal" href="#reference-api">Reference/API</a> section.</p> </div> <div class="section" id="the-current-cosmology"> <h2>The Current Cosmology<a class="headerlink" href="#the-current-cosmology" title="Permalink to this headline">¶</a></h2> <p>Sometimes it’s useful for Astropy functions to assume a default cosmology so that the desired cosmology doesn’t have to be specified every time the function is called – the convenience functions described in the previous section are one example. For these cases it’s possible to specify a “current” cosmology.</p> <p>You can set the current cosmology to a pre-defined value by using the “default_cosmology” option in the <tt class="docutils literal"><span class="pre">[cosmology.core]</span></tt> section of the configuration file (see <a class="reference internal" href="../configs/index.html#astropy-config"><em>Configuration system (astropy.config)</em></a>). Alternatively, you can use the <a class="reference internal" href="../_generated/astropy.cosmology.core.set_current.html#astropy.cosmology.core.set_current" title="astropy.cosmology.core.set_current"><tt class="xref py py-obj docutils literal"><span class="pre">set_current</span></tt></a> function to set a cosmology for the current Python session.</p> <p>If you haven’t set a current cosmology using one of the methods described above, then the cosmology module will use the 7-year WMAP parameters and print a warning message letting you know this. For example, if you call a convenience function without setting the current cosmology or using the <tt class="xref py py-obj docutils literal"><span class="pre">cosmo=</span></tt> keyword you see the following message:</p> <div class="highlight-python"><div class="highlight"><pre><span class="gp">>>> </span><span class="kn">from</span> <span class="nn">astropy</span> <span class="kn">import</span> <span class="n">cosmology</span> <span class="gp">>>> </span><span class="n">cosmology</span><span class="o">.</span><span class="n">lookback_time</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span> <span class="c"># lookback time in Gyr at z=1</span> <span class="go">WARNING: No default cosmology has been specified, using 7-year WMAP.</span> <span class="go">[astropy.cosmology.core]</span> <span class="go">7.787766946</span> </pre></div> </div> <p>The 9-year WMAP and Planck 2013 cosmologies are also available</p> <div class="highlight-python"><div class="highlight"><pre><span class="gp">>>> </span><span class="kn">from</span> <span class="nn">astropy.cosmology</span> <span class="kn">import</span> <span class="n">WMAP9</span> <span class="c"># WMAP 9-year</span> <span class="gp">>>> </span><span class="n">WMAP9</span><span class="o">.</span><span class="n">lookback_time</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span> <span class="c"># lookback time in Gyr at z=2</span> <span class="go">10.442114507</span> <span class="gp">>>> </span><span class="kn">from</span> <span class="nn">astropy.cosmology</span> <span class="kn">import</span> <span class="n">Planck13</span> <span class="c"># Planck 2013</span> <span class="gp">>>> </span><span class="n">Planck13</span><span class="o">.</span><span class="n">lookback_time</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span> <span class="c"># lookback time in Gyr at z=2</span> <span class="go">10.522149614</span> </pre></div> </div> <div class="admonition note"> <p class="first admonition-title">Note</p> <p class="last">In general it’s better to use an explicit cosmology (for example <tt class="docutils literal"><span class="pre">WMAP7.H(0)</span></tt> instead of <tt class="docutils literal"><span class="pre">cosmology.H(0)</span></tt>). The motivation for this is that when you go back to use the code at a later date or share your scripts with someone else, the default cosmology may have changed. Use of the convenience functions should generally be reserved for interactive work or cases where the flexibility of quickly changing between different cosmologies is for some reason useful. Alternatively, putting (for example) <tt class="docutils literal"><span class="pre">cosmology.set_current(WMAP7)</span></tt> at the top of your code will ensure that the right cosmology is always used.</p> </div> <div class="section" id="using-cosmology-inside-astropy"> <h3>Using <tt class="xref py py-obj docutils literal"><span class="pre">cosmology</span></tt> inside Astropy<a class="headerlink" href="#using-cosmology-inside-astropy" title="Permalink to this headline">¶</a></h3> <p>If you are writing code for the <tt class="xref py py-obj docutils literal"><span class="pre">astropy</span></tt> core or an affiliated package, it is strongly recommended that you use the current cosmology through the <a class="reference internal" href="../_generated/astropy.cosmology.core.get_current.html#astropy.cosmology.core.get_current" title="astropy.cosmology.core.get_current"><tt class="xref py py-obj docutils literal"><span class="pre">get_current</span></tt></a> function. It is also recommended that you provide an override option something like the following:</p> <div class="highlight-python"><div class="highlight"><pre><span class="k">def</span> <span class="nf">myfunc</span><span class="p">(</span><span class="o">...</span><span class="p">,</span> <span class="n">cosmo</span><span class="o">=</span><span class="bp">None</span><span class="p">):</span> <span class="kn">from</span> <span class="nn">astropy.cosmology</span> <span class="kn">import</span> <span class="n">get_current</span> <span class="k">if</span> <span class="n">cosmo</span> <span class="ow">is</span> <span class="bp">None</span><span class="p">:</span> <span class="n">cosmo</span> <span class="o">=</span> <span class="n">get_current</span><span class="p">()</span> <span class="o">...</span> <span class="n">your</span> <span class="n">code</span> <span class="n">here</span> <span class="o">...</span> </pre></div> </div> <p>This ensures that all code consistently uses the current cosmology unless explicitly overridden.</p> </div> </div> <div class="section" id="specifying-a-dark-energy-model"> <h2>Specifying a dark energy model<a class="headerlink" href="#specifying-a-dark-energy-model" title="Permalink to this headline">¶</a></h2> <p>In addition to the standard <a class="reference internal" href="../_generated/astropy.cosmology.core.FlatLambdaCDM.html#astropy.cosmology.core.FlatLambdaCDM" title="astropy.cosmology.core.FlatLambdaCDM"><tt class="xref py py-obj docutils literal"><span class="pre">FlatLambdaCDM</span></tt></a> model described above, a number of additional dark energy models are provided. <a class="reference internal" href="../_generated/astropy.cosmology.core.FlatLambdaCDM.html#astropy.cosmology.core.FlatLambdaCDM" title="astropy.cosmology.core.FlatLambdaCDM"><tt class="xref py py-obj docutils literal"><span class="pre">FlatLambdaCDM</span></tt></a> and <a class="reference internal" href="../_generated/astropy.cosmology.core.FlatLambdaCDM.html#astropy.cosmology.core.FlatLambdaCDM" title="astropy.cosmology.core.FlatLambdaCDM"><tt class="xref py py-obj docutils literal"><span class="pre">FlatLambdaCDM</span></tt></a> assume that dark energy is a cosmological constant, and should be the most commonly used case. <a class="reference internal" href="../_generated/astropy.cosmology.core.wCDM.html#astropy.cosmology.core.wCDM" title="astropy.cosmology.core.wCDM"><tt class="xref py py-obj docutils literal"><span class="pre">wCDM</span></tt></a> assumes a constant dark energy equation of state parameterized by <span class="math">w_0</span>. Two forms of a variable dark energy equation of state are provided: the simple first order linear expansion <span class="math">w(z) = w_0 + w_z z</span> by <a class="reference internal" href="../_generated/astropy.cosmology.core.w0wzCDM.html#astropy.cosmology.core.w0wzCDM" title="astropy.cosmology.core.w0wzCDM"><tt class="xref py py-obj docutils literal"><span class="pre">w0wzCDM</span></tt></a>, as well as the common CPL form by <a class="reference internal" href="../_generated/astropy.cosmology.core.w0waCDM.html#astropy.cosmology.core.w0waCDM" title="astropy.cosmology.core.w0waCDM"><tt class="xref py py-obj docutils literal"><span class="pre">w0waCDM</span></tt></a>: <span class="math">w(z) = w_0 + w_a (1 - a) = w_0 + w_a z / (1 + z)</span> and its generalization to include a pivot redshift by <a class="reference internal" href="../_generated/astropy.cosmology.core.wpwaCDM.html#astropy.cosmology.core.wpwaCDM" title="astropy.cosmology.core.wpwaCDM"><tt class="xref py py-obj docutils literal"><span class="pre">wpwaCDM</span></tt></a>: <span class="math">w(z) = w_p + w_a (a_p - a)</span>.</p> <p>Users can specify their own equation of state by sub-classing <a class="reference internal" href="../_generated/astropy.cosmology.core.FLRW.html#astropy.cosmology.core.FLRW" title="astropy.cosmology.core.FLRW"><tt class="xref py py-obj docutils literal"><span class="pre">FLRW</span></tt></a>. See the provided subclasses for examples.</p> </div> <div class="section" id="relativistic-species"> <h2>Relativistic Species<a class="headerlink" href="#relativistic-species" title="Permalink to this headline">¶</a></h2> <p>The cosmology classes include the contribution to the energy density from both photons and massless neutrinos. The two parameters controlling the proporties of these species are Tcmb0 (the temperature of the CMB at z=0) and Neff, the effective number of neutrino species. Both have standard default values (2.725 and 3.04, respectively; the reason that Neff is not 3 has to do with a small bump in the neutrino energy spectrum due to electron-positron annihilation).</p> <div class="highlight-python"><div class="highlight"><pre><span class="gp">>>> </span><span class="kn">from</span> <span class="nn">astropy.cosmology</span> <span class="kn">import</span> <span class="n">WMAP7</span> <span class="c"># WMAP 7-year cosmology</span> <span class="gp">>>> </span><span class="n">z</span> <span class="o">=</span> <span class="p">[</span><span class="mi">0</span><span class="p">,</span><span class="mf">1.0</span><span class="p">,</span><span class="mf">2.0</span><span class="p">]</span> <span class="gp">>>> </span><span class="n">WMAP7</span><span class="o">.</span><span class="n">Ogamma</span><span class="p">(</span><span class="n">z</span><span class="p">),</span> <span class="n">WMAP7</span><span class="o">.</span><span class="n">Onu</span><span class="p">(</span><span class="n">z</span><span class="p">)</span> <span class="go">(array([ 4.98569503e-05, 2.74574414e-04]),</span> <span class="go"> array([ 3.44204408e-05, 1.89561782e-04]),</span> <span class="go"> array([ 8.42773911e-05, 4.64136197e-04]))</span> </pre></div> </div> <p>If you want to exclude photons and neutrinos from your calculations, simply set the CMB Temperature to 0:</p> <div class="highlight-python"><div class="highlight"><pre><span class="gp">>>> </span><span class="kn">from</span> <span class="nn">astropy.cosmology</span> <span class="kn">import</span> <span class="n">FlatLambdaCDM</span> <span class="gp">>>> </span><span class="n">cos</span> <span class="o">=</span> <span class="n">FlatLambdaCDM</span><span class="p">(</span><span class="mf">70.4</span><span class="p">,</span> <span class="mf">0.272</span><span class="p">,</span> <span class="n">Tcmb0</span> <span class="o">=</span> <span class="mf">0.0</span><span class="p">)</span> <span class="gp">>>> </span><span class="n">cos</span><span class="o">.</span><span class="n">Ogamma0</span><span class="p">,</span> <span class="n">cos</span><span class="o">.</span><span class="n">Onu0</span> <span class="go">(0.0, 0.0)</span> </pre></div> </div> <p>Neutrinos can be removed (while leaving photons) by setting Neff=0:</p> <div class="highlight-python"><div class="highlight"><pre><span class="gp">>>> </span><span class="kn">from</span> <span class="nn">astropy.cosmology</span> <span class="kn">import</span> <span class="n">FlatLambdaCDM</span> <span class="gp">>>> </span><span class="n">cos</span> <span class="o">=</span> <span class="n">FlatLambdaCDM</span><span class="p">(</span><span class="mf">70.4</span><span class="p">,</span> <span class="mf">0.272</span><span class="p">,</span> <span class="n">Neff</span><span class="o">=</span><span class="mi">0</span><span class="p">)</span> <span class="gp">>>> </span><span class="n">cos</span><span class="o">.</span><span class="n">Ogamma</span><span class="p">([</span><span class="mi">0</span><span class="p">,</span><span class="mi">1</span><span class="p">,</span><span class="mi">2</span><span class="p">]),</span><span class="n">cos</span><span class="o">.</span><span class="n">Onu</span><span class="p">([</span><span class="mi">0</span><span class="p">,</span><span class="mi">1</span><span class="p">,</span><span class="mi">2</span><span class="p">])</span> <span class="go">(array([ 4.98569503e-05, 2.74623219e-04, 5.00051845e-04]),</span> <span class="go"> array([ 0., 0., 0.]))</span> </pre></div> </div> <p>While these examples used <a class="reference internal" href="../_generated/astropy.cosmology.core.FlatLambdaCDM.html#astropy.cosmology.core.FlatLambdaCDM" title="astropy.cosmology.core.FlatLambdaCDM"><tt class="xref py py-obj docutils literal"><span class="pre">FlatLambdaCDM</span></tt></a>, the above examples also apply for all of the other cosmology classes.</p> </div> <div class="section" id="see-also"> <h2>See Also<a class="headerlink" href="#see-also" title="Permalink to this headline">¶</a></h2> <ul class="simple"> <li>Hogg, “Distance measures in cosmology”, <a class="reference external" href="http://arxiv.org/abs/astroph/9905116">http://arxiv.org/abs/astroph/9905116</a></li> <li>Linder, “Exploring the Expansion History of the Universe”, <a class="reference external" href="http://arxiv.org/abs/astro-ph/0208512">http://arxiv.org/abs/astro-ph/0208512</a></li> <li>NASA’s Legacy Archive for Microwave Background Data Analysis, <a class="reference external" href="http://lambda.gsfc.nasa.gov/">http://lambda.gsfc.nasa.gov/</a></li> </ul> </div> <div class="section" id="range-of-validity-and-reliability"> <h2>Range of validity and reliability<a class="headerlink" href="#range-of-validity-and-reliability" title="Permalink to this headline">¶</a></h2> <p>The code in this sub-package is tested against several widely-used online cosmology calculators, and has been used to perform calculations in refereed papers. You can check the range of redshifts over which the code is regularly tested in the module <tt class="xref py py-obj docutils literal"><span class="pre">astropy.cosmology.tests.test_cosmology</span></tt>. If you find any bugs, please let us know by <a class="reference external" href="https://github.com/astropy/astropy/issues">opening an issue at the github repository</a>!</p> </div> <div class="section" id="reference-api"> <h2>Reference/API<a class="headerlink" href="#reference-api" title="Permalink to this headline">¶</a></h2> <div class="section" id="module-astropy.cosmology"> <span id="astropy-cosmology-module"></span><h3>astropy.cosmology Module<a class="headerlink" href="#module-astropy.cosmology" title="Permalink to this headline">¶</a></h3> <p>astropy.cosmology contains classes and functions for cosmological distance measures and other cosmology-related calculations.</p> <p>See the <a class="reference external" href="http://docs.astropy.org/en/latest/cosmology/index.html">Astropy documentation</a> for more detailed usage examples and references.</p> <div class="section" id="functions"> <h4>Functions<a class="headerlink" href="#functions" title="Permalink to this headline">¶</a></h4> <table border="1" class="longtable docutils"> <colgroup> <col width="10%" /> <col width="90%" /> </colgroup> <tbody valign="top"> <tr class="row-odd"><td><a class="reference internal" href="../_generated/astropy.cosmology.funcs.H.html#astropy.cosmology.funcs.H" title="astropy.cosmology.funcs.H"><tt class="xref py py-obj docutils literal"><span class="pre">H</span></tt></a>(z[, cosmo])</td> <td>Hubble parameter (km/s/Mpc) at redshift <tt class="xref py py-obj docutils literal"><span class="pre">z</span></tt>.</td> </tr> <tr class="row-even"><td><a class="reference internal" href="../_generated/astropy.cosmology.funcs.angular_diameter_distance.html#astropy.cosmology.funcs.angular_diameter_distance" title="astropy.cosmology.funcs.angular_diameter_distance"><tt class="xref py py-obj docutils literal"><span class="pre">angular_diameter_distance</span></tt></a>(z[, cosmo])</td> <td>Angular diameter distance in Mpc at a given redshift.</td> </tr> <tr class="row-odd"><td><a class="reference internal" href="../_generated/astropy.cosmology.funcs.arcsec_per_kpc_comoving.html#astropy.cosmology.funcs.arcsec_per_kpc_comoving" title="astropy.cosmology.funcs.arcsec_per_kpc_comoving"><tt class="xref py py-obj docutils literal"><span class="pre">arcsec_per_kpc_comoving</span></tt></a>(z[, cosmo])</td> <td>Angular separation in arcsec corresponding to a comoving kpc at redshift <tt class="xref py py-obj docutils literal"><span class="pre">z</span></tt>.</td> </tr> <tr class="row-even"><td><a class="reference internal" href="../_generated/astropy.cosmology.funcs.arcsec_per_kpc_proper.html#astropy.cosmology.funcs.arcsec_per_kpc_proper" title="astropy.cosmology.funcs.arcsec_per_kpc_proper"><tt class="xref py py-obj docutils literal"><span class="pre">arcsec_per_kpc_proper</span></tt></a>(z[, cosmo])</td> <td>Angular separation in arcsec corresponding to a proper kpc at redshift <tt class="xref py py-obj docutils literal"><span class="pre">z</span></tt>.</td> </tr> <tr class="row-odd"><td><a class="reference internal" href="../_generated/astropy.cosmology.funcs.comoving_distance.html#astropy.cosmology.funcs.comoving_distance" title="astropy.cosmology.funcs.comoving_distance"><tt class="xref py py-obj docutils literal"><span class="pre">comoving_distance</span></tt></a>(z[, cosmo])</td> <td>Comoving distance in Mpc at redshift <tt class="xref py py-obj docutils literal"><span class="pre">z</span></tt>.</td> </tr> <tr class="row-even"><td><a class="reference internal" href="../_generated/astropy.cosmology.funcs.critical_density.html#astropy.cosmology.funcs.critical_density" title="astropy.cosmology.funcs.critical_density"><tt class="xref py py-obj docutils literal"><span class="pre">critical_density</span></tt></a>(z[, cosmo])</td> <td>Critical density in grams per cubic cm at redshift <tt class="xref py py-obj docutils literal"><span class="pre">z</span></tt>.</td> </tr> <tr class="row-odd"><td><a class="reference internal" href="../_generated/astropy.cosmology.funcs.distmod.html#astropy.cosmology.funcs.distmod" title="astropy.cosmology.funcs.distmod"><tt class="xref py py-obj docutils literal"><span class="pre">distmod</span></tt></a>(z[, cosmo])</td> <td>Distance modulus at redshift <tt class="xref py py-obj docutils literal"><span class="pre">z</span></tt>.</td> </tr> <tr class="row-even"><td><a class="reference internal" href="../_generated/astropy.cosmology.core.get_current.html#astropy.cosmology.core.get_current" title="astropy.cosmology.core.get_current"><tt class="xref py py-obj docutils literal"><span class="pre">get_current</span></tt></a>()</td> <td>Get the current cosmology.</td> </tr> <tr class="row-odd"><td><a class="reference internal" href="../_generated/astropy.cosmology.funcs.kpc_comoving_per_arcmin.html#astropy.cosmology.funcs.kpc_comoving_per_arcmin" title="astropy.cosmology.funcs.kpc_comoving_per_arcmin"><tt class="xref py py-obj docutils literal"><span class="pre">kpc_comoving_per_arcmin</span></tt></a>(z[, cosmo])</td> <td>Separation in transverse comoving kpc corresponding to an arcminute at redshift <tt class="xref py py-obj docutils literal"><span class="pre">z</span></tt>.</td> </tr> <tr class="row-even"><td><a class="reference internal" href="../_generated/astropy.cosmology.funcs.kpc_proper_per_arcmin.html#astropy.cosmology.funcs.kpc_proper_per_arcmin" title="astropy.cosmology.funcs.kpc_proper_per_arcmin"><tt class="xref py py-obj docutils literal"><span class="pre">kpc_proper_per_arcmin</span></tt></a>(z[, cosmo])</td> <td>Separation in transverse proper kpc corresponding to an arcminute at redshift <tt class="xref py py-obj docutils literal"><span class="pre">z</span></tt>.</td> </tr> <tr class="row-odd"><td><a class="reference internal" href="../_generated/astropy.cosmology.funcs.lookback_time.html#astropy.cosmology.funcs.lookback_time" title="astropy.cosmology.funcs.lookback_time"><tt class="xref py py-obj docutils literal"><span class="pre">lookback_time</span></tt></a>(z[, cosmo])</td> <td>Lookback time in Gyr to redshift <tt class="xref py py-obj docutils literal"><span class="pre">z</span></tt>.</td> </tr> <tr class="row-even"><td><a class="reference internal" href="../_generated/astropy.cosmology.funcs.luminosity_distance.html#astropy.cosmology.funcs.luminosity_distance" title="astropy.cosmology.funcs.luminosity_distance"><tt class="xref py py-obj docutils literal"><span class="pre">luminosity_distance</span></tt></a>(z[, cosmo])</td> <td>Luminosity distance in Mpc at redshift <tt class="xref py py-obj docutils literal"><span class="pre">z</span></tt>.</td> </tr> <tr class="row-odd"><td><a class="reference internal" href="../_generated/astropy.cosmology.funcs.scale_factor.html#astropy.cosmology.funcs.scale_factor" title="astropy.cosmology.funcs.scale_factor"><tt class="xref py py-obj docutils literal"><span class="pre">scale_factor</span></tt></a>(z[, cosmo])</td> <td>Scale factor at redshift <tt class="xref py py-obj docutils literal"><span class="pre">z</span></tt>.</td> </tr> <tr class="row-even"><td><a class="reference internal" href="../_generated/astropy.cosmology.core.set_current.html#astropy.cosmology.core.set_current" title="astropy.cosmology.core.set_current"><tt class="xref py py-obj docutils literal"><span class="pre">set_current</span></tt></a>(cosmo)</td> <td>Set the current cosmology.</td> </tr> </tbody> </table> </div> <div class="section" id="classes"> <h4>Classes<a class="headerlink" href="#classes" title="Permalink to this headline">¶</a></h4> <table border="1" class="longtable docutils"> <colgroup> <col width="10%" /> <col width="90%" /> </colgroup> <tbody valign="top"> <tr class="row-odd"><td><a class="reference internal" href="../_generated/astropy.cosmology.core.FLRW.html#astropy.cosmology.core.FLRW" title="astropy.cosmology.core.FLRW"><tt class="xref py py-obj docutils literal"><span class="pre">FLRW</span></tt></a>(H0, Om0, Ode0[, Tcmb0, Neff, name])</td> <td>A class describing an isotropic and homogeneous (Friedmann-Lemaitre-Robertson-Walker) cosmology.</td> </tr> <tr class="row-even"><td><a class="reference internal" href="../_generated/astropy.cosmology.core.FlatLambdaCDM.html#astropy.cosmology.core.FlatLambdaCDM" title="astropy.cosmology.core.FlatLambdaCDM"><tt class="xref py py-obj docutils literal"><span class="pre">FlatLambdaCDM</span></tt></a>(H0, Om0[, Tcmb0, Neff, name])</td> <td>FLRW cosmology with a cosmological constant and no curvature.</td> </tr> <tr class="row-odd"><td><a class="reference internal" href="../_generated/astropy.cosmology.core.Flatw0waCDM.html#astropy.cosmology.core.Flatw0waCDM" title="astropy.cosmology.core.Flatw0waCDM"><tt class="xref py py-obj docutils literal"><span class="pre">Flatw0waCDM</span></tt></a>(H0, Om0[, w0, wa, Tcmb0, Neff, name])</td> <td>FLRW cosmology with a CPL dark energy equation of state and no curvature.</td> </tr> <tr class="row-even"><td><a class="reference internal" href="../_generated/astropy.cosmology.core.FlatwCDM.html#astropy.cosmology.core.FlatwCDM" title="astropy.cosmology.core.FlatwCDM"><tt class="xref py py-obj docutils literal"><span class="pre">FlatwCDM</span></tt></a>(H0, Om0[, w0, Tcmb0, Neff, name])</td> <td>FLRW cosmology with a constant dark energy equation of state and no spatial curvature.</td> </tr> <tr class="row-odd"><td><a class="reference internal" href="../_generated/astropy.cosmology.core.LambdaCDM.html#astropy.cosmology.core.LambdaCDM" title="astropy.cosmology.core.LambdaCDM"><tt class="xref py py-obj docutils literal"><span class="pre">LambdaCDM</span></tt></a>(H0, Om0, Ode0[, Tcmb0, Neff, name])</td> <td>FLRW cosmology with a cosmological constant and curvature.</td> </tr> <tr class="row-even"><td><a class="reference internal" href="../_generated/astropy.cosmology.core.w0waCDM.html#astropy.cosmology.core.w0waCDM" title="astropy.cosmology.core.w0waCDM"><tt class="xref py py-obj docutils literal"><span class="pre">w0waCDM</span></tt></a>(H0, Om0, Ode0[, w0, wa, Tcmb0, ...])</td> <td>FLRW cosmology with a CPL dark energy equation of state and curvature.</td> </tr> <tr class="row-odd"><td><a class="reference internal" href="../_generated/astropy.cosmology.core.w0wzCDM.html#astropy.cosmology.core.w0wzCDM" title="astropy.cosmology.core.w0wzCDM"><tt class="xref py py-obj docutils literal"><span class="pre">w0wzCDM</span></tt></a>(H0, Om0, Ode0[, w0, wz, Tcmb0, ...])</td> <td>FLRW cosmology with a variable dark energy equation of state and curvature.</td> </tr> <tr class="row-even"><td><a class="reference internal" href="../_generated/astropy.cosmology.core.wCDM.html#astropy.cosmology.core.wCDM" title="astropy.cosmology.core.wCDM"><tt class="xref py py-obj docutils literal"><span class="pre">wCDM</span></tt></a>(H0, Om0, Ode0[, w0, Tcmb0, Neff, name])</td> <td>FLRW cosmology with a constant dark energy equation of state and curvature.</td> </tr> <tr class="row-odd"><td><a class="reference internal" href="../_generated/astropy.cosmology.core.wpwaCDM.html#astropy.cosmology.core.wpwaCDM" title="astropy.cosmology.core.wpwaCDM"><tt class="xref py py-obj docutils literal"><span class="pre">wpwaCDM</span></tt></a>(H0, Om0, Ode0[, wp, wa, zp, Tcmb0, ...])</td> <td>FLRW cosmology with a CPL dark energy equation of state, a pivot redshift, and curvature.</td> </tr> </tbody> </table> </div> <div class="section" id="class-inheritance-diagram"> <h4>Class Inheritance Diagram<a class="headerlink" href="#class-inheritance-diagram" title="Permalink to this headline">¶</a></h4> <p class="graphviz"> digraph inheritanceb05379fd82 { rankdir=LR; size="8.0, 12.0"; "astropy.cosmology.core.w0wzCDM" [style="setlinewidth(0.5)",URL="../_generated/astropy.cosmology.core.w0wzCDM.html#astropy.cosmology.core.w0wzCDM",fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",height=0.25,shape=box,fontsize=10]; "astropy.cosmology.core.FLRW" -> "astropy.cosmology.core.w0wzCDM" [arrowsize=0.5,style="setlinewidth(0.5)"]; "astropy.cosmology.core.Flatw0waCDM" [style="setlinewidth(0.5)",URL="../_generated/astropy.cosmology.core.Flatw0waCDM.html#astropy.cosmology.core.Flatw0waCDM",fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",height=0.25,shape=box,fontsize=10]; "astropy.cosmology.core.w0waCDM" -> "astropy.cosmology.core.Flatw0waCDM" [arrowsize=0.5,style="setlinewidth(0.5)"]; "astropy.cosmology.core.wCDM" [style="setlinewidth(0.5)",URL="../_generated/astropy.cosmology.core.wCDM.html#astropy.cosmology.core.wCDM",fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",height=0.25,shape=box,fontsize=10]; "astropy.cosmology.core.FLRW" -> "astropy.cosmology.core.wCDM" [arrowsize=0.5,style="setlinewidth(0.5)"]; "astropy.cosmology.core.FlatwCDM" [style="setlinewidth(0.5)",URL="../_generated/astropy.cosmology.core.FlatwCDM.html#astropy.cosmology.core.FlatwCDM",fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",height=0.25,shape=box,fontsize=10]; "astropy.cosmology.core.wCDM" -> "astropy.cosmology.core.FlatwCDM" [arrowsize=0.5,style="setlinewidth(0.5)"]; "astropy.cosmology.core.w0waCDM" [style="setlinewidth(0.5)",URL="../_generated/astropy.cosmology.core.w0waCDM.html#astropy.cosmology.core.w0waCDM",fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",height=0.25,shape=box,fontsize=10]; "astropy.cosmology.core.FLRW" -> "astropy.cosmology.core.w0waCDM" [arrowsize=0.5,style="setlinewidth(0.5)"]; "astropy.cosmology.core.FLRW" [style="setlinewidth(0.5)",URL="../_generated/astropy.cosmology.core.FLRW.html#astropy.cosmology.core.FLRW",fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",height=0.25,shape=box,fontsize=10]; "astropy.cosmology.core.Cosmology" -> "astropy.cosmology.core.FLRW" [arrowsize=0.5,style="setlinewidth(0.5)"]; "astropy.cosmology.core.FlatLambdaCDM" [style="setlinewidth(0.5)",URL="../_generated/astropy.cosmology.core.FlatLambdaCDM.html#astropy.cosmology.core.FlatLambdaCDM",fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",height=0.25,shape=box,fontsize=10]; "astropy.cosmology.core.LambdaCDM" -> "astropy.cosmology.core.FlatLambdaCDM" [arrowsize=0.5,style="setlinewidth(0.5)"]; "astropy.cosmology.core.wpwaCDM" [style="setlinewidth(0.5)",URL="../_generated/astropy.cosmology.core.wpwaCDM.html#astropy.cosmology.core.wpwaCDM",fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",height=0.25,shape=box,fontsize=10]; "astropy.cosmology.core.FLRW" -> "astropy.cosmology.core.wpwaCDM" [arrowsize=0.5,style="setlinewidth(0.5)"]; "astropy.cosmology.core.LambdaCDM" [style="setlinewidth(0.5)",URL="../_generated/astropy.cosmology.core.LambdaCDM.html#astropy.cosmology.core.LambdaCDM",fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",height=0.25,shape=box,fontsize=10]; "astropy.cosmology.core.FLRW" -> "astropy.cosmology.core.LambdaCDM" [arrowsize=0.5,style="setlinewidth(0.5)"]; "astropy.cosmology.core.Cosmology" [shape=box,style="setlinewidth(0.5)",fontsize=10,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",height=0.25]; } </p> </div> </div> </div> </div> </div> </div> </div> <div class="sphinxsidebar"> <div class="sphinxsidebarwrapper"><h3>Page Contents</h3> <ul> <li><a class="reference internal" href="#">Cosmological Calculations (<tt class="docutils literal"><span class="pre">astropy.cosmology</span></tt>)</a><ul> <li><a class="reference internal" href="#introduction">Introduction</a></li> <li><a class="reference internal" href="#getting-started">Getting Started</a></li> <li><a class="reference internal" href="#using-cosmology">Using <tt class="docutils literal"><span class="pre">cosmology</span></tt></a></li> <li><a class="reference internal" href="#the-current-cosmology">The Current Cosmology</a><ul> <li><a class="reference internal" href="#using-cosmology-inside-astropy">Using <tt class="docutils literal"><span class="pre">cosmology</span></tt> inside Astropy</a></li> </ul> </li> <li><a class="reference internal" href="#specifying-a-dark-energy-model">Specifying a dark energy model</a></li> <li><a class="reference internal" href="#relativistic-species">Relativistic Species</a></li> <li><a class="reference internal" href="#see-also">See Also</a></li> <li><a class="reference internal" href="#range-of-validity-and-reliability">Range of validity and reliability</a></li> <li><a class="reference internal" href="#reference-api">Reference/API</a><ul> <li><a class="reference internal" href="#module-astropy.cosmology">astropy.cosmology Module</a><ul> <li><a class="reference internal" href="#functions">Functions</a><ul> </ul> </li> <li><a class="reference internal" href="#classes">Classes</a><ul> </ul> </li> <li><a class="reference internal" href="#class-inheritance-diagram">Class Inheritance Diagram</a></li> </ul> </li> </ul> </li> </ul> </li> </ul> </div> </div> <div class="clearer"></div> </div> <footer class="footer"> <p class="pull-right"> <a href="http://github.com/astropy/astropy/tree/v0.2.4/docs/cosmology/index.rst">Edit This Page on Github</a> <a href="../_sources/cosmology/index.txt" rel="nofollow">Page Source</a> <a href="#">Back to Top</a></p> <p> © Copyright 2011-2013, The Astropy Developers.<br/> Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3. Last built 22 Oct 2013. <br/> </p> </footer> </body> </html>