使用astWCS尝试创建WCS对象时出错
我正在运行 python2.5 并尝试使用 astLib 库来分析天文图像中的 WCS 信息。我尝试使用以下骨架代码实例化对象:
from astLib import astWCS
w = astWCS.WCS('file.fits') # error here
其中 file.fits 是指向有效适合文件的字符串。
我尝试使用传递 pyfits 标头对象的替代方法,但这也失败:
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
我知道 astWCS 模块是 WCStools 的包装版本,但我更喜欢使用 Python 模块,因为我的其余代码都在 Python 中
任何人都可以帮助解决这个问题?
I'm running python2.5 and trying to use the astLib library to analyse WCS information in astronomical images. I try and get the object instanciated with the following skeleton code:
from astLib import astWCS
w = astWCS.WCS('file.fits') # error here
where file.fits is a string pointing to a valid fits file.
I have tried using the alternate method of passing a pyfits header object and this fails also:
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
The error is this:
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 *'
When I run in ipython, I get the full error here on the pastebin
I know the astWCS module is a wrapped version of WCStools but i'd prefer to use the Python module as the rest of my code is in Python
Can anyone help with this problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
刚刚发现这个库的更新版本已经解决了这个问题,感谢大家的帮助
Just found out the updated version of this library has fixed the problem, thanks for everyone's help
哦,对不起,我应该看到的。更详细地查看pastebin,我能想到的唯一错误是,由于某种原因,标头中包含unicode。它无法转换为
char *
,并且您会收到错误。我尝试在标题中搜索某些内容,但一切看起来都很好。你能做到这一点并将输出发布到另一个pastebin中吗?或者,如果您可以检查适合文件的标题中是否有“有趣”的字符,则删除它们应该可以解决问题。
Oh sorry, I should have seen. Looking at the pastebin in more detail, the only error I can think of is that, for some reason the header has unicode in it. It can't be converted to
char *
, and you get the error. I tried searching for something in the header, but everything looks okay. Can you do this and post the output in another pastebin?Or, if you can check the header of your fits file for "funny" characters, getting rid of them should solve the issue.