Skip to main content
 首页 » 编程设计

python之将 FITS 表输入到 astroquery.xmatch

2024年10月24日17sxdcgaq8080

我需要使用 astroquery 中的 xmatch用于将大型本地目录与 2MASS 交叉匹配的软件包。 我像往常一样用 astropy 加载我的本地 FITS 表:

from astropy.io import fits 
hdu = fits.open(root+'mycat.fits') 

然后尝试按照 the astroquery docs 中描述的语法对该表(该表是 hdu[2])使用 xmatch。 :

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 表作为输入传递?谢谢!

请您参考如下方法:

虽然 xmatch 可以接受文件对象作为输入,但该文件对象必须是 Vizier 样式的 .csv 表。您需要先将 FITS 表转换为 astropy 表,例如

from astropy.table import Table 
myTable = Table(data=hdu[2].data)