简体   繁体   English

无法使用PyFITS打开文件

[英]Cannot open file with PyFITS

I've got some .fit files containing images from a CCD camera and I can't seem to open them using PyFITS. 我有一些包含来自CCD相机的图像的.fit文件,我似乎无法使用PyFITS打开它们。 I'm a complete newbie with PyFITS so I don't know what (if any) options I have. 我是PyFITS的完全新手,所以我不知道我有哪些(如果有)选项。 Here's what I'm trying: 这是我正在尝试的:

import pyfits

hdulist = pyfits.open('apex5_1_90s.fit')

Which returns the error: 返回错误:

Traceback (most recent call last):
  File "\\uol.le.ac.uk\root\staff\home\l\lvh8\Desktop Files\Prototype Data\spextract.py", line 3, in <module>
    hdulist = pyfits.open('apex5_1_90s.fit')#, ignore_missing_end=True)
  File "C:\Python27\lib\site-packages\pyfits\hdu\hdulist.py", line 118, in fitsopen
    return HDUList.fromfile(name, mode, memmap, save_backup, **kwargs)
  File "C:\Python27\lib\site-packages\pyfits\hdu\hdulist.py", line 250, in fromfile
    save_backup=save_backup, **kwargs)
  File "C:\Python27\lib\site-packages\pyfits\hdu\hdulist.py", line 803, in _readfrom
    hdu = _BaseHDU.readfrom(ffo, **kwargs)
  File "C:\Python27\lib\site-packages\pyfits\hdu\base.py", line 299, in readfrom
    hdr = Header.fromfile(fileobj, endcard=not ignore_missing_end)
  File "C:\Python27\lib\site-packages\pyfits\header.py", line 476, in fromfile
    raise IOError('Header missing END card.')
IOError: Header missing END card.

If on the other hand I try: 另一方面,如果我尝试:

import pyfits

hdulist = pyfits.open('apex5_1_90s.fit', ignore_missing_end=True)

I get told: 我被告知:

Error validating header for HDU #1 (note: PyFITS uses zero-based indexing).
    Header size is not multiple of 2880: 1920
There may be extra bytes after the last HDU or the file is corrupted.

I don't really know what this means and I've no idea what I can do about it, so any help would be greatly appreciated! 我真的不知道这意味着什么,也不知道该怎么办,因此,我们将不胜感激!

It's seems that your file is corrupted or have some issues with header. 看来您的文件已损坏或标题出现问题。 Are you sure you have a valid FITS file? 您确定您有一个有效的FITS文件吗? Based on PyFITS documentation: 根据PyFITS文档:

Problem with the FITS format is that, as old as it is, there are many conventions that appear in files from certain sources that do not meet the FITS standard. FITS格式的问题在于,某些来源的文件中出现了许多不符合FITS标准的约定,以至于它已经很古老了。 And yet they are so common-place that it is necessary to support them in any FITS readers. 然而,它们是如此普遍,以至于有必要在任何FITS读者中提供支持。 CONTINUE cards are one such example. 连续卡就是这样一个例子。

(...) If PyFITS is having trouble opening a file, a good way to rule out whether not the problem is with PyFITS is to run the file through the fitsverify . (......)如果PyFITS是有打开文件的麻烦,一个很好的方式,以排除没有这个问题是否与PyFITS是运行通过的文件fitsverify If the file is malformatted, fitsverify will output errors and warnings. 如果文件格式错误,fitsverify将输出错误和警告。 If fitsverify confirms no problems with a file, and PyFITS is still having trouble opening it (...) then it's likely there is a bug in PyFITS. 如果fitsverify确认文件没有问题,而PyFITS仍无法打开文件(...),则可能是PyFITS中存在错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM