Sophie

Sophie

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

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>File Handling and Convenience Functions &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="FITS File handling (astropy.io.fits)" href="../index.html" />
    <link rel="next" title="HDU Lists" href="hdulists.html" />
    <link rel="prev" title="astropy.io.fits History" href="../appendix/history.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="hdulists.html" title="HDU Lists">
	  next &raquo;
	</a>
      </li>
      <li class="right">
	<a href="../appendix/history.html" title="astropy.io.fits History">
	  &laquo; previous
	</a>
	 |
      </li>
      <li>
	<a href="../../../index.html">Astropy v0.2.4</a>
	 &raquo;
      </li>
      <li><a href="../index.html" accesskey="U">FITS File handling (<tt class="docutils literal"><span class="pre">astropy.io.fits</span></tt>)</a> &raquo;</li>
      
      <li>File Handling and Convenience Functions</li> 
    </ul>
</div>
  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <div class="section" id="file-handling-and-convenience-functions">
<h1>File Handling and Convenience Functions<a class="headerlink" href="#file-handling-and-convenience-functions" title="Permalink to this headline">¶</a></h1>
<div class="section" id="open">
<h2><a class="reference internal" href="#astropy.io.fits.open" title="astropy.io.fits.open"><tt class="xref py py-func docutils literal"><span class="pre">open()</span></tt></a><a class="headerlink" href="#open" title="Permalink to this headline">¶</a></h2>
<dl class="function">
<dt id="astropy.io.fits.open">
<tt class="descclassname">astropy.io.fits.</tt><tt class="descname">open</tt><big>(</big><em>name</em>, <em>mode='readonly'</em>, <em>memmap=None</em>, <em>save_backup=False</em>, <em>**kwargs</em><big>)</big><a class="reference external" href="http://github.com/astropy/astropy/tree/v0.2.4/astropy/io/fits.py#L25" title="Push the Edit button on the next page"><span class="edit-on-github viewcode-link">&nbsp;[edit on github]</span></a><a class="headerlink" href="#astropy.io.fits.open" title="Permalink to this definition">¶</a></dt>
<dd><p>Factory function to open a FITS file and return an <a class="reference internal" href="hdulists.html#astropy.io.fits.HDUList" title="astropy.io.fits.HDUList"><tt class="xref py py-obj docutils literal"><span class="pre">HDUList</span></tt></a> object.</p>
<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>name</strong> : file path, file object or file-like object</p>
<blockquote>
<div><p>File to be opened.</p>
</div></blockquote>
<p><strong>mode</strong> : str</p>
<blockquote>
<div><p>Open mode, &#8216;readonly&#8217; (default), &#8216;update&#8217;, &#8216;append&#8217;, &#8216;denywrite&#8217;, or
&#8216;ostream&#8217;.</p>
<p>If <tt class="xref py py-obj docutils literal"><span class="pre">name</span></tt> is a file object that is already opened, <tt class="xref py py-obj docutils literal"><span class="pre">mode</span></tt> must
match the mode the file was opened with, copyonwrite (rb),
readonly (rb), update (rb+), append (ab+), ostream (w),
denywrite (rb)).</p>
</div></blockquote>
<p><strong>memmap</strong> : bool</p>
<blockquote>
<div><p>Is memory mapping to be used?</p>
</div></blockquote>
<p><strong>save_backup</strong> : bool</p>
<blockquote>
<div><p>If the file was opened in update or append mode, this ensures that a
backup of the original file is saved before any changes are flushed.
The backup has the same name as the original file with &#8221;.bak&#8221; appended.
If &#8220;file.bak&#8221; already exists then &#8220;file.bak.1&#8221; is used, and so on.</p>
</div></blockquote>
<p><strong>kwargs</strong> : dict</p>
<blockquote>
<div><p>optional keyword arguments, possible values are:</p>
<ul>
<li><p class="first"><strong>uint</strong> : bool</p>
<blockquote>
<div><p>Interpret signed integer data where <tt class="docutils literal"><span class="pre">BZERO</span></tt> is the
central value and <tt class="docutils literal"><span class="pre">BSCALE</span> <span class="pre">==</span> <span class="pre">1</span></tt> as unsigned integer
data.  For example, <tt class="xref py py-obj docutils literal"><span class="pre">int16</span></tt> data with <tt class="docutils literal"><span class="pre">BZERO</span> <span class="pre">=</span> <span class="pre">32768</span></tt>
and <tt class="docutils literal"><span class="pre">BSCALE</span> <span class="pre">=</span> <span class="pre">1</span></tt> would be treated as <tt class="xref py py-obj docutils literal"><span class="pre">uint16</span></tt> data.</p>
<p>Note, for backward compatibility, the kwarg <strong>uint16</strong> may
be used instead.  The kwarg was renamed when support was
added for integers of any size.</p>
</div></blockquote>
</li>
<li><p class="first"><strong>ignore_missing_end</strong> : bool</p>
<blockquote>
<div><p>Do not issue an exception when opening a file that is
missing an <tt class="docutils literal"><span class="pre">END</span></tt> card in the last header.</p>
</div></blockquote>
</li>
<li><p class="first"><strong>checksum</strong> : bool, str</p>
<blockquote>
<div><p>If <tt class="xref py py-obj docutils literal"><span class="pre">True</span></tt>, verifies that both <tt class="docutils literal"><span class="pre">DATASUM</span></tt> and
<tt class="docutils literal"><span class="pre">CHECKSUM</span></tt> card values (when present in the HDU header)
match the header and data of all HDU&#8217;s in the file.  Updates to a
file that already has a checksum will preserve and update the
existing checksums unless this argument is given a value of
&#8216;remove&#8217;, in which case the CHECKSUM and DATASUM values are not
checked, and are removed when saving changes to the file.</p>
</div></blockquote>
</li>
<li><p class="first"><strong>disable_image_compression</strong> : bool</p>
<blockquote>
<div><p>If <tt class="xref py py-obj docutils literal"><span class="pre">True</span></tt>, treates compressed image HDU&#8217;s like normal
binary table HDU&#8217;s.</p>
</div></blockquote>
</li>
<li><p class="first"><strong>do_not_scale_image_data</strong> : bool</p>
<blockquote>
<div><p>If <tt class="xref py py-obj docutils literal"><span class="pre">True</span></tt>, image data is not scaled using BSCALE/BZERO values
when read.</p>
</div></blockquote>
</li>
<li><p class="first"><strong>scale_back</strong> : bool</p>
<blockquote>
<div><p>If <tt class="xref py py-obj docutils literal"><span class="pre">True</span></tt>, when saving changes to a file that contained scaled
image data, restore the data to the original type and reapply the
original BSCALE/BZERO values.  This could lead to loss of accuracy
if scaling back to integer values after performing floating point
operations on the data.</p>
</div></blockquote>
</li>
</ul>
</div></blockquote>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns :</th><td class="field-body"><p class="first"><strong>hdulist</strong> : an <a class="reference internal" href="hdulists.html#astropy.io.fits.HDUList" title="astropy.io.fits.HDUList"><tt class="xref py py-obj docutils literal"><span class="pre">HDUList</span></tt></a> object</p>
<blockquote class="last">
<div><p><a class="reference internal" href="hdulists.html#astropy.io.fits.HDUList" title="astropy.io.fits.HDUList"><tt class="xref py py-obj docutils literal"><span class="pre">HDUList</span></tt></a> containing all of the header data units in the
file.</p>
</div></blockquote>
</td>
</tr>
</tbody>
</table>
</dd></dl>

