Astropy cross-matching unusall coordinates

Question:

I want to cross-match two catalogs. But the Dec and RA coordinate data of these two catalogs are written as "h m s" and "d m s" (instead of being separated by a ":" a space separates them).

RAJ2000                            
-----------
00 32 41.56
00 32 41.55
...

That’s why I think my code gives an error.

"TypeError: unsupported operand type(s) for *: 'MaskedColumn' and 'Unit'"

Is there a command where I can either add all the coordinates in degrees or add colons between the given coordinates?

This is the code:

from astropy import units as u
from astropy.coordinates import SkyCoord
from astropy.table import Table
import numpy as np


from astroquery.vizier import Vizier
import astropy.units as u

Vizier.ROW_LIMIT = -1
result = Vizier.query_region(SkyCoord.from_name('NGC 147',frame='icrs'),
                                 radius=10*u.arcmin,
                                 catalog='J/ApJS/216/10/dustgsc')


from tabulate import tabulate
with open('Boyer_Spitzer.txt', 'w') as f:
    f.write(tabulate(result[0]))


catalogs = Vizier.get_catalogs('J/A+A/445/69/table2')

with open('Sohn06.txt', 'w') as f1:
    f1.write(tabulate(catalogs[0]))


Boyer=result[0]
Sohn=catalogs[0]

coo_B15 = SkyCoord(Boyer['RAJ2000']*u.deg, Boyer['DEJ2000']*u.deg)
coo_S06 = SkyCoord(Sohn['RAJ2000']*u.deg, Sohn['DEJ2000']*u.deg)

idx_B15, d2d_B15, d3d_B15 = coo_S06.match_to_catalog_sky(coo_B15)
Asked By: hamid

||

Answers:

Don’t multiply by a unit here: the contents of the columns are strings (check e.g. Boyer['RAJ2000'].dtype), so convert them to SkyCoord accordingly, using the unit keyword (a space or colon as separator is irrelevant here). See the example code at the top of the AstroPy coordinate documentation:

coo_B15 = SkyCoord(Boyer['RAJ2000'], Boyer['DEJ2000'], unit=(u.hourangle, u.deg))
coo_S06 = SkyCoord(Sohn['RAJ2000'], Sohn['DEJ2000'], unit=(u.hourangle, u.deg))

Also, use u.hourangle, not degrees, for the RA, since the RA columns are in hms.

Answered By: 9769953