join_distance#
- astropy.table.join_distance(distance, kdtree_args=None, query_args=None)[source]#
Helper function to join table columns using distance matching.
This function is intended for use in
table.join()
to allow performing a table join where the key columns are matched by computing the distance between points and accepting values belowdistance
. This numerical “fuzzy” match can apply to 1-D or 2-D columns, where in the latter case the distance is a vector distance.The distance cross-matching is done using
scipy.spatial.cKDTree
. If necessary you can tweak the default behavior by providingdict
values for thekdtree_args
orquery_args
.- Parameters:
- distance
float
orQuantity
[:ref: ‘length’] Maximum distance between points to be considered a join match
- kdtree_args
dict
,None
Optional extra args for
cKDTree
- query_args
dict
,None
Optional extra args for
query_ball_tree
- distance
- Returns:
- join_funcfunction
Function that accepts (skycoord1, skycoord2) and returns the tuple (ids1, ids2) of pair-matched unique identifiers.
Examples
>>> from astropy.table import Table, join_distance >>> from astropy import table
>>> c1 = [0, 1, 1.1, 2] >>> c2 = [0.5, 1.05, 2.1]
>>> t1 = Table([c1], names=['col']) >>> t2 = Table([c2], names=['col']) >>> t12 = table.join(t1, t2, join_type='outer', join_funcs={'col': join_distance(0.2)}) >>> print(t12) col_id col_1 col_2 ------ ----- ----- 1 1.0 1.05 1 1.1 1.05 2 2.0 2.1 3 0.0 -- 4 -- 0.5