我正在运行python2.5,并尝试使用astLib库来分析天文图像中的WCS信息。我尝试使用以下框架代码实例化该对象:
from astLib import astWCS
w = astWCS.WCS('file.fits') # error here其中file.fits是指向有效fits文件的字符串。
我尝试使用另一种方法传递pyfits header对象,但也失败了:
import pyfits
from astLib import astWCS
f = pyfits.open('file.fits')
header = f[0].header
f.close()
w = astWCS.WCS(header, mode='pyfits') # error here also错误是这样的:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/home/astro/phrfbf/build/lib/python2.6/site-packages/astLib/astWCS.py", line 79, in __init__
self.updateFromHeader()
File "/home/astro/phrfbf/build/lib/python2.6/site-packages/astLib/astWCS.py", line 119, in updateFromHeader
self.WCSStructure=wcs.wcsinit(cardstring)
File "/home/astro/phrfbf/build/lib/python2.6/site-packages/PyWCSTools/wcs.py", line 70, in wcsinit
return _wcs.wcsinit(*args)
TypeError: in method 'wcsinit', argument 1 of type 'char *'当我在ipython中运行时,我在pastebin上得到了完整的错误
我知道Python模块是WCStools的打包版本,但我更喜欢使用astWCS模块,因为我其余的代码都是用Python语言编写的
有人能帮助解决这个问题吗?
发布于 2010-03-10 08:26:59
刚刚发现这个库的更新版本已经解决了这个问题,感谢大家的帮助
发布于 2010-01-14 10:58:37
哦,对不起,我应该看出来的。更详细地看一下粘贴盒,我能想到的唯一错误是,由于某种原因,标头中有unicode。它不能转换成char *,你会得到错误。我试着在标题中搜索一些东西,但一切看起来都没问题。你能做到这一点并将输出张贴在另一个粘贴箱中吗?
import pyfits
f = pyfits.open('file.fits')
header = f[0].header
f.close()
for x, i in enumerate(header.iteritems()):
if len(str(i[1])) >= 70:
print x, str(i[1])
cardlist = header.ascardlist()
cardstring = ""
for card in cardlist:
cardstring = cardstring + str(card)
print repr(cardstring)或者,如果您可以检查fits文件的头中是否有“有趣”的字符,那么删除它们应该可以解决这个问题。
https://stackoverflow.com/questions/2048166
复制相似问题