join_skycoord#
- astropy.table.join_skycoord(distance, distance_func='search_around_sky')[源代码]#
使用距离匹配在SkyCoord列上加入的帮助函数。
此函数用于
table.join()
允许在键列都为的情况下执行表联接SkyCoord
对象,通过计算点之间的距离并接受以下值进行匹配distance
.距离交叉匹配是使用
search_around_sky
或search_around_3d
,取决于distance_func
. 默认值为'search_around_sky'
.也可以为
distance_func
,在这种情况下,它必须是一个与search_around_sky
. 在这种情况下,函数将用(skycoord1, skycoord2, distance)
作为论据。- 参数:
- distance :
Quantity
[:ref: 'angle' , :ref: 'length' ]数量 [:ref: 'angle', :ref: 'length'] 被视为连接匹配的点之间的最大距离。必须有角度或距离单位。
- distance_func :
str
或 functionPYTHON:STR或PYTHON:Function 指定用于根据执行交叉匹配的函数
distance
. 如果以字符串形式提供,则指定中函数的名称astropy.coordinates
. 如果作为函数提供,则直接调用该函数。
- distance :
- 返回:
- join_func : functionPYTHON:函数
接受两个的函数
SkyCoord
列(col1,col2)并返回成对匹配的唯一标识符的元组(ids1,ids2)。
实例
这个例子展示了两个的内部连接
SkyCoord
列,取0.2度范围内的任何源作为匹配项。注意新的sc_id
添加并为匹配项提供唯一源标识符的列。>>> from astropy.coordinates import SkyCoord >>> import astropy.units as u >>> from astropy.table import Table, join_skycoord >>> from astropy import table
>>> sc1 = SkyCoord([0, 1, 1.1, 2], [0, 0, 0, 0], unit='deg') >>> sc2 = SkyCoord([0.5, 1.05, 2.1], [0, 0, 0], unit='deg')
>>> join_func = join_skycoord(0.2 * u.deg) >>> join_func(sc1, sc2) # Associate each coordinate with unique source ID (array([3, 1, 1, 2]), array([4, 1, 2]))
>>> t1 = Table([sc1], names=['sc']) >>> t2 = Table([sc2], names=['sc']) >>> t12 = table.join(t1, t2, join_funcs={'sc': join_skycoord(0.2 * u.deg)}) >>> print(t12) # Note new `sc_id` column with the IDs from join_func() sc_id sc_1 sc_2 deg,deg deg,deg ----- ------- -------- 1 1.0,0.0 1.05,0.0 1 1.1,0.0 1.05,0.0 2 2.0,0.0 2.1,0.0