我想交叉匹配两个目录。但是,这两个目录的Dec和RA坐标数据被写成"h“和”Dec“(而不是用":”分隔它们)。
RAJ2000
-----------
00 32 41.56
00 32 41.55
...这就是我认为我的代码出错的原因。
"TypeError: unsupported operand type(s) for *: 'MaskedColumn' and 'Unit'"是否有命令可以将所有坐标按度数相加,或者在给定坐标之间添加冒号?
这是代码:
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)发布于 2022-09-16 13:03:52
这里不要乘以一个单位:列的内容是字符串(请检查例如Boyer['RAJ2000'].dtype),因此使用unit关键字(空格或冒号作为分隔符)将它们相应地转换为SkyCoord。参见AstroPy坐标文档顶部的示例代码
coo_B15 = SkyCoord(Boyer['RAJ2000'], Boyer['DEJ2000'], unit=(u.hourangle, u.deg))
coo_S06 = SkyCoord(Sohn['RAJ2000'], Sohn['DEJ2000'], unit=(u.hourangle, u.deg))另外,对于RA使用u.hourangle,而不是使用度,因为RA列在hms中。
https://stackoverflow.com/questions/73743257
复制相似问题