<!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>Cds — 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="ASCII Tables (astropy.io.ascii)" href="../io/ascii/index.html" /> <link rel="next" title="Column" href="astropy.io.ascii.core.Column.html" /> <link rel="prev" title="Basic" href="astropy.io.ascii.basic.Basic.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.io.ascii.core.Column.html" title="Column"> next » </a> </li> <li class="right"> <a href="astropy.io.ascii.basic.Basic.html" title="Basic"> « previous </a> | </li> <li> <a href="../index.html">Astropy v0.2.4</a> » </li> <li><a href="../io/ascii/index.html" accesskey="U">ASCII Tables (<tt class="docutils literal"><span class="pre">astropy.io.ascii</span></tt>)</a> »</li> <li>Cds</li> </ul> </div> <div class="document"> <div class="documentwrapper"> <div class="bodywrapper"> <div class="body"> <div class="section" id="cds"> <h1>Cds<a class="headerlink" href="#cds" title="Permalink to this headline">¶</a></h1> <dl class="class"> <dt id="astropy.io.ascii.cds.Cds"> <em class="property">class </em><tt class="descclassname">astropy.io.ascii.cds.</tt><tt class="descname">Cds</tt><big>(</big><em>readme=None</em><big>)</big><a class="reference external" href="http://github.com/astropy/astropy/tree/v0.2.4/astropy/io/ascii/cds.py#L198" title="Push the Edit button on the next page"><span class="edit-on-github viewcode-link"> [edit on github]</span></a><a class="reference internal" href="../_modules/astropy/io/ascii/cds.html#Cds"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#astropy.io.ascii.cds.Cds" title="Permalink to this definition">¶</a></dt> <dd><p>Bases: <a class="reference internal" href="astropy.io.ascii.core.BaseReader.html#astropy.io.ascii.core.BaseReader" title="astropy.io.ascii.core.BaseReader"><tt class="xref py py-class docutils literal"><span class="pre">astropy.io.ascii.core.BaseReader</span></tt></a></p> <p>Read a CDS format table. See <a class="reference external" href="http://vizier.u-strasbg.fr/doc/catstd.htx">http://vizier.u-strasbg.fr/doc/catstd.htx</a>. Example:</p> <div class="highlight-python"><pre>Table: Table name here = ============================================================================== Catalog reference paper Bibliography info here ================================================================================ ADC_Keywords: Keyword ; Another keyword ; etc Description: Catalog description here. ================================================================================ Byte-by-byte Description of file: datafile3.txt -------------------------------------------------------------------------------- Bytes Format Units Label Explanations -------------------------------------------------------------------------------- 1- 3 I3 --- Index Running identification number 5- 6 I2 h RAh Hour of Right Ascension (J2000) 8- 9 I2 min RAm Minute of Right Ascension (J2000) 11- 15 F5.2 s RAs Second of Right Ascension (J2000) -------------------------------------------------------------------------------- Note (1): A CDS file can contain sections with various metadata. Notes can be multiple lines. Note (2): Another note. -------------------------------------------------------------------------------- 1 03 28 39.09 2 04 18 24.11</pre> </div> <p><strong>About parsing the CDS format</strong></p> <p>The CDS format consists of a table description and the table data. These can be in separate files as a <tt class="docutils literal"><span class="pre">ReadMe</span></tt> file plus data file(s), or combined in a single file. Different subsections within the description are separated by lines of dashes or equal signs (“——” or “======”). The table which specifies the column information must be preceded by a line starting with “Byte-by-byte Description of file:”.</p> <p>In the case where the table description is combined with the data values, the data must be in the last section and must be preceded by a section delimiter line (dashes or equal signs only).</p> <p><strong>Basic usage</strong></p> <p>Use the <tt class="docutils literal"><span class="pre">ascii.read()</span></tt> function as normal, with an optional <tt class="docutils literal"><span class="pre">readme</span></tt> parameter indicating the CDS ReadMe file. If not supplied it is assumed that the header information is at the top of the given table. Examples:</p> <div class="highlight-python"><div class="highlight"><pre><span class="gp">>>> </span><span class="kn">from</span> <span class="nn">astropy.io</span> <span class="kn">import</span> <span class="n">ascii</span> <span class="gp">>>> </span><span class="n">table</span> <span class="o">=</span> <span class="n">ascii</span><span class="o">.</span><span class="n">read</span><span class="p">(</span><span class="s">"t/cds.dat"</span><span class="p">)</span> <span class="gp">>>> </span><span class="n">table</span> <span class="o">=</span> <span class="n">ascii</span><span class="o">.</span><span class="n">read</span><span class="p">(</span><span class="s">"t/vizier/table1.dat"</span><span class="p">,</span> <span class="n">readme</span><span class="o">=</span><span class="s">"t/vizier/ReadMe"</span><span class="p">)</span> <span class="gp">>>> </span><span class="n">table</span> <span class="o">=</span> <span class="n">ascii</span><span class="o">.</span><span class="n">read</span><span class="p">(</span><span class="s">"t/cds/multi/lhs2065.dat"</span><span class="p">,</span> <span class="n">readme</span><span class="o">=</span><span class="s">"t/cds/multi/ReadMe"</span><span class="p">)</span> <span class="gp">>>> </span><span class="n">table</span> <span class="o">=</span> <span class="n">ascii</span><span class="o">.</span><span class="n">read</span><span class="p">(</span><span class="s">"t/cds/glob/lmxbrefs.dat"</span><span class="p">,</span> <span class="n">readme</span><span class="o">=</span><span class="s">"t/cds/glob/ReadMe"</span><span class="p">)</span> </pre></div> </div> <p><strong>Using a reader object</strong></p> <p>When <tt class="docutils literal"><span class="pre">Cds</span></tt> reader object is created with a <tt class="docutils literal"><span class="pre">readme</span></tt> parameter passed to it at initialization, then when the <tt class="docutils literal"><span class="pre">read</span></tt> method is executed with a table filename, the header information for the specified table is taken from the <tt class="docutils literal"><span class="pre">readme</span></tt> file. An <tt class="docutils literal"><span class="pre">InconsistentTableError</span></tt> is raised if the <tt class="docutils literal"><span class="pre">readme</span></tt> file does not have header information for the given table.</p> <div class="highlight-python"><div class="highlight"><pre><span class="gp">>>> </span><span class="n">readme</span> <span class="o">=</span> <span class="s">"t/vizier/ReadMe"</span> <span class="gp">>>> </span><span class="n">r</span> <span class="o">=</span> <span class="n">ascii</span><span class="o">.</span><span class="n">get_reader</span><span class="p">(</span><span class="n">ascii</span><span class="o">.</span><span class="n">Cds</span><span class="p">,</span> <span class="n">readme</span><span class="o">=</span><span class="n">readme</span><span class="p">)</span> <span class="gp">>>> </span><span class="n">table</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">read</span><span class="p">(</span><span class="s">"t/vizier/table1.dat"</span><span class="p">)</span> <span class="gp">>>> </span><span class="c"># table5.dat has the same ReadMe file</span> <span class="gp">>>> </span><span class="n">table</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">read</span><span class="p">(</span><span class="s">"t/vizier/table5.dat"</span><span class="p">)</span> </pre></div> </div> <p>If no <tt class="docutils literal"><span class="pre">readme</span></tt> parameter is specified, then the header information is assumed to be at the top of the given table.</p> <div class="highlight-python"><div class="highlight"><pre><span class="gp">>>> </span><span class="n">r</span> <span class="o">=</span> <span class="n">ascii</span><span class="o">.</span><span class="n">get_reader</span><span class="p">(</span><span class="n">ascii</span><span class="o">.</span><span class="n">Cds</span><span class="p">)</span> <span class="gp">>>> </span><span class="n">table</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">read</span><span class="p">(</span><span class="s">"t/cds.dat"</span><span class="p">)</span> <span class="gp">>>> </span><span class="c">#The following gives InconsistentTableError, since no</span> <span class="gp">>>> </span><span class="c">#readme file was given and table1.dat does not have a header.</span> <span class="gp">>>> </span><span class="n">table</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">read</span><span class="p">(</span><span class="s">"t/vizier/table1.dat"</span><span class="p">)</span> <span class="gt">Traceback (most recent call last):</span> <span class="c">...</span> <span class="gr">InconsistentTableError</span>: <span class="n">No CDS section delimiter found</span> </pre></div> </div> <p>Caveats:</p> <ul class="simple"> <li>Format, Units, and Explanations are available in the <tt class="docutils literal"><span class="pre">Reader.cols</span></tt> attribute.</li> <li>All of the other metadata defined by this format is ignored.</li> </ul> <p>Code contribution to enhance the parsing to include metadata in a Reader.meta attribute would be welcome.</p> <p class="rubric">Methods Summary</p> <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="#astropy.io.ascii.cds.Cds.write" title="astropy.io.ascii.cds.Cds.write"><tt class="xref py py-obj docutils literal"><span class="pre">write</span></tt></a>([table])</td> <td>Not available for the Cds class (raises NotImplementedError)</td> </tr> </tbody> </table> <p class="rubric">Methods Documentation</p> <dl class="method"> <dt id="astropy.io.ascii.cds.Cds.write"> <tt class="descname">write</tt><big>(</big><em>table=None</em><big>)</big><a class="reference external" href="http://github.com/astropy/astropy/tree/v0.2.4/astropy/io/ascii/cds.py#L294" title="Push the Edit button on the next page"><span class="edit-on-github viewcode-link"> [edit on github]</span></a><a class="reference internal" href="../_modules/astropy/io/ascii/cds.html#Cds.write"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#astropy.io.ascii.cds.Cds.write" title="Permalink to this definition">¶</a></dt> <dd><p>Not available for the Cds class (raises NotImplementedError)</p> </dd></dl> </dd></dl> </div> </div> </div> </div> <div class="sphinxsidebar"> <div class="sphinxsidebarwrapper"><h3>Page Contents</h3> <ul> <li><a class="reference internal" href="#">Cds</a></li> </ul> </div> </div> <div class="clearer"></div> </div> <footer class="footer"> <p class="pull-right"> <a href="../_sources/_generated/astropy.io.ascii.cds.Cds.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>