【问题标题】:Error when using astWCS trying to create WCS object使用 astWCS 尝试创建 WCS 对象时出错
【发布时间】:2010-01-12 10:24:58
【问题描述】:

我正在运行 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 中

谁能帮忙解决这个问题?

【问题讨论】:

  • 你用的是什么版本的python?
  • @Alok 如第一行所述:python2.5。更具体地说 2.5.4

标签: python astronomy fits


【解决方案1】:

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

【讨论】:

    【解决方案2】:

    哦,对不起,我应该看到的。更详细地查看 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)
    

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

    【讨论】:

      猜你喜欢
      • 2011-01-08
      • 2014-08-09
      • 2012-04-24
      • 1970-01-01
      • 1970-01-01
      • 2023-03-19
      • 2022-11-22
      • 2022-12-09
      • 1970-01-01
      相关资源
      最近更新 更多