<!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>UnitConverter — 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="World Coordinate System (astropy.wcs)" href="../wcs/index.html" /> <link rel="next" title="find_all_wcs" href="astropy.wcs.wcs.find_all_wcs.html" /> <link rel="prev" title="Wcsprm" href="astropy.wcs.Wcsprm.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="astropy.wcs.wcs.find_all_wcs.html" title="find_all_wcs"> next » </a> </li> <li class="right"> <a href="astropy.wcs.Wcsprm.html" title="Wcsprm"> « previous </a> | </li> <li> <a href="../index.html">Astropy v0.2.4</a> » </li> <li><a href="../wcs/index.html" accesskey="U">World Coordinate System (<tt class="docutils literal"><span class="pre">astropy.wcs</span></tt>)</a> »</li> <li>UnitConverter</li> </ul> </div> <div class="document"> <div class="documentwrapper"> <div class="bodywrapper"> <div class="body"> <div class="section" id="unitconverter"> <h1>UnitConverter<a class="headerlink" href="#unitconverter" title="Permalink to this headline">¶</a></h1> <dl class="function"> <dt id="astropy.wcs.UnitConverter"> <tt class="descclassname">astropy.wcs.</tt><tt class="descname">UnitConverter</tt><big>(</big><em>*args</em>, <em>**kwargs</em><big>)</big><a class="reference external" href="http://github.com/astropy/astropy/tree/v0.2.4/astropy/wcs.py#L380" title="Push the Edit button on the next page"><span class="edit-on-github viewcode-link"> [edit on github]</span></a><a class="headerlink" href="#astropy.wcs.UnitConverter" title="Permalink to this definition">¶</a></dt> <dd><p class="deprecated"> <span class="versionmodified">Deprecated since version 0.2: </span>Use astropy.units instead.</p> <p>UnitConverter(have, want, translate_units=’‘)</p> <p>An object for converting from one system of units to another.</p> <p>Use the returned object’s <tt class="xref py py-obj docutils literal"><span class="pre">convert</span></tt> method to convert values from <em>have</em> to <em>want</em>.</p> <p>This function is permissive in accepting whitespace in all contexts in a units specification where it does not create ambiguity (e.g. not between a metric prefix and a basic unit string), including in strings like <tt class="docutils literal"><span class="pre">"log</span> <span class="pre">(m</span> <span class="pre">**</span> <span class="pre">2)"</span></tt> which is formally disallowed.</p> <div class="admonition note"> <p class="first admonition-title">Note</p> <p>Deprecated in Astropy 0.2</p> <p class="last"><a class="reference internal" href="#astropy.wcs.UnitConverter" title="astropy.wcs.UnitConverter"><tt class="xref py py-obj docutils literal"><span class="pre">UnitConverter</span></tt></a> will be removed in a future version of astropy. The <tt class="xref py py-obj docutils literal"><span class="pre">astropy.units</span></tt> package should be used instead.</p> </div> <table class="docutils field-list" frame="void" rules="none"> <col class="field-name" /> <col class="field-body" /> <tbody valign="top"> <tr class="field-odd field"><th class="field-name">Parameters :</th><td class="field-body"><p class="first"><strong>have</strong> : string</p> <blockquote> <div><p>FITS unit string to convert from, with or without surrounding square brackets (for inline specifications); text following the closing bracket is ignored.</p> </div></blockquote> <p><strong>want</strong> : string</p> <blockquote> <div><p>FITS unit string to convert to, with or without surrounding square brackets (for inline specifications); text following the closing bracket is ignored.</p> </div></blockquote> <p><strong>ctrl</strong> : string, optional</p> <blockquote> <div><p>Do potentially unsafe translations of non-standard unit strings.</p> <p>Although <tt class="docutils literal"><span class="pre">"S"</span></tt> is commonly used to represent seconds, its recognizes <tt class="docutils literal"><span class="pre">"S"</span></tt> formally as Siemens, however rarely that may be translation to <tt class="docutils literal"><span class="pre">"s"</span></tt> is potentially unsafe since the standard used. The same applies to <tt class="docutils literal"><span class="pre">"H"</span></tt> for hours (Henry), and <tt class="docutils literal"><span class="pre">"D"</span></tt> for days (Debye).</p> <p>This string controls what to do in such cases, and is case-insensitive.</p> <ul class="simple"> <li>If the string contains <tt class="docutils literal"><span class="pre">"s"</span></tt>, translate <tt class="docutils literal"><span class="pre">"S"</span></tt> to <tt class="docutils literal"><span class="pre">"s"</span></tt>.</li> <li>If the string contains <tt class="docutils literal"><span class="pre">"h"</span></tt>, translate <tt class="docutils literal"><span class="pre">"H"</span></tt> to <tt class="docutils literal"><span class="pre">"h"</span></tt>.</li> <li>If the string contains <tt class="docutils literal"><span class="pre">"d"</span></tt>, translate <tt class="docutils literal"><span class="pre">"D"</span></tt> to <tt class="docutils literal"><span class="pre">"d"</span></tt>.</li> </ul> <p>Thus <tt class="docutils literal"><span class="pre">''</span></tt> doesn’t do any unsafe translations, whereas <tt class="docutils literal"><span class="pre">'shd'</span></tt> does all of them.</p> </div></blockquote> </td> </tr> <tr class="field-even field"><th class="field-name">Raises :</th><td class="field-body"><p class="first"><strong>ValueError</strong> :</p> <blockquote> <div><p>Invalid numeric multiplier.</p> </div></blockquote> <p><strong>SyntaxError</strong> :</p> <blockquote> <div><p>Dangling binary operator.</p> </div></blockquote> <p><strong>SyntaxError</strong> :</p> <blockquote> <div><p>Invalid symbol in INITIAL context.</p> </div></blockquote> <p><strong>SyntaxError</strong> :</p> <blockquote> <div><p>Function in invalid context.</p> </div></blockquote> <p><strong>SyntaxError</strong> :</p> <blockquote> <div><p>Invalid symbol in EXPON context.</p> </div></blockquote> <p><strong>SyntaxError</strong> :</p> <blockquote> <div><p>Unbalanced bracket.</p> </div></blockquote> <p><strong>SyntaxError</strong> :</p> <blockquote> <div><p>Unbalanced parenthesis.</p> </div></blockquote> <p><strong>SyntaxError</strong> :</p> <blockquote> <div><p>Consecutive binary operators.</p> </div></blockquote> <p><strong>SyntaxError</strong> :</p> <blockquote> <div><p>Internal parser error.</p> </div></blockquote> <p><strong>SyntaxError</strong> :</p> <blockquote> <div><p>Non-conformant unit specifications.</p> </div></blockquote> <p><strong>SyntaxError</strong> :</p> <blockquote> <div><p>Non-conformant functions.</p> </div></blockquote> <p><strong>ValueError</strong> :</p> <blockquote class="last"> <div><p>Potentially unsafe translation.</p> </div></blockquote> </td> </tr> </tbody> </table> </dd></dl> </div> </div> </div> </div> <div class="sphinxsidebar"> <div class="sphinxsidebarwrapper"><h3>Page Contents</h3> <ul> <li><a class="reference internal" href="#">UnitConverter</a></li> </ul> </div> </div> <div class="clearer"></div> </div> <footer class="footer"> <p class="pull-right"> <a href="../_sources/_generated/astropy.wcs.UnitConverter.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>