输入 FITS table 到 astroquery.xmatch
Input FITS table to astroquery.xmatch
我需要使用 astroquery 包中的 xmatch 来交叉匹配大型本地目录与 2MASS。
我像往常一样用 astropy 加载我的本地 FITS table:
from astropy.io import fits
hdu = fits.open(root+'mycat.fits')
然后尝试按照 the astroquery docs:
中描述的语法将 xmatch 与 table 一起使用(table 是 hdu[2])
from astroquery.xmatch import XMatch
table = XMatch.query(cat1=hdu[2],
cat2='vizier:II/246/out',
max_distance=1 * u.arcsec, colRA1='RA',
colDec1='Dec')
但是得到如下错误:
AttributeError: 'BinTableHDU' object has no attribute 'read'
astroquery docs上的例子只展示了如何给本地CSV文件。但是我的目录大约有700万个条目,所以不方便将其作为ASCII CSV文件传递。
我应该如何将我的 FITS table 作为输入传递?谢谢!
虽然 xmatch 可以接受文件对象作为输入,但该文件对象必须是 Vizier 风格的 .csv table。您需要先将您的 FITS table 转换为 astropy table,例如
from astropy.table import Table
myTable = Table(data=hdu[2].data)
我需要使用 astroquery 包中的 xmatch 来交叉匹配大型本地目录与 2MASS。 我像往常一样用 astropy 加载我的本地 FITS table:
from astropy.io import fits
hdu = fits.open(root+'mycat.fits')
然后尝试按照 the astroquery docs:
中描述的语法将 xmatch 与 table 一起使用(table 是 hdu[2])from astroquery.xmatch import XMatch
table = XMatch.query(cat1=hdu[2],
cat2='vizier:II/246/out',
max_distance=1 * u.arcsec, colRA1='RA',
colDec1='Dec')
但是得到如下错误:
AttributeError: 'BinTableHDU' object has no attribute 'read'
astroquery docs上的例子只展示了如何给本地CSV文件。但是我的目录大约有700万个条目,所以不方便将其作为ASCII CSV文件传递。
我应该如何将我的 FITS table 作为输入传递?谢谢!
虽然 xmatch 可以接受文件对象作为输入,但该文件对象必须是 Vizier 风格的 .csv table。您需要先将您的 FITS table 转换为 astropy table,例如
from astropy.table import Table
myTable = Table(data=hdu[2].data)