Sophie

Sophie

distrib > Fedora > 13 > i386 > media > os > by-pkgid > ecbd8c5b7568e331fe6ea5b9a07a78a0 > files > 199

CCfits-docs-2.2-2.fc13.noarch.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/xhtml;charset=UTF-8"/>
<title>CCfits: Reading with Extended File Name Syntax</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<!-- Generated by Doxygen 1.6.1 -->
<div class="navigation" id="top">
  <div class="tabs">
    <ul>
      <li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
      <li class="current"><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
</div>
<div class="contents">


<h1><a class="anchor" id="readextendedsyntax">Reading with Extended File Name Syntax </a></h1><p>It is also possible to apply extended file name syntax (as described in chapter 10 of the cfitsio manual) when reading data. The function below shows a typical example using the basic <a class="el" href="classCCfits_1_1FITS.html" title="Memory object representation of a disk FITS file.">CCfits::FITS</a> constructor.</p>
<p>The extended syntax is entered as part of the file name string. In this case it specifies an HDU and a row selection criterion dependent upon the values in the column named "Density." Any read operations performed on this HDU will only see rows which meet the "Density &gt; 5.2" condition. Also the current header position in the file is automatically placed at the specified HDU upon construction of the FITS object.</p>
<p>Extended file name syntax can also be used with the FITS constructors which take specific HDU names or indices as arguments. However if the extended syntax specifies an HDU, that HDU must also be among those specified as a FITS constructor argument, otherwise a <a class="el" href="classCCfits_1_1FITS_1_1OperationNotSupported.html" title="thrown for unsupported operations, such as attempted to select rows from an image...">CCfits::FITS::OperationNotSupported</a> exception is thrown. For example: </p>
<div class="fragment"><pre class="fragment">FITS fits(<span class="keyword">new</span> FITS(<span class="stringliteral">&quot;myFile.fit[HDU_A]&quot;</span>,Read,<span class="keywordtype">string</span>(<span class="stringliteral">&quot;HDU_A&quot;</span>))); <span class="comment">// OK</span>
FITS fits(<span class="keyword">new</span> FITS(<span class="stringliteral">&quot;myFile.fit[HDU_B]&quot;</span>,Read,<span class="keywordtype">string</span>(<span class="stringliteral">&quot;HDU_A&quot;</span>))); <span class="comment">// Error   </span>
</pre></div><p> (Note - The extended file name feature which allows the opening of a particular image located in the row of a table remains unsupported in CCfits.)</p>
<div class="fragment"><pre class="fragment"> <span class="keywordtype">int</span> readExtendedSyntax()
 {
    <span class="comment">// Current extension will be set to PLANETS_ASCII after construction:</span>
    std::auto_ptr&lt;FITS&gt; pInfile(<span class="keyword">new</span> FITS(<span class="stringliteral">&quot;btestfil.fit[PLANETS_ASCII][Density &gt; 5.2]&quot;</span>));
    std::cout &lt;&lt; <span class="stringliteral">&quot;\nCurrent extension: &quot;</span> 
        &lt;&lt; pInfile-&gt;currentExtensionName() &lt;&lt; std::endl;
        
    Column&amp; col = pInfile-&gt;currentExtension().column(<span class="stringliteral">&quot;Density&quot;</span>);
    std::vector&lt;double&gt; densities;
    
    <span class="comment">// nRows should only include rows with density column vals &gt; 5.2.</span>
    <span class="keyword">const</span> <span class="keywordtype">int</span> nRows = col.rows();
    col.read(densities, 1, nRows);
    <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i=0; i&lt;nRows; ++i)
       std::cout &lt;&lt; densities[i] &lt;&lt; <span class="stringliteral">&quot;  &quot;</span>;
    std::cout &lt;&lt; std::endl;
    
    <span class="keywordflow">return</span> 0;
 }
</pre></div> </div>
<hr size="1"/><address style="text-align: right;"><small>Generated on Wed Sep 9 11:59:41 2009 for CCfits by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1 </small></address>
</body>
</html>