Sophie

Sophie

distrib > Mageia > 4 > x86_64 > by-pkgid > 82fd441cd3f2a8bc33fc3ed41403eced > files > 1955

python-astropy-0.2.4-4.mga4.x86_64.rpm


<!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>Constants (astropy.constants) &mdash; 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="Constant" href="../_generated/astropy.constants.constant.Constant.html" />
    <link rel="prev" title="What’s New in Astropy 0.2" href="../whatsnew/0.2.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.constants.constant.Constant.html" title="Constant">
	  next &raquo;
	</a>
      </li>
      <li class="right">
	<a href="../whatsnew/0.2.html" title="What’s New in Astropy 0.2">
	  &laquo; previous
	</a>
	 |
      </li>
      <li>
	<a href="../index.html">Astropy v0.2.4</a>
	 &raquo;
      </li>
      
      <li>Constants (<tt class="docutils literal"><span class="pre">astropy.constants</span></tt>)</li> 
    </ul>
</div>
  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <div class="section" id="constants-astropy-constants">
<h1>Constants (<a class="reference internal" href="#module-astropy.constants" title="astropy.constants"><tt class="xref py py-obj docutils literal"><span class="pre">astropy.constants</span></tt></a>)<a class="headerlink" href="#constants-astropy-constants" 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><a class="reference internal" href="#module-astropy.constants" title="astropy.constants"><tt class="xref py py-obj docutils literal"><span class="pre">astropy.constants</span></tt></a> contains a number of physical constants useful in
Astronomy. Constants are <a class="reference internal" href="../_generated/astropy.units.quantity.Quantity.html#astropy.units.quantity.Quantity" title="astropy.units.quantity.Quantity"><tt class="xref py py-obj docutils literal"><span class="pre">Quantity</span></tt></a> objects with
additional meta-data describing their provenance and uncertainties.</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>To use the constants in S.I. units, you can import the constants directly from
the <a class="reference internal" href="#module-astropy.constants" title="astropy.constants"><tt class="xref py py-obj docutils literal"><span class="pre">astropy.constants</span></tt></a> sub-package:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">astropy.constants</span> <span class="kn">import</span> <span class="n">G</span>
</pre></div>
</div>
<p>or, if you want to avoid having to explicitly import all the constants you
need, you can simply do:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">astropy</span> <span class="kn">import</span> <span class="n">constants</span> <span class="k">as</span> <span class="n">const</span>
</pre></div>
</div>
<p>and then subsequently use for example <tt class="docutils literal"><span class="pre">const.G</span></tt>. Constants are fully-fleged
<a class="reference internal" href="../_generated/astropy.units.quantity.Quantity.html#astropy.units.quantity.Quantity" title="astropy.units.quantity.Quantity"><tt class="xref py py-obj docutils literal"><span class="pre">Quantity</span></tt></a> objects, so you can easily convert them to
different units for example:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="k">print</span> <span class="n">const</span><span class="o">.</span><span class="n">c</span>
<span class="go">  Name   = Speed of light in vacuum</span>
<span class="go">  Value  = 299792458.0</span>
<span class="go">  Error  = 0.0</span>
<span class="go">  Units = m / (s)</span>
<span class="go">  Reference = CODATA 2010</span>

