Skip to content

Error in reading long header values via astropy.io.fits #1

@demitri

Description

@demitri

Example:

from astropy.io import fits
from cornish  import ASTFrameSet 
hdu_list = fits.open("MISDR1_24278_0266_0001-nd-cat_mch_flagstar.fits.gz")  
hdu1 = hdu_list[0] 
f = ASTFrameSet.fromFITSHeader(hdu1.header)

Trace:

---------------------------------------------------------------------------
AssertionError                            Traceback (most recent call last)
<ipython-input-7-1361cb9c9c83> in <module>
----> 1 f = ASTFrameSet.fromFITSHeader(hdu1.header)

~/Documents/Repositories/GitHub/cornish/cornish/mapping/frame/frame_set.py in fromFITSHeader(fits_header)
    101                 from ...channel import ASTFITSChannel # or "from cornish import ..." ?
    102 
--> 103                 fits_channel = ASTFITSChannel(header=fits_header)
    104 
    105                 # does this channel contain a frame set?

~/Documents/Repositories/GitHub/cornish/cornish/channel/fits_channel.py in __init__(self, ast_object, hdu, header)
     86                         if isinstance(header, (astropy.io.fits.header.Header, fitsio.fitslib.FITSHDR)) or \
     87                            (isinstance(header, list) and isinstance(header[0], str)):
---> 88                            self._readHeader()
     89                         elif isinstance(header, list):
     90                                 logger.debug("Found list header")

~/Documents/Repositories/GitHub/cornish/cornish/channel/fits_channel.py in _readHeader(self)
    120                         #self.fitsChan = Ast.FitsChan(source="".join([c.image for x in hdu.header.cards]))
    121                         for card in self.header.cards:
--> 122                                 self.addHeader(card=card)
    123 
    124                 # try to read the header from an fitsio header object

~/Documents/Repositories/GitHub/cornish/cornish/channel/fits_channel.py in addHeader(self, card, keyword, value, comment, overwrite)
    274 #                                       raise Exception("Not implemented: handle value of type '{0}'.".format(type(value)))
    275 
--> 276                 assert len(fits_header_card) <= 80, "The FITS card is incorrectly formatted (>80 char) or a bad value has been given: '{0}'".format(fits_header_card)
    277 
    278                 self.astObject.putfits(fits_header_card, overwrite)

AssertionError: The FITS card is incorrectly formatted (>80 char) or a bad value has been given: 'SEXCAT  = '/home/eisa2/fltops/pipe/01-vsn/03000-MISDR1_24278_0266/d/00-visits/&'CONTINUE  '0001-img/07-try/MISDR1_24278_0266_0001-nd-cat.fits'                  '

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions