[AstroPy] pyfits: reading fits data problem

Perry Greenfield perry at stsci.edu
Tue May 26 15:21:59 EDT 2009

Well, we just made a change that causes an exception when the END  
statement is not found. That's the right solution to this particular  


On May 26, 2009, at 3:18 PM, Russell Owen wrote:

> I agree that it makes sense to give up on FITS files with newlines  
> and/or carriage returns in the header. But would it be practical for  
> pyfits to generate a more useful error message? Perhaps it could  
> test for nonprintable chars in the first 100 or so bytes of the file?
> -- Russell
> On May 26, 2009, at 8:32 AM, Perry Greenfield wrote:
>> On May 26, 2009, at 9:26 AM, Guillaume Blanc wrote:
>>> Thanks a lot for your quick replies...
>>> Actually my fits file was effectively not "standard". If I set the
>>> DATE keyword in the standard form (using the sethead script from
>>> wcstools), it works, even if the fits verifier says: "*** Error:
>>> File has extra byte(s) after last HDU at byte 63360." ??
>>> But perhaps the pyfits library is too tightly linked to the
>>> standard... And the error sent was quite enigmatic.
>>> Cheers,
>>> Guillaume
>> Apparently the fundamental problem is that the original file contains
>> newlines in the header. PyFITS is not finding the end of header as a
>> result and everything is thrown off regarding file size. It's  
>> possible
>> that in fixing the DATE value you fixed most of these newline issues
>> inadvertently (thus it looked like fixing date fixed the problem).
>> While we could spend time trying to have PyFITS handle all sorts of
>> nonstandard header characters, this is one we decided not to handle
>> explicitly. Whatever software is generating these newline-laden
>> headers really ought to be fixed instead.
>> Thanks, Perry
>> _______________________________________________
>> AstroPy mailing list
>> AstroPy at scipy.org
>> http://mail.scipy.org/mailman/listinfo/astropy

More information about the AstroPy mailing list