</div>
<div class="section" id="writeto">
<h2><a class="reference internal" href="#astropy.io.fits.writeto" title="astropy.io.fits.writeto"><tt class="xref py py-func docutils literal"><span class="pre">writeto()</span></tt></a><a class="headerlink" href="#writeto" title="Permalink to this headline">¶</a></h2>
<dl class="function">
<dt id="astropy.io.fits.writeto">
<tt class="descclassname">astropy.io.fits.</tt><tt class="descname">writeto</tt><big>(</big><em>filename</em>, <em>data</em>, <em>header=None</em>, <em>output_verify='exception'</em>, <em>clobber=False</em>, <em>checksum=False</em><big>)</big><a class="reference external" href="http://github.com/astropy/astropy/tree/v0.2.4/astropy/io/fits.py#L370" title="Push the Edit button on the next page"><span class="edit-on-github viewcode-link">&nbsp;[edit on github]</span></a><a class="headerlink" href="#astropy.io.fits.writeto" title="Permalink to this definition">¶</a></dt>
<dd><p>Create a new FITS file using the supplied data/header.</p>
<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>filename</strong> : file path, file object, or file like object</p>
<blockquote>
<div><p>File to write to.  If opened, must be opened for append (ab+).</p>
</div></blockquote>
<p><strong>data</strong> : array, record array, or groups data object</p>
<blockquote>
<div><p>data to write to the new file</p>
</div></blockquote>
<p><strong>header</strong> : <a class="reference internal" href="headers.html#astropy.io.fits.Header" title="astropy.io.fits.Header"><tt class="xref py py-obj docutils literal"><span class="pre">Header</span></tt></a> object (optional)</p>
<blockquote>
<div><p>the header associated with <tt class="xref py py-obj docutils literal"><span class="pre">data</span></tt>. If <tt class="xref py py-obj docutils literal"><span class="pre">None</span></tt>, a header
of the appropriate type is created for the supplied data. This
argument is optional.</p>
</div></blockquote>
<p><strong>output_verify</strong> : str</p>
<blockquote>
<div><p>Output verification option.  Must be one of <tt class="docutils literal"><span class="pre">&quot;fix&quot;</span></tt>,
<tt class="docutils literal"><span class="pre">&quot;silentfix&quot;</span></tt>, <tt class="docutils literal"><span class="pre">&quot;ignore&quot;</span></tt>, <tt class="docutils literal"><span class="pre">&quot;warn&quot;</span></tt>, or
<tt class="docutils literal"><span class="pre">&quot;exception&quot;</span></tt>.  See <a class="reference internal" href="verification.html#verify"><em>Verification options</em></a> for more info.</p>
</div></blockquote>
<p><strong>clobber</strong> : bool (optional)</p>
<blockquote>
<div><p>If <tt class="xref py py-obj docutils literal"><span class="pre">True</span></tt>, and if filename already exists, it will overwrite
the file.  Default is <tt class="xref py py-obj docutils literal"><span class="pre">False</span></tt>.</p>
</div></blockquote>
<p><strong>checksum</strong> : bool (optional)</p>
<blockquote class="last">
<div><p>If <tt class="xref py py-obj docutils literal"><span class="pre">True</span></tt>, adds both <tt class="docutils literal"><span class="pre">DATASUM</span></tt> and <tt class="docutils literal"><span class="pre">CHECKSUM</span></tt> cards to the
headers of all HDU&#8217;s written to the file.</p>
</div></blockquote>
</td>
</tr>
</tbody>
</table>
</dd></dl>

