Fwd: {SunPy} Non-ascii characters in fits headers

11 views
Skip to first unread message

Joe Hourcle

unread,
Nov 23, 2016, 9:56:15 AM11/23/16
to su...@googlegroups.com

Oops, sent this w/ the wrong from-address.

> Begin forwarded message:
>
> Subject: Re: {SunPy} Non-ascii characters in fits headers
> Date: November 23, 2016 at 9:24:17 AM EST
> To: Kamen Kozarev <kamen....@gmail.com>
> Cc: su...@googlegroups.com
>
>
>> On Nov 23, 2016, at 7:14 AM, Kamen Kozarev <kamen....@gmail.com> wrote:
>>
>> Hello,
>>
>> I have come into the problem of astropy.io.fits quitting when I try to read the header of a fits file, if it contains non-ascii characters.
>> It doesn't crap on loading the file with pyfits directly, but when I try to access an element of the header with non-ascii chars. This also happens when I try to create a map directly. As far as I know people are aware of this, but no fix has been implemented: https://github.com/astropy/astropy/pull/2887
>>
>> I realize this isn't strictly a Sunpy bug, but I was wondering if people might suggest a workaround…
>
> The real workaround is to fix the headers — non-ASCII would be an invalid FITS file.
>
> I’m not 100% sure at this point, but I think the problem character might actually be a line return.
>
> Would you be willing to share the file with me, or at least the headers?
>
> (I went looking to see if I could get MWA data, but it looks like you have to coordinate with them to download anything, and there’s an 18 month embargo, so I couldn’t get the file you’re working with, anyway).
>
> If you don’t want me to see the data (or it won’t go through e-mail, as it’s about 8MB), I’ve attached a Perl script which will strip the headers up until it sees an ‘END’ card followed by non-ASCII.
>
> Just do something like:
>
> perl strip_headers.pl --dir=/tmp filename.fits
>
> It’ll then write out a file called filename.hdu00 into /tmp (and possibly filename.hdu01, etc, if it’s compressed or a data cube).
>
> It shouldn’t require any additional Perl modules (it only loads File::Path if you tell it to write to a directory that doesn’t exist)
>
> -Joe
>
size_headers.pl
Reply all
Reply to author
Forward
0 new messages