Sophie

Sophie

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

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: Copying an Extension between Files</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="copy">Copying an Extension between Files </a></h1><p>Copying extensions from one fits file to another is very straightforward. A complication arises, however, because CCfits requires every FITS object to correspond to a conforming FITS file once constructed. Thus we provide a custom constructor which copies the primary HDU of a ``source FITS file into a new file. Subsequent extensions can be copied by name or extension number as illustrated below.</p>
<p>Note that the simple call</p>
<div class="fragment"><pre class="fragment">FITS::FITS(<span class="keyword">const</span> std::string&amp; filename)
</pre></div><p>Reads the headers for all of the extensions in the file, so that after the FITS object corresponding to <em>infile</em> in the following code is instantiated, all extensions are recognized [read calls are also provided to read only specific HDUs - see below].</p>
<p>In the example code below, the file outFile is written straight to disk. Since the code never requests that the HDUs being written to that file are read, the user needs to add statements to do this after the copy is complete.</p>
<div class="fragment"><pre class="fragment"><span class="keywordtype">int</span> copyHDU()
{
    <span class="comment">//******************************************************************</span>
    <span class="comment">// copy the 1st and 3rd HDUs from the input file to a new FITS file </span>
    <span class="comment">//******************************************************************</span>


    <span class="keyword">const</span> <span class="keywordtype">string</span> inFileName(<span class="stringliteral">&quot;atestfil.fit&quot;</span>);  
    <span class="keyword">const</span> <span class="keywordtype">string</span> outFileName(<span class="stringliteral">&quot;btestfil.fit&quot;</span>);  

    <span class="keywordtype">int</span> status(0);

    status = 0;

    <span class="keyword">remove</span>(outFileName.c_str());       <span class="comment">// Delete old file if it already exists</span>

    <span class="comment">// open the existing FITS file</span>
    FITS inFile(inFileName);
    
    <span class="comment">// custom constructor FITS::FITS(const string&amp;, const FITS&amp;) for</span>
    <span class="comment">// this particular task.</span>
    
    FITS outFile(outFileName,inFile);

    <span class="comment">// copy extension by number...</span>
    outFile.copy(inFile.extension(2));
    
    <span class="comment">// copy extension by name...</span>
    outFile.copy(inFile.extension(<span class="stringliteral">&quot;TABLE_BINARY&quot;</span>));
    
   <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>