</div>
<div class="section" id="info">
<h2><a class="reference internal" href="#astropy.io.fits.info" title="astropy.io.fits.info"><tt class="xref py py-func docutils literal"><span class="pre">info()</span></tt></a><a class="headerlink" href="#info" title="Permalink to this headline">¶</a></h2>
<dl class="function">
<dt id="astropy.io.fits.info">
<tt class="descclassname">astropy.io.fits.</tt><tt class="descname">info</tt><big>(</big><em>filename</em>, <em>output=None</em>, <em>**kwargs</em><big>)</big><a class="reference external" href="http://github.com/astropy/astropy/tree/v0.2.4/astropy/io/fits.py#L534" title="Push the Edit button on the next page"><span class="edit-on-github viewcode-link">&nbsp;[edit on github]</span></a><a class="headerlink" href="#astropy.io.fits.info" title="Permalink to this definition">¶</a></dt>
<dd><p>Print the summary information on a FITS file.</p>
<p>This includes the name, type, length of header, data shape and type
for each extension.</p>
<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>filename</strong> : file path, file object, or file like object</p>
<blockquote>
<div><p>FITS file to obtain info from.  If opened, mode must be one of
the following: rb, rb+, or ab+.</p>
</div></blockquote>
<p><strong>output</strong> : file (optional)</p>
<blockquote>
<div><p>File-like object to output the HDU info to.  Outputs to stdout by
default.</p>
</div></blockquote>
<p><strong>kwargs</strong> :</p>
<blockquote class="last">
<div><p>Any additional keyword arguments to be passed to
<a class="reference internal" href="#astropy.io.fits.open" title="astropy.io.fits.open"><tt class="xref py py-obj docutils literal"><span class="pre">astropy.io.fits.open</span></tt></a>.
<em>Note:</em> This function sets <tt class="docutils literal"><span class="pre">ignore_missing_end=True</span></tt> by default.</p>
</div></blockquote>
</td>
</tr>
</tbody>
</table>
</dd></dl>

</div>
<div class="section" id="append">
<h2><a class="reference internal" href="#astropy.io.fits.append" title="astropy.io.fits.append"><tt class="xref py py-func docutils literal"><span class="pre">append()</span></tt></a><a class="headerlink" href="#append" title="Permalink to this headline">¶</a></h2>
<dl class="function">
<dt id="astropy.io.fits.append">
<tt class="descclassname">astropy.io.fits.</tt><tt class="descname">append</tt><big>(</big><em>filename</em>, <em>data</em>, <em>header=None</em>, <em>checksum=False</em>, <em>verify=True</em>, <em>**kwargs</em><big>)</big><a class="reference external" href="http://github.com/astropy/astropy/tree/v0.2.4/astropy/io/fits.py#L409" title="Push the Edit button on the next page"><span class="edit-on-github viewcode-link">&nbsp;[edit on github]</span></a><a class="headerlink" href="#astropy.io.fits.append" title="Permalink to this definition">¶</a></dt>
<dd><p>Append the header/data to FITS file if filename exists, create if not.</p>
<p>If only <tt class="xref py py-obj docutils literal"><span class="pre">data</span></tt> is supplied, a minimal header is created.</p>
<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>filename</strong> : file path, file object, or file like object</p>
<blockquote>
<div><p>File to write to.  If opened, must be opened for update (rb+)
unless it is a new file, then it must be opened for append
(ab+).  A file or <tt class="xref py py-obj docutils literal"><span class="pre">GzipFile</span></tt> object opened for update will be
closed after return.</p>
</div></blockquote>
<p><strong>data</strong> : array, table, or group data object</p>
<blockquote>
<div><p>the new data used for appending</p>
</div></blockquote>
<p><strong>header</strong> : <a class="reference internal" href="headers.html#astropy.io.fits.Header" title="astropy.io.fits.Header"><tt class="xref py py-obj docutils literal"><span class="pre">Header</span></tt></a> object (optional)</p>
<blockquote>
<div><p>The header associated with <tt class="xref py py-obj docutils literal"><span class="pre">data</span></tt>.  If <tt class="xref py py-obj docutils literal"><span class="pre">None</span></tt>, an appropriate
header will be created for the data object supplied.</p>
</div></blockquote>
<p><strong>checksum</strong> : bool (optional)</p>
<blockquote>
<div><p>When <tt class="xref py py-obj docutils literal"><span class="pre">True</span></tt> adds both <tt class="docutils literal"><span class="pre">DATASUM</span></tt> and <tt class="docutils literal"><span class="pre">CHECKSUM</span></tt> cards to
the header of the HDU when written to the file.</p>
</div></blockquote>
<p><strong>verify: bool (optional)</strong> :</p>
<blockquote>
<div><p>When <tt class="xref py py-obj docutils literal"><span class="pre">True</span></tt>, the existing FITS file will be read in to verify
it for correctness before appending.  When <tt class="xref py py-obj docutils literal"><span class="pre">False</span></tt>, content is
simply appended to the end of the file.  Setting <em>verify</em> to
<tt class="xref py py-obj docutils literal"><span class="pre">False</span></tt> can be much faster.</p>
</div></blockquote>
<p><strong>kwargs</strong> :</p>
<blockquote class="last">
<div><p>Any additional keyword arguments to be passed to
<a class="reference internal" href="#astropy.io.fits.open" title="astropy.io.fits.open"><tt class="xref py py-obj docutils literal"><span class="pre">astropy.io.fits.open</span></tt></a>.</p>
</div></blockquote>
</td>
</tr>
</tbody>
</table>
</dd></dl>

