astro py:docs

- Index
- Modules

### Navigation

- next »
- « previous |
- Astropy v5.2.1 »
- Data Tables (`astropy.table`) »
- join_distance

# join_distance

astropy.table.join_distance(distance, kdtree_args=None, query_args=None)

  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 below `distance`. 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 providing `dict` values for the `kdtree_args` or `query_args`.

  Parameters:
    distance `python:float` or `Quantity` [:ref: ‘length’]

      Maximum distance between points to be considered a join match

    kdtree_args `python:dict`, `python:None`

      Optional extra args for `cKDTree`

    query_args `python:dict`, `python:None`

      Optional extra args for `query_ball_tree`

  Returns:
    join_func python:function

      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