crossmatch helpers

Data Lab helpers for (local) positional cross-matching.

crossmatch.xmatch(ra1, dec1, ra2, dec2, maxdist=None, units='deg', method='astropy', **kwargs)[source]

Cross-match two sets of ra & dec coordinates locally (i.e. all coordinates are in RAM).

The function will search for counterparts of ra1/dec1 coordinates in the in ra2/dec2 coordinate set, i.e. one can consider ra2/dec2 to be the catalog that will be searched.

Parameters:
  • dec1 (ra1,) – RA and declination of first coordinate set, in units of units
  • dec2 (ra2,) – RA and declination of second coordinate set, in units of units
  • maxdist (float or None) – If not None, then it is the maximum angular distance (in units of units) to be considered. All distances greater than that will be considered non-matches. If None, then all ra1/dec1 will have matches in ra2/dec2.
  • units (str) – Units of ra1, dec1, ra2, dec2. Default: ‘deg’ (decimal degrees).
  • method (str) – Currently only astropy’s match_to_catalog_sky() method is supported, i.e. the default ‘astropy’.
Other Parameters:
 

nthneighbor (int, optional) – If method='astropy'. Which closest neighbor to search for. Typically 1 is desired here, as that is correct for matching one set of coordinates to another. The next likely use case is 2, for matching a coordinate catalog against itself (1 is inappropriate because each point will find itself as the closest match).

Returns:

  • idx (1-d array) – Index values of the ra1/dec1 counterparts found in ra2/dec2. Thus ra2[idx], dec2[idx] will select from the ra2/dec2 catalog the matched counterparts of the ra1/dec1 coordinate pairs.

    If maxdist was not None but a number instead, then ‘idx’ only contains the objects matched up to the maxdist radius.

  • dist2d (1-d array) – The angular distances of the matches found in the ra2/dec2 catalog. In units of units.

    If maxdist was not None but a number instead, then ‘dist2d’ only contains the objects matched up to the maxdist radius.