2

I need to use xmatch from the astroquery package to cross match a large local catalogue with 2MASS. I load my local FITS table with astropy as usual:

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

Then try to use xmatch with that table (the table is hdu[2]) following the syntax described in the astroquery docs:

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')

But get the following error:

AttributeError: 'BinTableHDU' object has no attribute 'read'

The examples on the astroquery docs only shows how to give a local CSV file. But my catalogue has about 7 million entries, so it is not convenient to pass it as an ASCII CSV file.

How should I pass my FITS table as input? Thanks!

MSeifert
  • 145,886
  • 38
  • 333
  • 352
HBouy
  • 245
  • 3
  • 14

1 Answers1

2

While xmatch can accept a file object as input, that file object has to be a Vizier-style .csv table. You need to convert your FITS table to an astropy table first, e.g.

from astropy.table import Table
myTable = Table(data=hdu[2].data)
keflavich
  • 18,278
  • 20
  • 86
  • 118