[AstroPy] PyFits not reading END value from header?

Michael Droettboom mdroe at stsci.edu
Tue Apr 5 07:56:43 EDT 2011


Can you send me (off list) the input fits files you are using?

For me, with your example code, pyfits rightfully complains since an 
extension HDU is being put in the zero'th place.

Cheers,
Mike

In [6]:     pf.update('test.fits',table_1,hdr_1)
---------------------------------------------------------------------------
VerifyError                               Traceback (most recent call last)
/wonkabar/sc1/scraps/fitswriter_data/miri/<ipython-input-6-8c4c189ca795> 
in <module>()
----> 1 pf.update('test.fits',table_1,hdr_1)

/home/mdroe/usr/lib/python2.7/site-packages/pyfits/core.pyc in 
update(filename, data, *ext, **extkeys)
   11030     hdulist[_ext] = new_hdu
   11031
 > 11032     hdulist.close(closed=closed)
   11033
   11034

/home/mdroe/usr/lib/python2.7/site-packages/pyfits/core.pyc in 
close(self, output_verify, verbose, closed)
   10192         if self.__file != None:
   10193             if self.__file.mode in ['append', 'update']:
 > 10194                 self.flush(output_verify=output_verify, 
verbose=verbose)
   10195
   10196             if closed and hasattr(self.__file, 'close'):

/home/mdroe/usr/lib/python2.7/site-packages/pyfits/core.pyc in 
flush(self, output_verify, verbose, classExtensions)
    9843
    9844         self.update_tbhdu()
-> 9845         self.verify(option=output_verify)
    9846
    9847         if self.__file.mode in ('append', 'ostream'):

/home/mdroe/usr/lib/python2.7/site-packages/pyfits/core.pyc in 
verify(self, option)
     259             warnings.warn(x)
     260         if _option == 'exception' and x:
--> 261             raise VerifyError, '\n'+x
     262
     263 def _pad(input):

VerifyError:
HDUList's 0th element is not a primary HDU.



On 04/04/2011 06:48 PM, Gerard Fitzpatrick wrote:
>
> Hello all,
>
>
> I've run into a small problem with pyfits. I am not sure if this is a 
> problem or simply down to my ignorance!
>
>
> 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.
>
>
> I am using version 2.3.1 on ubuntu 10.10
>
>
> The code is something like this:
>
>
>     import pyfits as pf
>
>
>     file='blah.fits'
>     fits_file=pf.open(file)
>     hdr_1=fits_file[1].header
>     table_1=fits_file[1].data
>     fits_file.close()
>     pf.update('test.fits',table_1,hdr_1)
>
>
>
>
>
>
> In place of pf.update I have also tried pf.append & pf.writeto.
>
>
> Regards,
>
>
> G
>
>
> _______________________________________________
> AstroPy mailing list
> AstroPy at scipy.org
> http://mail.scipy.org/mailman/listinfo/astropy
>    


-- 
Michael Droettboom
Science Software Branch
Space Telescope Science Institute
Baltimore, Maryland, USA

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/astropy/attachments/20110405/fe401f25/attachment.html>


More information about the AstroPy mailing list