</div>
<div class="section" id="update">
<h2><a class="reference internal" href="#astropy.io.fits.update" title="astropy.io.fits.update"><tt class="xref py py-func docutils literal"><span class="pre">update()</span></tt></a><a class="headerlink" href="#update" title="Permalink to this headline">¶</a></h2>
<dl class="function">
<dt id="astropy.io.fits.update">
<tt class="descclassname">astropy.io.fits.</tt><tt class="descname">update</tt><big>(</big><em>filename</em>, <em>data</em>, <em>*args</em>, <em>**kwargs</em><big>)</big><a class="reference external" href="http://github.com/astropy/astropy/tree/v0.2.4/astropy/io/fits.py#L475" title="Push the Edit button on the next page"><span class="edit-on-github viewcode-link">&nbsp;[edit on github]</span></a><a class="headerlink" href="#astropy.io.fits.update" title="Permalink to this definition">¶</a></dt>
<dd><p>Update the specified extension with the input data/header.</p>
<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>filename</strong> : file path, file object, or file like object</p>
<blockquote>
<div><p>File to update.  If opened, mode must be update (rb+).  An
opened file object or <tt class="xref py py-obj docutils literal"><span class="pre">GzipFile</span></tt> object will be closed upon
return.</p>
</div></blockquote>
<p><strong>data</strong> : array, table, or group data object</p>
<blockquote>
<div><p>the new data used for updating</p>
</div></blockquote>
<p><strong>header</strong> : <a class="reference internal" href="headers.html#astropy.io.fits.Header" title="astropy.io.fits.Header"><tt class="xref py py-obj docutils literal"><span class="pre">Header</span></tt></a> object (optional)</p>
<blockquote>
<div><p>The header associated with <tt class="xref py py-obj docutils literal"><span class="pre">data</span></tt>.  If <tt class="xref py py-obj docutils literal"><span class="pre">None</span></tt>, an appropriate
header will be created for the data object supplied.</p>
</div></blockquote>
<p><strong>ext, extname, extver</strong> :</p>
<blockquote>
<div><p>The rest of the arguments are flexible: the 3rd argument can
be the header associated with the data.  If the 3rd argument
is not a <a class="reference internal" href="headers.html#astropy.io.fits.Header" title="astropy.io.fits.Header"><tt class="xref py py-obj docutils literal"><span class="pre">Header</span></tt></a>, it (and other positional arguments) are
assumed to be the extension specification(s).  Header and
extension specs can also be keyword arguments.  For example:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">update</span><span class="p">(</span><span class="nb">file</span><span class="p">,</span> <span class="n">dat</span><span class="p">,</span> <span class="n">hdr</span><span class="p">,</span> <span class="s">&#39;sci&#39;</span><span class="p">)</span>  <span class="c"># update the &#39;sci&#39; extension</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">update</span><span class="p">(</span><span class="nb">file</span><span class="p">,</span> <span class="n">dat</span><span class="p">,</span> <span class="mi">3</span><span class="p">)</span>  <span class="c"># update the 3rd extension</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">update</span><span class="p">(</span><span class="nb">file</span><span class="p">,</span> <span class="n">dat</span><span class="p">,</span> <span class="n">hdr</span><span class="p">,</span> <span class="mi">3</span><span class="p">)</span>  <span class="c"># update the 3rd extension</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">update</span><span class="p">(</span><span class="nb">file</span><span class="p">,</span> <span class="n">dat</span><span class="p">,</span> <span class="s">&#39;sci&#39;</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span>  <span class="c"># update the 2nd SCI extension</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">update</span><span class="p">(</span><span class="nb">file</span><span class="p">,</span> <span class="n">dat</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="n">header</span><span class="o">=</span><span class="n">hdr</span><span class="p">)</span>  <span class="c"># update the 3rd extension</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">update</span><span class="p">(</span><span class="nb">file</span><span class="p">,</span> <span class="n">dat</span><span class="p">,</span> <span class="n">header</span><span class="o">=</span><span class="n">hdr</span><span class="p">,</span> <span class="n">ext</span><span class="o">=</span><span class="mi">5</span><span class="p">)</span> <span class="c"># update the 5th extension</span>
</pre></div>
</div>
</div></blockquote>
<p><strong>kwargs</strong> :</p>
<blockquote class="last">
<div><p>Any additional keyword arguments to be passed to
<a class="reference internal" href="#astropy.io.fits.open" title="astropy.io.fits.open"><tt class="xref py py-obj docutils literal"><span class="pre">astropy.io.fits.open</span></tt></a>.</p>
</div></blockquote>
</td>
</tr>
</tbody>
</table>
</dd></dl>