<span class="gp">&gt;&gt;&gt; </span><span class="k">print</span> <span class="n">const</span><span class="o">.</span><span class="n">c</span><span class="o">.</span><span class="n">to</span><span class="p">(</span><span class="s">&#39;km/s&#39;</span><span class="p">)</span>
<span class="go">299792.458 km / (s)</span>

<span class="gp">&gt;&gt;&gt; </span><span class="k">print</span> <span class="n">const</span><span class="o">.</span><span class="n">c</span><span class="o">.</span><span class="n">to</span><span class="p">(</span><span class="s">&#39;pc/yr&#39;</span><span class="p">)</span>
<span class="go">0.306594845466 pc / (yr)</span>
</pre></div>
</div>
<p>and you can use them in conjunction with unit and other non-constant
<a class="reference internal" href="../_generated/astropy.units.quantity.Quantity.html#astropy.units.quantity.Quantity" title="astropy.units.quantity.Quantity"><tt class="xref py py-obj docutils literal"><span class="pre">Quantity</span></tt></a> objects:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">F</span> <span class="o">=</span> <span class="p">(</span><span class="n">const</span><span class="o">.</span><span class="n">G</span> <span class="o">*</span> <span class="mf">3.</span> <span class="o">*</span> <span class="n">const</span><span class="o">.</span><span class="n">M_sun</span> <span class="o">*</span> <span class="mi">100</span> <span class="o">*</span> <span class="n">u</span><span class="o">.</span><span class="n">kg</span><span class="p">)</span> <span class="o">/</span> <span class="p">(</span><span class="mf">2.2</span> <span class="o">*</span> <span class="n">u</span><span class="o">.</span><span class="n">au</span><span class="p">)</span> <span class="o">**</span> <span class="mi">2</span>
<span class="gp">&gt;&gt;&gt; </span><span class="k">print</span> <span class="n">F</span><span class="o">.</span><span class="n">to</span><span class="p">(</span><span class="n">u</span><span class="o">.</span><span class="n">N</span><span class="p">)</span>
<span class="go">0.367669392028 N</span>
</pre></div>
</div>
<p>It is possible to convert most constants to cgs using e.g.:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">const</span><span class="o">.</span><span class="n">c</span><span class="o">.</span><span class="n">cgs</span>
<span class="go">&lt;Quantity 29979245800.0 cm / (s)&gt;</span>
</pre></div>
</div>
<p>However, some constants are defined with different physical dimensions in cgs
and cannot be directly converted. Because of this ambiguity, such constants
cannot be used in expressions without specifying a system:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="mi">100</span> <span class="o">*</span> <span class="n">const</span><span class="o">.</span><span class="n">e</span>
<span class="go">ERROR: TypeError: Constant &#39;e&#39; does not have physically compatible units</span>
<span class="go">across all systems of units and cannot be combined with other values without</span>
<span class="go">specifying a system (eg. e.esu) [astropy.constants.constant]</span>
<span class="gp">...</span>
<span class="gp">&gt;&gt;&gt; </span><span class="mi">100</span> <span class="o">*</span> <span class="n">const</span><span class="o">.</span><span class="n">e</span><span class="o">.</span><span class="n">esu</span>
<span class="go">&lt;Quantity 4.80320450571e-08 Fr&gt;</span>
</pre></div>
</div>
</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.constants">
<span id="astropy-constants-module"></span><h3>astropy.constants Module<a class="headerlink" href="#module-astropy.constants" title="Permalink to this headline">¶</a></h3>
<p>Contains astronomical and physical constants for use in Astropy or other
places.</p>
<p>A typical use case might be:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">astropy.constants</span> <span class="kn">import</span> <span class="n">c</span><span class="p">,</span> <span class="n">m_e</span>
<span class="gp">&gt;&gt;&gt; </span><span class="c"># ... define the mass of something you want the rest energy of as m ...</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">m</span> <span class="o">=</span> <span class="n">m_e</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">E</span> <span class="o">=</span> <span class="n">m</span> <span class="o">*</span> <span class="n">c</span><span class="o">**</span><span class="mi">2</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">E</span><span class="o">.</span><span class="n">to</span><span class="p">(</span><span class="s">&#39;MeV&#39;</span><span class="p">)</span>
<span class="go">&lt;Quantity 0.510998927603 MeV&gt;</span>
</pre></div>
</div>
<p>The following constants are available:</p>
<table border="1" class="docutils">
<colgroup>
<col width="15%" />
<col width="22%" />
<col width="25%" />
<col width="38%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Name</th>
<th class="head">Value</th>
<th class="head">Unit</th>
<th class="head">Description</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>G</td>
<td>6.67384e-11</td>
<td>m3 / (kg s2)</td>
<td>Gravitational constant</td>
</tr>
<tr class="row-odd"><td>L_sun</td>
<td>3.846e+26</td>
<td>W</td>
<td>Solar luminosity</td>
</tr>
<tr class="row-even"><td>M_earth</td>
<td>5.9742e+24</td>
<td>kg</td>
<td>Earth mass</td>
</tr>
<tr class="row-odd"><td>M_jup</td>
<td>1.8987e+27</td>
<td>kg</td>
<td>Jupiter mass</td>
</tr>
<tr class="row-even"><td>M_sun</td>
<td>1.9891e+30</td>
<td>kg</td>
<td>Solar mass</td>
</tr>
<tr class="row-odd"><td>N_A</td>
<td>6.02214129e+23</td>
<td>1 / (mol)</td>
<td>Avogadro&#8217;s number</td>
</tr>
<tr class="row-even"><td>R</td>
<td>8.3144621</td>
<td>J / (K mol)</td>
<td>Gas constant</td>
</tr>
<tr class="row-odd"><td>R_earth</td>
<td>6378136</td>
<td>m</td>
<td>Earth equatorial radius</td>
</tr>
<tr class="row-even"><td>R_jup</td>
<td>71492000</td>
<td>m</td>
<td>Jupiter equatorial radius</td>
</tr>
<tr class="row-odd"><td>R_sun</td>
<td>695508000</td>
<td>m</td>
<td>Solar radius</td>
</tr>
<tr class="row-even"><td>Ryd</td>
<td>10973731.6</td>
<td>1 / (m)</td>
<td>Rydberg constant</td>
</tr>
<tr class="row-odd"><td>au</td>
<td>1.49597871e+11</td>
<td>m</td>
<td>Astronomical Unit</td>
</tr>
<tr class="row-even"><td>c</td>
<td>299792458</td>
<td>m / (s)</td>
<td>Speed of light in vacuum</td>
</tr>
<tr class="row-odd"><td>e</td>
<td>1.60217657e-19</td>
<td>C</td>
<td>Electron charge</td>
</tr>
<tr class="row-even"><td>h</td>
<td>6.62606957e-34</td>
<td>J s</td>
<td>Planck constant</td>
</tr>
<tr class="row-odd"><td>hbar</td>
<td>1.05457173e-34</td>
<td>J s</td>
<td>Reduced Planck constant</td>
</tr>
<tr class="row-even"><td>k_B</td>
<td>1.3806488e-23</td>
<td>J / (K)</td>
<td>Boltzmann constant</td>
</tr>
<tr class="row-odd"><td>kpc</td>
<td>3.08567758e+19</td>
<td>m</td>
<td>Kiloparsec</td>
</tr>
<tr class="row-even"><td>m_e</td>
<td>9.10938291e-31</td>
<td>kg</td>
<td>Electron mass</td>
</tr>
<tr class="row-odd"><td>m_n</td>
<td>1.67492735e-27</td>
<td>kg</td>
<td>Neutron mass</td>
</tr>
<tr class="row-even"><td>m_p</td>
<td>1.67262178e-27</td>
<td>kg</td>
<td>Proton mass</td>
</tr>
<tr class="row-odd"><td>pc</td>
<td>3.08567758e+16</td>
<td>m</td>
<td>Parsec</td>
</tr>
<tr class="row-even"><td>sigma_sb</td>
<td>5.670373e-08</td>
<td>W / (K4 m2)</td>
<td>Stefan-Boltzmann constant</td>
</tr>
</tbody>
</table>
<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.constants.constant.Constant.html#astropy.constants.constant.Constant" title="astropy.constants.constant.Constant"><tt class="xref py py-obj docutils literal"><span class="pre">Constant</span></tt></a>(abbrev,&nbsp;name,&nbsp;value,&nbsp;unit,&nbsp;...[,&nbsp;...])</td>
<td>A physical or astronomical constant.</td>
</tr>
<tr class="row-even"><td><a class="reference internal" href="../_generated/astropy.constants.constant.EMConstant.html#astropy.constants.constant.EMConstant" title="astropy.constants.constant.EMConstant"><tt class="xref py py-obj docutils literal"><span class="pre">EMConstant</span></tt></a>(abbrev,&nbsp;name,&nbsp;value,&nbsp;unit,&nbsp;...[,&nbsp;...])</td>
<td>An electromagnetic constant.</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 inheritance9ab5a854db {
rankdir=LR;
size=&quot;8.0, 12.0&quot;;
  &quot;astropy.constants.constant.EMConstant&quot; [style=&quot;setlinewidth(0.5)&quot;,URL=&quot;../_generated/astropy.constants.constant.EMConstant.html#astropy.constants.constant.EMConstant&quot;,fontname=&quot;Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans&quot;,height=0.25,shape=box,fontsize=10];
  &quot;astropy.constants.constant.Constant&quot; -&gt; &quot;astropy.constants.constant.EMConstant&quot; [arrowsize=0.5,style=&quot;setlinewidth(0.5)&quot;];
  &quot;astropy.units.quantity.Quantity&quot; [style=&quot;setlinewidth(0.5)&quot;,URL=&quot;../_generated/astropy.units.quantity.Quantity.html#astropy.units.quantity.Quantity&quot;,fontname=&quot;Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans&quot;,height=0.25,shape=box,fontsize=10];
  &quot;astropy.constants.constant.Constant&quot; [style=&quot;setlinewidth(0.5)&quot;,URL=&quot;../_generated/astropy.constants.constant.Constant.html#astropy.constants.constant.Constant&quot;,fontname=&quot;Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans&quot;,height=0.25,shape=box,fontsize=10];
  &quot;astropy.units.quantity.Quantity&quot; -&gt; &quot;astropy.constants.constant.Constant&quot; [arrowsize=0.5,style=&quot;setlinewidth(0.5)&quot;];
}
</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="#">Constants (<tt class="docutils literal"><span class="pre">astropy.constants</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="#reference-api">Reference/API</a><ul>
<li><a class="reference internal" href="#module-astropy.constants">astropy.constants Module</a><ul>
<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/constants/index.rst">Edit This Page on Github</a> &nbsp;
    <a href="../_sources/constants/index.txt"
       rel="nofollow">Page Source</a> &nbsp;
    <a href="#">Back to Top</a></p>
  <p>
    &copy; Copyright 2011-2013, The Astropy Developers.<br/>
    Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3. &nbsp;
    Last built 22 Oct 2013. <br/>
  </p>
</footer>
  </body>
</html>