我有一些 .fit
文件,其中包含来自 CCD 相机的图像,但我似乎无法使用 PyFITS 打开它们。我是 PyFITS 的新手,所以我不知道我有什么(如果有的话)选项。这是我正在尝试的:
import pyfits
hdulist = pyfits.open('apex5_1_90s.fit')
返回错误:
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.
如果另一方面我尝试:
import pyfits
hdulist = pyfits.open('apex5_1_90s.fit', ignore_missing_end=True)
我被告知:
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.
我真的不知道这意味着什么,也不知道我能做些什么,所以任何帮助将不胜感激!
最佳答案
您的文件似乎已损坏或 header 存在一些问题。您确定您有有效的 FITS 文件吗?基于 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. And yet they are so common-place that it is necessary to support them in any FITS readers. 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. If the file is malformatted, fitsverify will output errors and warnings. 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.
关于python - 无法使用 PyFITS 打开文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18255173/