<html dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
<style id="owaParaStyle" type="text/css">P {margin-top:0;margin-bottom:0;}</style>
</head>
<body ocsi="0" fpstyle="1">
If you absolutely need to read this without modification and would like to live dangerously, you "may" be able to add the parameter<br>
<br>
ignore_missing_end=True<br>
<br>
to the fits.open call. I've had this issue before and seem to remember this working out. Its documented here as
<a href="http://docs.astropy.org/en/v0.4.2/io/fits/api/hdus.html" target="_blank">
part of the PrimaryHDU</a> class, hence I'm not sure if fits.open will pass the parameter down this far or not.<br>
<br>
jde<br>
<div><br>
<div style="font-family:Tahoma; font-size:13px">
<div style="font-family:Tahoma; font-size:13px">
<div style="font-family:Tahoma; font-size:13px">
<div style="font-family:Tahoma; font-size:13px">
<div style="font-family:Tahoma; font-size:13px">Jonathan D. Eisenhamer<br>
STScI Science Software Branch<br>
eisenhamer@stsci.edu<br>
+1 410 338 5073<br>
g+/gtalk: stscieisenhamer@gmail.com<br>
aim/skype/icq: triccare<br>
<br>
http://www.stsci.edu/<br>
http://hubblesite.org/<br>
http://amazing-space.stsci.edu/<br>
</div>
</div>
</div>
</div>
</div>
</div>
________________________________________<br>
From: astropy-bounces@scipy.org [astropy-bounces@scipy.org] on behalf of Indy Leclercq [indy.leclercq@manchester.ac.uk]<br>
Sent: Thursday, October 30, 2014 12:03<br>
To: Astronomical Python mailing list<br>
Subject: Re: [AstroPy] Fits file missing END card error when END is present in the header<br>
<br>
Hi Erik,<br>
<br>
Thanks for pointing that out – I didn’t make these files myself and after poking around a bit it would seem that there are indeed some extra bytes in the files that don’t open properly. I think that’s what the problem was here – will have to talk to the person
 who made the files!<br>
<br>
Cheers,<br>
<br>
Indy<br>
<br>
<br>
On 30 Oct 2014, at 17:51, Erik Bray <embray@stsci.edu> wrote:<br>
<br>
> One suggestion I can offer is that there are some cases where the "missing END<br>
> card" error is a bit misleading (patches welcome to fix this issue). This is<br>
> because there is no way in FITS to know how many HDUs *should* be in a file, so<br>
> if there are extra bytes at the end of a FITS file it will start reading those<br>
> bytes as though it's supposed to be the start of another FITS header. But then<br>
> when it doesn't find an END card before the end of the file it raises that error.<br>
><br>
> One case I've seen very commonly is if somebody opened in a FITS file in a text<br>
> editor and then closed it again, many editors will append a newline to the end<br>
> of the file. Other cases have occurred where the software that wrote the FITS<br>
> files appended extra bytes incorrectly.<br>
><br>
> Erik<br>
><br>
><br>
> On 10/30/2014 11:39 AM, Indy Leclercq wrote:<br>
>> Hello,<br>
>><br>
>> I’ve been processing a batch of similar of FITS files in python using astropy<br>
>> 0.4.2 on Mac OSX 10.9, and on one subset of them (with a header in identical<br>
>> format to the others), fits.open throws an error saying that there is a missing<br>
>> END card in the file. Viewing the header in the terminal shows that the END card<br>
>> is there, and as I said before, the routine works fine on files with essentially<br>
>> the same header.<br>
>><br>
>> Could anyone shed some light on this, or is this a weird bug? I can bypass this<br>
>> with the ignore_missing_end kwarg, but still find it weird.<br>
>><br>
>> Here are example of working and non-working headers (copied from a terminal more<br>
>> command)<br>
>><br>
>> This file opens fine:<br>
>><br>
>> SIMPLE = T / Standard FITS file<br>
>> BITPIX = -32 / IEEE 4-byte float<br>
>> NAXIS = 3 / Number of image dimensions<br>
>> NAXIS1 = 5155 / Size of 1st dimension in pixels<br>
>> NAXIS2 = 1070 / Size of 2nd dimension in pixels<br>
>> NAXIS3 = 376 /<br>
>> OBJECT = 'GALFACTS_S1 Stokes I' / Object name<br>
>> CTYPE1 = 'RA---CAR' / 1st axis type<br>
>> CRVAL1 = 102.050003 / Reference pixel value<br>
>> CRPIX1 = 2578.00 / Reference pixel<br>
>> CDELT1 = -0.0166667 / Pixel size in world coordinate units<br>
>> CROTA1 = 0.0000 / Axis rotation in degrees<br>
>> CTYPE2 = 'DEC--CAR' / 2nd axis type<br>
>> CRVAL2 = 0.000000 / Reference pixel value<br>
>> CRPIX2 = 53.25 / Reference pixel<br>
>> CDELT2 = 0.0166667 / Pixel size in world coordinate units<br>
>> CROTA2 = 0.0000 / Axis rotation in degrees<br>
>> CTYPE3 = 'FREQ' / 3rd axis type<br>
>> CRVAL3 = 1524717952.000000 / Reference pixel value<br>
>> CRPIX3 = 1.00 / Reference pixel<br>
>> CDELT3 = -420000.0000000 / Pixel size in world coordinate units<br>
>> CROTA3 = 0.0000 / Axis rotation in degrees<br>
>> EQUINOX = 2000.00 / Equinox of coordinates (if any)<br>
>> BUNIT = 'Kelvin' / Units of pixel data values<br>
>> END<br>
>><br>
>><br>
>> But this one doesn’t:<br>
>><br>
>> SIMPLE = T / Standard FITS file<br>
>> BITPIX = -32 / IEEE 4-byte float<br>
>> NAXIS = 3 / Number of image dimensions<br>
>> NAXIS1 = 6000 / Size of 1st dimension in pixels<br>
>> NAXIS2 = 1074 / Size of 2nd dimension in pixels<br>
>> NAXIS3 = 376 /<br>
>> OBJECT = 'GALFACTS_N4 Stokes I' / Object name<br>
>> CTYPE1 = 'RA---CAR' / 1st axis type<br>
>> CRVAL1 = 335.000000 / Reference pixel value<br>
>> CRPIX1 = 3000.50 / Reference pixel<br>
>> CDELT1 = -0.0166667 / Pixel size in world coordinate units<br>
>> CROTA1 = 0.0000 / Axis rotation in degrees<br>
>> CTYPE2 = 'DEC--CAR' / 2nd axis type<br>
>> CRVAL2 = 0.000000 / Reference pixel value<br>
>> CRPIX2 = -1181.50 / Reference pixel<br>
>> CDELT2 = 0.0166667 / Pixel size in world coordinate units<br>
>> CROTA2 = 0.0000 / Axis rotation in degrees<br>
>> CTYPE3 = 'FREQ' / 3rd axis type<br>
>> CRVAL3 = 1524717952.000000 / Reference pixel value<br>
>> CRPIX3 = 1.00 / Reference pixel<br>
>> CDELT3 = -420000.0000000 / Pixel size in world coordinate units<br>
>> CROTA3 = 0.0000 / Axis rotation in degrees<br>
>> EQUINOX = 2000.00 / Equinox of coordinates (if any)<br>
>> BUNIT = 'Kelvin' / Units of pixel data values<br>
>> END<br>
>><br>
>> Thanks for any help you could provide!<br>
><br>
><br>
> _______________________________________________<br>
> AstroPy mailing list<br>
> AstroPy@scipy.org<br>
> http://mail.scipy.org/mailman/listinfo/astropy<br>
<br>
_______________________________________________<br>
AstroPy mailing list<br>
AstroPy@scipy.org<br>
http://mail.scipy.org/mailman/listinfo/astropy<br>
</body>
</html>