Python 保存匹配表:关键字说明及其值太长
尝试将使用astroquery检索的astropy表保存到FITS文件时出错。在某些情况下,它抱怨某些关键字的描述太长。Python 保存匹配表:关键字说明及其值太长,python,astropy,Python,Astropy,尝试将使用astroquery检索的astropy表保存到FITS文件时出错。在某些情况下,它抱怨某些关键字的描述太长。writeto()函数似乎有一个output\u verify参数来避免此类问题,但我找不到如何将其传递给write()函数?它存在吗? 这是我的密码: import astropy.units as u from astroquery.vizier import Vizier import astropy.coordinates as coord from astropy.t
writeto()
函数似乎有一个output\u verify
参数来避免此类问题,但我找不到如何将其传递给write()
函数?它存在吗?
这是我的密码:
import astropy.units as u
from astroquery.vizier import Vizier
import astropy.coordinates as coord
from astropy.table import Table
akari_query=Vizier(columns=["S09","S18","e_S09","e_S18","q_S09","q_S18"],catalog=["II/297/irc"])
result=akari_query.query_region(coord.SkyCoord(ra=200.0, dec=10.0,unit=(u.deg, u.deg),frame='icrs'), width=[2.0*u.deg,2.0*u.deg],return_type='votable')
table=Table(result[0], masked=True)
table.write('test.fits')
它返回一条以以下内容结尾的长错误消息:
ValueError: The keyword description with its value is too long
问题是
table.meta['description']
的长度超过了您试图保存的fits文件头的允许长度。您只需将其缩短到80个字符以下,然后再次尝试编写test.fits
:
table.meta['description'] = u'AKARI/IRC All-Sky Survey Point Source Catalogue v. 1.0'
table.write('test.fits')
够了,谢谢!我看的是列描述,而不是表描述……也许FITS表的I/O连接器应该捕捉到这个异常并更好地处理它,因为它的来源并不明显(特别是如果您不熟悉FITS格式的话)。。。