<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html; charset=ISO-8859-1"
 http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Can you send me (off list) the input fits files you are using?<br>
<br>
For me, with your example code, pyfits rightfully complains since an
extension HDU is being put in the zero'th place.<br>
<br>
Cheers,<br>
Mike<br>
<br>
In [6]:     pf.update('test.fits',table_1,hdr_1)<br>
---------------------------------------------------------------------------<br>
VerifyError                               Traceback (most recent call
last)<br>
/wonkabar/sc1/scraps/fitswriter_data/miri/<ipython-input-6-8c4c189ca795>
in <module>()<br>
----> 1 pf.update('test.fits',table_1,hdr_1)<br>
<br>
/home/mdroe/usr/lib/python2.7/site-packages/pyfits/core.pyc in
update(filename, data, *ext, **extkeys)<br>
  11030     hdulist[_ext] = new_hdu<br>
  11031 <br>
> 11032     hdulist.close(closed=closed)<br>
  11033 <br>
  11034 <br>
<br>
/home/mdroe/usr/lib/python2.7/site-packages/pyfits/core.pyc in
close(self, output_verify, verbose, closed)<br>
  10192         if self.__file != None:<br>
  10193             if self.__file.mode in ['append', 'update']:<br>
> 10194                 self.flush(output_verify=output_verify,
verbose=verbose)<br>
  10195 <br>
  10196             if closed and hasattr(self.__file, 'close'):<br>
<br>
/home/mdroe/usr/lib/python2.7/site-packages/pyfits/core.pyc in
flush(self, output_verify, verbose, classExtensions)<br>
   9843 <br>
   9844         self.update_tbhdu()<br>
-> 9845         self.verify(option=output_verify)<br>
   9846 <br>
   9847         if self.__file.mode in ('append', 'ostream'):<br>
<br>
/home/mdroe/usr/lib/python2.7/site-packages/pyfits/core.pyc in
verify(self, option)<br>
    259             warnings.warn(x)<br>
    260         if _option == 'exception' and x:<br>
--> 261             raise VerifyError, '\n'+x<br>
    262 <br>
    263 def _pad(input):<br>
<br>
VerifyError: <br>
HDUList's 0th element is not a primary HDU.<br>
<br>
<br>
<br>
On 04/04/2011 06:48 PM, Gerard Fitzpatrick wrote:
<blockquote cite="mid:73d0d9a3ec68.4d9a58cc@ucd.ie" type="cite">
  <meta http-equiv="Content-Type"
 content="text/html; charset=ISO-8859-1">
  <br>
Hello all,<br>
  <br>
  <br>
I've run into a small problem with pyfits. I am not sure if this is a
problem or simply down to my ignorance! <br>
  <br>
  <br>
I am reading in  a header and table data from one file, then appending
it to another. The code throws an error: IOError: Header missing END
card. I can print the header and see that it is missing the End value.
I have tried this on three different fits files and continually run
into the same problem, this leads me to suspect that there is a
subtlety that I am missing. <br>
  <br>
  <br>
I am using version 2.3.1 on ubuntu 10.10<br>
  <br>
  <br>
The code is something like this:<br>
  <br>
  <blockquote class="webkit-indent-blockquote"
 style="border: medium none ; margin: 0pt 0pt 0pt 40px; padding: 0px;"><br>
import pyfits as pf<br>
    <br>
    <br>
file='blah.fits'<br>
fits_file=pf.open(file)<br>
hdr_1=fits_file[1].header<br>
table_1=fits_file[1].data<br>
fits_file.close()<br>
pf.update('test.fits',table_1,hdr_1)</blockquote>
  <br>
  <br>
  <br>
  <br>
  <br>
In place of pf.update I have also tried pf.append & pf.writeto.<br>
  <br>
  <br>
Regards,<br>
  <br>
  <br>
G
  <pre wrap="">
<fieldset class="mimeAttachmentHeader"></fieldset>
_______________________________________________
AstroPy mailing list
<a class="moz-txt-link-abbreviated" href="mailto:AstroPy@scipy.org">AstroPy@scipy.org</a>
<a class="moz-txt-link-freetext" href="http://mail.scipy.org/mailman/listinfo/astropy">http://mail.scipy.org/mailman/listinfo/astropy</a>
  </pre>
</blockquote>
<br>
<br>
<pre class="moz-signature" cols="72">-- 
Michael Droettboom
Science Software Branch
Space Telescope Science Institute
Baltimore, Maryland, USA</pre>
</body>
</html>