使用astWCS尝试创建WCS对象时出错

发布于 2024-08-17 12:49:15 字数 1245 浏览 6 评论 0原文

我正在运行 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

烟酉 2024-08-24 12:49:15

刚刚发现这个库的更新版本已经解决了这个问题,感谢大家的帮助

Just found out the updated version of this library has fixed the problem, thanks for everyone's help

小情绪 2024-08-24 12:49:15

哦,对不起,我应该看到的。更详细地查看pastebin,我能想到的唯一错误是,由于某种原因,标头中包含unicode。它无法转换为 char *,并且您会收到错误。我尝试在标题中搜索某些内容,但一切看起来都很好。你能做到这一点并将输出发布到另一个pastebin中吗?

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)

或者,如果您可以检查适合文件的标题中是否有“有趣”的字符,则删除它们应该可以解决问题。

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?

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)

Or, if you can check the header of your fits file for "funny" characters, getting rid of them should solve the issue.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文