Sophie

Sophie

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

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>Transforming Between Systems &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="up" title="Astronomical Coordinate Systems (astropy.coordinates)" href="index.html" />
    <link rel="next" title="Designing Coordinate Systems" href="designing.html" />
    <link rel="prev" title="Distances and Cartesian Representations" href="distances.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="designing.html" title="Designing Coordinate Systems">
	  next &raquo;
	</a>
      </li>
      <li class="right">
	<a href="distances.html" title="Distances and Cartesian Representations">
	  &laquo; previous
	</a>
	 |
      </li>
      <li>
	<a href="../index.html">Astropy v0.2.4</a>
	 &raquo;
      </li>
      <li><a href="index.html" accesskey="U">Astronomical Coordinate Systems (<tt class="docutils literal"><span class="pre">astropy.coordinates</span></tt>)</a> &raquo;</li>
      
      <li>Transforming Between Systems</li> 
    </ul>
</div>
  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <div class="section" id="transforming-between-systems">
<h1>Transforming Between Systems<a class="headerlink" href="#transforming-between-systems" title="Permalink to this headline">ΒΆ</a></h1>
<p><a class="reference internal" href="index.html#module-astropy.coordinates" title="astropy.coordinates"><tt class="xref py py-obj docutils literal"><span class="pre">astropy.coordinates</span></tt></a> supports a rich system for transforming coordinates from
one system to another.  The key concept is that a registry of all the
transformations is used to determine which coordinates can convert to others.
When you ask for a transformation, the registry (or &#8220;transformation graph&#8221;) is
searched for the shortest path from your starting coordinate to your target, and
it applies all of the transformations in that path in series.   This allows only
the simplest transformations to be defined, and the package will automatically
determine how to combine those transformations to get from one system to
another.</p>
<p>As described above, there are two ways of transforming coordinates.  Coordinates
that have an alias (created with
<a class="reference internal" href="../_generated/astropy.coordinates.transformations.coordinate_alias.html#astropy.coordinates.transformations.coordinate_alias" title="astropy.coordinates.transformations.coordinate_alias"><tt class="xref py py-obj docutils literal"><span class="pre">coordinate_alias</span></tt></a>) can be converted by
simply using attribute style access to any other coordinate system:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">gc</span> <span class="o">=</span> <span class="n">GalacticCoordinates</span><span class="p">(</span><span class="n">l</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="n">b</span><span class="o">=</span><span class="mi">45</span><span class="p">,</span> <span class="n">unit</span><span class="o">=</span><span class="p">(</span><span class="n">u</span><span class="o">.</span><span class="n">degree</span><span class="p">,</span> <span class="n">u</span><span class="o">.</span><span class="n">degree</span><span class="p">))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">gc</span><span class="o">.</span><span class="n">fk5</span>
<span class="go">&lt;FK5Coordinates RA=229.27250 deg, Dec=-1.12842 deg&gt;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">ic</span> <span class="o">=</span> <span class="n">ICRSCoordinates</span><span class="p">(</span><span class="n">ra</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="n">dec</span><span class="o">=</span><span class="mi">45</span><span class="p">,</span> <span class="n">unit</span><span class="o">=</span><span class="p">(</span><span class="n">u</span><span class="o">.</span><span class="n">degree</span><span class="p">,</span> <span class="n">u</span><span class="o">.</span><span class="n">degree</span><span class="p">)))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">ic</span><span class="o">.</span><span class="n">fk5</span>
<span class="go">&lt;FK5Coordinates RA=0.00001 deg, Dec=45.00000 deg&gt;</span>
</pre></div>
</div>
<p>While this appears to be simple attribute-style access, it is actually just
syntactic sugar for the <tt class="xref py py-obj docutils literal"><span class="pre">transform_to</span></tt> method:</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.coordinates</span> <span class="kn">import</span> <span class="n">FK5Coordinates</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">gc</span><span class="o">.</span><span class="n">transform_to</span><span class="p">(</span><span class="n">FK5Coordinates</span><span class="p">)</span>
<span class="go">&lt;FK5Coordinates RA=229.27250 deg, Dec=-1.12842 deg&gt;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">ic</span><span class="o">.</span><span class="n">transform_to</span><span class="p">(</span><span class="n">FK5Coordinates</span><span class="p">)</span>
<span class="go">&lt;FK5Coordinates RA=0.00001 deg, Dec=45.00000 deg&gt;</span>
</pre></div>
</div>
<p>The full list of supported coordinate systems and transformations is in the
<a class="reference internal" href="index.html#module-astropy.coordinates" title="astropy.coordinates"><tt class="xref py py-obj docutils literal"><span class="pre">astropy.coordinates</span></tt></a> API documentation below.</p>
<p>Additionally, some coordinate systems support precessing the coordinate to
produce a new coordinate in the same system but at a different equinox.  Note
that these systems have a default equinox they start with if you don&#8217;t specify
one:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">fk5c</span> <span class="o">=</span> <span class="n">FK5Coordinates</span><span class="p">(</span><span class="s">&#39;02h31m49.09s +89d15m50.8s&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">fk5c</span><span class="o">.</span><span class="n">equinox</span>
<span class="go">&lt;Time object: scale=&#39;utc&#39; format=&#39;jyear_str&#39; vals=J2000.000&gt;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">fk5c</span>
<span class="go">&lt;FK5Coordinates RA=37.95454 deg, Dec=89.26411 deg&gt;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">fk5c</span><span class="o">.</span><span class="n">precess_to</span><span class="p">(</span><span class="n">Time</span><span class="p">(</span><span class="mi">2100</span><span class="p">,</span> <span class="n">format</span><span class="o">=</span><span class="s">&#39;jyear&#39;</span><span class="p">,</span> <span class="n">scale</span><span class="o">=</span><span class="s">&#39;utc&#39;</span><span class="p">))</span>
<span class="go">&lt;FK5Coordinates RA=88.32396 deg, Dec=89.54057 deg&gt;</span>
</pre></div>
</div>
<p>You can also specify the equinox when you create a coordinate using an
<tt class="xref py py-obj docutils literal"><span class="pre">astropy.time.Time</span></tt> object:</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.time</span> <span class="kn">import</span> <span class="n">Time</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">fk5c</span> <span class="o">=</span> <span class="n">FK5Coordinates</span><span class="p">(</span><span class="s">&#39;02h31m49.09s +89d15m50.8s&#39;</span><span class="p">,</span> <span class="n">equinox</span><span class="o">=</span><span class="n">Time</span><span class="p">(</span><span class="s">&#39;J1970&#39;</span><span class="p">,</span> <span class="n">scale</span><span class="o">=</span><span class="s">&#39;utc&#39;</span><span class="p">))</span>
<span class="go">&lt;FK5Coordinates RA=37.95454 deg, Dec=89.26411 deg&gt;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">fk5c</span><span class="o">.</span><span class="n">precess_to</span><span class="p">(</span><span class="n">Time</span><span class="p">(</span><span class="mi">2000</span><span class="p">,</span> <span class="n">format</span><span class="o">=</span><span class="s">&#39;jyear&#39;</span><span class="p">,</span> <span class="n">scale</span><span class="o">=</span><span class="s">&#39;utc&#39;</span><span class="p">))</span>
<span class="go">&lt;FK5Coordinates RA=48.02317 deg, Dec=89.38672 deg&gt;</span>
</pre></div>
</div>
<p>Coordinate systems do not necessarily all support an equinox nor precession, as it is a
meaningless action for coordinate systems that do not depend on a particular equinox.</p>
<p>Furthermore, coordinates typically have an <tt class="xref py py-obj docutils literal"><span class="pre">obstime</span></tt> attribute, intended to record the
time of the observation.  Some systems (especially FK4) require this information due
to being non-inertial frames (i.e., they rotate over time due to motions of the
defining stars).</p>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper"><h3>Page Contents</h3>
<ul>
<li><a class="reference internal" href="#">Transforming Between Systems</a></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/coordinates/transforming.rst">Edit This Page on Github</a> &nbsp;
    <a href="../_sources/coordinates/transforming.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>