</div>
<div class="section" id="getdata">
<h2><a class="reference internal" href="#astropy.io.fits.getdata" title="astropy.io.fits.getdata"><tt class="xref py py-func docutils literal"><span class="pre">getdata()</span></tt></a><a class="headerlink" href="#getdata" title="Permalink to this headline">¶</a></h2>
<dl class="function">
<dt id="astropy.io.fits.getdata">
<tt class="descclassname">astropy.io.fits.</tt><tt class="descname">getdata</tt><big>(</big><em>filename</em>, <em>*args</em>, <em>**kwargs</em><big>)</big><a class="reference external" href="http://github.com/astropy/astropy/tree/v0.2.4/astropy/io/fits.py#L109" title="Push the Edit button on the next page"><span class="edit-on-github viewcode-link">&nbsp;[edit on github]</span></a><a class="headerlink" href="#astropy.io.fits.getdata" title="Permalink to this definition">¶</a></dt>
<dd><p>Get the data from an extension of a FITS file (and optionally the
header).</p>
<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>filename</strong> : file path, file object, or file like object</p>
<blockquote>
<div><p>File to get data from.  If opened, mode must be one of the
following rb, rb+, or ab+.</p>
</div></blockquote>
<p><strong>ext</strong> :</p>
<blockquote>
<div><p>The rest of the arguments are for extension specification.
They are flexible and are best illustrated by examples.</p>
<p>No extra arguments implies the primary header:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">getdata</span><span class="p">(</span><span class="s">&#39;in.fits&#39;</span><span class="p">)</span>
</pre></div>
</div>
<p>By extension number:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">getdata</span><span class="p">(</span><span class="s">&#39;in.fits&#39;</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span>    <span class="c"># the primary header</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">getdata</span><span class="p">(</span><span class="s">&#39;in.fits&#39;</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span>    <span class="c"># the second extension</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">getdata</span><span class="p">(</span><span class="s">&#39;in.fits&#39;</span><span class="p">,</span> <span class="n">ext</span><span class="o">=</span><span class="mi">2</span><span class="p">)</span> <span class="c"># the second extension</span>
</pre></div>
</div>
<p>By name, i.e., <tt class="docutils literal"><span class="pre">EXTNAME</span></tt> value (if unique):</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">getdata</span><span class="p">(</span><span class="s">&#39;in.fits&#39;</span><span class="p">,</span> <span class="s">&#39;sci&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">getdata</span><span class="p">(</span><span class="s">&#39;in.fits&#39;</span><span class="p">,</span> <span class="n">extname</span><span class="o">=</span><span class="s">&#39;sci&#39;</span><span class="p">)</span> <span class="c"># equivalent</span>
</pre></div>
</div>
<p>Note <tt class="docutils literal"><span class="pre">EXTNAME</span></tt> values are not case sensitive</p>
<p>By combination of <tt class="docutils literal"><span class="pre">EXTNAME</span></tt> and EXTVER`` as separate
arguments or as a tuple:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">getdata</span><span class="p">(</span><span class="s">&#39;in.fits&#39;</span><span class="p">,</span> <span class="s">&#39;sci&#39;</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span> <span class="c"># EXTNAME=&#39;SCI&#39; &amp; EXTVER=2</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">getdata</span><span class="p">(</span><span class="s">&#39;in.fits&#39;</span><span class="p">,</span> <span class="n">extname</span><span class="o">=</span><span class="s">&#39;sci&#39;</span><span class="p">,</span> <span class="n">extver</span><span class="o">=</span><span class="mi">2</span><span class="p">)</span> <span class="c"># equivalent</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">getdata</span><span class="p">(</span><span class="s">&#39;in.fits&#39;</span><span class="p">,</span> <span class="p">(</span><span class="s">&#39;sci&#39;</span><span class="p">,</span> <span class="mi">2</span><span class="p">))</span> <span class="c"># equivalent</span>
</pre></div>
</div>
<p>Ambiguous or conflicting specifications will raise an exception:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">getdata</span><span class="p">(</span><span class="s">&#39;in.fits&#39;</span><span class="p">,</span> <span class="n">ext</span><span class="o">=</span><span class="p">(</span><span class="s">&#39;sci&#39;</span><span class="p">,</span><span class="mi">1</span><span class="p">),</span> <span class="n">extname</span><span class="o">=</span><span class="s">&#39;err&#39;</span><span class="p">,</span> <span class="n">extver</span><span class="o">=</span><span class="mi">2</span><span class="p">)</span>
</pre></div>
</div>
</div></blockquote>
<p><strong>header</strong> : bool (optional)</p>
<blockquote>
<div><p>If <tt class="xref py py-obj docutils literal"><span class="pre">True</span></tt>, return the data and the header of the specified HDU as a
tuple.</p>
</div></blockquote>
<p><strong>lower, upper</strong> : bool (optional)</p>
<blockquote>
<div><p>If <tt class="xref py py-obj docutils literal"><span class="pre">lower</span></tt> or <tt class="xref py py-obj docutils literal"><span class="pre">upper</span></tt> are <tt class="xref py py-obj docutils literal"><span class="pre">True</span></tt>, the field names in the
returned data object will be converted to lower or upper case,
respectively.</p>
</div></blockquote>
<p><strong>view</strong> : ndarray (optional)</p>
<blockquote>
<div><p>When given, the data will be turned wrapped in the given ndarray
subclass by calling:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">data</span><span class="o">.</span><span class="n">view</span><span class="p">(</span><span class="n">view</span><span class="p">)</span>
</pre></div>
</div>
</div></blockquote>
<p><strong>kwargs</strong> :</p>
<blockquote>
<div><p>Any additional keyword arguments to be passed to
<a class="reference internal" href="#astropy.io.fits.open" title="astropy.io.fits.open"><tt class="xref py py-obj docutils literal"><span class="pre">astropy.io.fits.open</span></tt></a>.</p>
</div></blockquote>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns :</th><td class="field-body"><p class="first"><strong>array</strong> : array, record array or groups data object</p>
<blockquote class="last">
<div><p>Type depends on the type of the extension being referenced.</p>
<p>If the optional keyword <tt class="xref py py-obj docutils literal"><span class="pre">header</span></tt> is set to <tt class="xref py py-obj docutils literal"><span class="pre">True</span></tt>, this
function will return a (<tt class="xref py py-obj docutils literal"><span class="pre">data</span></tt>, <tt class="xref py py-obj docutils literal"><span class="pre">header</span></tt>) tuple.</p>
</div></blockquote>
</td>
</tr>
</tbody>
</table>
</dd></dl>

</div>
<div class="section" id="getheader">
<h2><a class="reference internal" href="#astropy.io.fits.getheader" title="astropy.io.fits.getheader"><tt class="xref py py-func docutils literal"><span class="pre">getheader()</span></tt></a><a class="headerlink" href="#getheader" title="Permalink to this headline">¶</a></h2>
<dl class="function">
<dt id="astropy.io.fits.getheader">
<tt class="descclassname">astropy.io.fits.</tt><tt class="descname">getheader</tt><big>(</big><em>filename</em>, <em>*args</em>, <em>**kwargs</em><big>)</big><a class="reference external" href="http://github.com/astropy/astropy/tree/v0.2.4/astropy/io/fits.py#L78" title="Push the Edit button on the next page"><span class="edit-on-github viewcode-link">&nbsp;[edit on github]</span></a><a class="headerlink" href="#astropy.io.fits.getheader" title="Permalink to this definition">¶</a></dt>
<dd><p>Get the header from an extension of a FITS file.</p>
<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>filename</strong> : file path, file object, or file like object</p>
<blockquote>
<div><p>File to get header from.  If an opened file object, its mode
must be one of the following rb, rb+, or ab+).</p>
</div></blockquote>
<p><strong>ext, extname, extver</strong> :</p>
<blockquote>
<div><p>The rest of the arguments are for extension specification.  See the
<a class="reference internal" href="#astropy.io.fits.getdata" title="astropy.io.fits.getdata"><tt class="xref py py-obj docutils literal"><span class="pre">getdata</span></tt></a> documentation for explanations/examples.</p>
</div></blockquote>
<p><strong>kwargs</strong> :</p>
<blockquote>
<div><p>Any additional keyword arguments to be passed to
<a class="reference internal" href="#astropy.io.fits.open" title="astropy.io.fits.open"><tt class="xref py py-obj docutils literal"><span class="pre">astropy.io.fits.open</span></tt></a>.</p>
</div></blockquote>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns :</th><td class="field-body"><p class="first last"><strong>header</strong> : <a class="reference internal" href="headers.html#astropy.io.fits.Header" title="astropy.io.fits.Header"><tt class="xref py py-obj docutils literal"><span class="pre">Header</span></tt></a> object</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>

</div>
<div class="section" id="getval">
<h2><a class="reference internal" href="#astropy.io.fits.getval" title="astropy.io.fits.getval"><tt class="xref py py-func docutils literal"><span class="pre">getval()</span></tt></a><a class="headerlink" href="#getval" title="Permalink to this headline">¶</a></h2>
<dl class="function">
<dt id="astropy.io.fits.getval">
<tt class="descclassname">astropy.io.fits.</tt><tt class="descname">getval</tt><big>(</big><em>filename</em>, <em>keyword</em>, <em>*args</em>, <em>**kwargs</em><big>)</big><a class="reference external" href="http://github.com/astropy/astropy/tree/v0.2.4/astropy/io/fits.py#L227" title="Push the Edit button on the next page"><span class="edit-on-github viewcode-link">&nbsp;[edit on github]</span></a><a class="headerlink" href="#astropy.io.fits.getval" title="Permalink to this definition">¶</a></dt>
<dd><p>Get a keyword&#8217;s value from a header in a FITS file.</p>
<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>filename</strong> : file path, file object, or file like object</p>
<blockquote>
<div><p>Name of the FITS file, or file object (if opened, mode must be
one of the following rb, rb+, or ab+).</p>
</div></blockquote>
<p><strong>keyword</strong> : str</p>
<blockquote>
<div><p>Keyword name</p>
</div></blockquote>
<p><strong>ext, extname, extver</strong> :</p>
<blockquote>
<div><p>The rest of the arguments are for extension specification.
See <a class="reference internal" href="#astropy.io.fits.getdata" title="astropy.io.fits.getdata"><tt class="xref py py-obj docutils literal"><span class="pre">getdata</span></tt></a> for explanations/examples.</p>
</div></blockquote>
<p><strong>kwargs</strong> :</p>
<blockquote>
<div><p>Any additional keyword arguments to be passed to
<a class="reference internal" href="#astropy.io.fits.open" title="astropy.io.fits.open"><tt class="xref py py-obj docutils literal"><span class="pre">astropy.io.fits.open</span></tt></a>.
<em>Note:</em> This function automatically specifies <tt class="docutils literal"><span class="pre">do_not_scale_image_data</span>
<span class="pre">=</span> <span class="pre">True</span></tt> when opening the file so that values can be retrieved from the
unmodified header.</p>
</div></blockquote>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns :</th><td class="field-body"><p class="first last"><strong>keyword value</strong> : string, integer, or float</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>

</div>
<div class="section" id="setval">
<h2><a class="reference internal" href="#astropy.io.fits.setval" title="astropy.io.fits.setval"><tt class="xref py py-func docutils literal"><span class="pre">setval()</span></tt></a><a class="headerlink" href="#setval" title="Permalink to this headline">¶</a></h2>
<dl class="function">
<dt id="astropy.io.fits.setval">
<tt class="descclassname">astropy.io.fits.</tt><tt class="descname">setval</tt><big>(</big><em>filename</em>, <em>keyword</em>, <em>*args</em>, <em>**kwargs</em><big>)</big><a class="reference external" href="http://github.com/astropy/astropy/tree/v0.2.4/astropy/io/fits.py#L263" title="Push the Edit button on the next page"><span class="edit-on-github viewcode-link">&nbsp;[edit on github]</span></a><a class="headerlink" href="#astropy.io.fits.setval" title="Permalink to this definition">¶</a></dt>
<dd><p>Set a keyword&#8217;s value from a header in a FITS file.</p>
<p>If the keyword already exists, it&#8217;s value/comment will be updated.
If it does not exist, a new card will be created and it will be
placed before or after the specified location.  If no <tt class="xref py py-obj docutils literal"><span class="pre">before</span></tt> or
<tt class="xref py py-obj docutils literal"><span class="pre">after</span></tt> is specified, it will be appended at the end.</p>
<p>When updating more than one keyword in a file, this convenience
function is a much less efficient approach compared with opening
the file for update, modifying the header, and closing the file.</p>
<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>filename</strong> : file path, file object, or file like object</p>
<blockquote>
<div><p>Name of the FITS file, or file object If opened, mode must be
update (rb+).  An opened file object or <tt class="xref py py-obj docutils literal"><span class="pre">GzipFile</span></tt> object will
be closed upon return.</p>
</div></blockquote>
<p><strong>keyword</strong> : str</p>
<blockquote>
<div><p>Keyword name</p>
</div></blockquote>
<p><strong>value</strong> : str, int, float (optional)</p>
<blockquote>
<div><p>Keyword value (default: <tt class="xref py py-obj docutils literal"><span class="pre">None</span></tt>, meaning don&#8217;t modify)</p>
</div></blockquote>
<p><strong>comment</strong> : str (optional)</p>
<blockquote>
<div><p>Keyword comment, (default: <tt class="xref py py-obj docutils literal"><span class="pre">None</span></tt>, meaning don&#8217;t modify)</p>
</div></blockquote>
<p><strong>before</strong> : str, int (optional)</p>
<blockquote>
<div><p>Name of the keyword, or index of the card before which the new card
will be placed.  The argument <tt class="xref py py-obj docutils literal"><span class="pre">before</span></tt> takes precedence over <tt class="xref py py-obj docutils literal"><span class="pre">after</span></tt> if
both are specified (default: <tt class="xref py py-obj docutils literal"><span class="pre">None</span></tt>).</p>
</div></blockquote>
<p><strong>after</strong> : str, int (optional)</p>
<blockquote>
<div><p>Name of the keyword, or index of the card after which the new card will
be placed. (default: <tt class="xref py py-obj docutils literal"><span class="pre">None</span></tt>).</p>
</div></blockquote>
<p><strong>savecomment</strong> : bool (optional)</p>
<blockquote>
<div><p>When <tt class="xref py py-obj docutils literal"><span class="pre">True</span></tt>, preserve the current comment for an existing keyword.  The
argument <tt class="xref py py-obj docutils literal"><span class="pre">savecomment</span></tt> takes precedence over <tt class="xref py py-obj docutils literal"><span class="pre">comment</span></tt> if both
specified.  If <tt class="xref py py-obj docutils literal"><span class="pre">comment</span></tt> is not specified then the current comment will
automatically be preserved  (default: <tt class="xref py py-obj docutils literal"><span class="pre">False</span></tt>).</p>
</div></blockquote>
<p><strong>ext, extname, extver</strong> :</p>
<blockquote>
<div><p>The rest of the arguments are for extension specification.
See <a class="reference internal" href="#astropy.io.fits.getdata" title="astropy.io.fits.getdata"><tt class="xref py py-obj docutils literal"><span class="pre">getdata</span></tt></a> for explanations/examples.</p>
</div></blockquote>
<p><strong>kwargs</strong> :</p>
<blockquote class="last">
<div><p>Any additional keyword arguments to be passed to
<a class="reference internal" href="#astropy.io.fits.open" title="astropy.io.fits.open"><tt class="xref py py-obj docutils literal"><span class="pre">astropy.io.fits.open</span></tt></a>.
<em>Note:</em> This function automatically specifies <tt class="docutils literal"><span class="pre">do_not_scale_image_data</span>
<span class="pre">=</span> <span class="pre">True</span></tt> when opening the file so that values can be retrieved from the
unmodified header.</p>
</div></blockquote>
</td>
</tr>
</tbody>
</table>
</dd></dl>

</div>
<div class="section" id="delval">
<h2><a class="reference internal" href="#astropy.io.fits.delval" title="astropy.io.fits.delval"><tt class="xref py py-func docutils literal"><span class="pre">delval()</span></tt></a><a class="headerlink" href="#delval" title="Permalink to this headline">¶</a></h2>
<dl class="function">
<dt id="astropy.io.fits.delval">
<tt class="descclassname">astropy.io.fits.</tt><tt class="descname">delval</tt><big>(</big><em>filename</em>, <em>keyword</em>, <em>*args</em>, <em>**kwargs</em><big>)</big><a class="reference external" href="http://github.com/astropy/astropy/tree/v0.2.4/astropy/io/fits.py#L335" title="Push the Edit button on the next page"><span class="edit-on-github viewcode-link">&nbsp;[edit on github]</span></a><a class="headerlink" href="#astropy.io.fits.delval" title="Permalink to this definition">¶</a></dt>
<dd><p>Delete all instances of keyword from a header in a FITS file.</p>
<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>filename</strong> : file path, file object, or file like object</p>
<blockquote>
<div><p>Name of the FITS file, or file object If opened, mode must be
update (rb+).  An opened file object or <tt class="xref py py-obj docutils literal"><span class="pre">GzipFile</span></tt> object will
be closed upon return.</p>
</div></blockquote>
<p><strong>keyword</strong> : str, int</p>
<blockquote>
<div><p>Keyword name or index</p>
</div></blockquote>
<p><strong>ext, extname, extver</strong> :</p>
<blockquote>
<div><p>The rest of the arguments are for extension specification.
See <a class="reference internal" href="#astropy.io.fits.getdata" title="astropy.io.fits.getdata"><tt class="xref py py-obj docutils literal"><span class="pre">getdata</span></tt></a> for explanations/examples.</p>
</div></blockquote>
<p><strong>kwargs</strong> :</p>
<blockquote class="last">
<div><p>Any additional keyword arguments to be passed to
<a class="reference internal" href="#astropy.io.fits.open" title="astropy.io.fits.open"><tt class="xref py py-obj docutils literal"><span class="pre">astropy.io.fits.open</span></tt></a>.
<em>Note:</em> This function automatically specifies <tt class="docutils literal"><span class="pre">do_not_scale_image_data</span>
<span class="pre">=</span> <span class="pre">True</span></tt> when opening the file so that values can be retrieved from the
unmodified header.</p>
</div></blockquote>
</td>
</tr>
</tbody>
</table>
</dd></dl>

</div>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper"><h3>Page Contents</h3>
<ul>
<li><a class="reference internal" href="#">File Handling and Convenience Functions</a><ul>
<li><a class="reference internal" href="#open"><tt class="docutils literal"><span class="pre">open()</span></tt></a></li>
<li><a class="reference internal" href="#writeto"><tt class="docutils literal"><span class="pre">writeto()</span></tt></a></li>
<li><a class="reference internal" href="#info"><tt class="docutils literal"><span class="pre">info()</span></tt></a></li>
<li><a class="reference internal" href="#append"><tt class="docutils literal"><span class="pre">append()</span></tt></a></li>
<li><a class="reference internal" href="#update"><tt class="docutils literal"><span class="pre">update()</span></tt></a></li>
<li><a class="reference internal" href="#getdata"><tt class="docutils literal"><span class="pre">getdata()</span></tt></a></li>
<li><a class="reference internal" href="#getheader"><tt class="docutils literal"><span class="pre">getheader()</span></tt></a></li>
<li><a class="reference internal" href="#getval"><tt class="docutils literal"><span class="pre">getval()</span></tt></a></li>
<li><a class="reference internal" href="#setval"><tt class="docutils literal"><span class="pre">setval()</span></tt></a></li>
<li><a class="reference internal" href="#delval"><tt class="docutils literal"><span class="pre">delval()</span></tt></a></li>
</ul>
</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/io/fits/api/files.rst">Edit This Page on Github</a> &nbsp;
    <a href="../../../_sources/io/fits/api/files.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>