Viewing contents of file '../idllib/uit/pro/coord_index.pro'
;
;
;+
; NAME:
; COORD_INDEX
; PURPOSE:
; A SHOWPHOT procedure to find cross-index two sets of coordinates,
; looking for unique matches.
; CALLING SEQUENCE:
; coord_index, x1, y1, x2, y2, ind1, ind2 [, SEPARATION=sep]
; INPUTS:
; x1 An array containing the first coord. of the first set of coords.
; y1 An array containing the second coord. of the first set of coords.
; x2 An array containing the first coord. of the second set of coords.
; y2 An array containing the second coord. of the second set of coords.
; OUTPUTS:
; ind1 The array of indices indicating which elements in the second
; coordinate set match the elements in the first. -1's indicate
; unmatched elements.
; ind2 The array of indices indicating which elements in the first
; coordinate set match the elements in the second. -1's indicate
; unmatched elements.
; KEYWORDS:
; SEPARATION Indicates the maximum separation allowed between matching
; coordinates. This parameter may be no less than 0.5 and
; it defaults to 1.
; RESTRICTIONS:
; The two components of each set of coordinates must have the same
; length. The two sets of coordinates need not.
; PROCEDURE:
; SRCOR is used to find the matches between the two tables. The index
; arrays returned by this procedure are then converted into the format
; required by SHOWPHOT (seen the OUTPUTS section above).
; MODIFICATION HISTORY:
; Written by Michael R. Greason, Hughes STX, 28 April 1992.
; Rewritten using SRCOR. MRG, Hughes STX, 15 May 1992.
;-
PRO coord_index, x1, y1, x2, y2, ind1, ind2, SEPARATION=sep
;
; Check parameters.
;
np = n_params(0)
IF (np LT 6) THEN BEGIN
print, 'Syntax: coord_index, x1, y1, x2, y2, ind1, ind2 ' + $
'[, SEPARATION=sep]'
RETURN
ENDIF
;
n1 = n_elements(x1)
IF (n1 NE n_elements(y1)) THEN BEGIN
print, 'COORD_INDEX -- Error. The first pair of parameters must ' + $
'be the same size.'
RETURN
ENDIF
;
n2 = n_elements(x2)
IF (n2 NE n_elements(y2)) THEN BEGIN
print, 'COORD_INDEX -- Error. The second pair of parameters must ' + $
'be the same size.'
RETURN
ENDIF
;
IF (n_elements(sep) LE 0) THEN sep = 1.0
sep = sep > 0.5
;
; Initialize the output index arrays.
;
ind1 = replicate(-1L, n1)
ind2 = replicate(-1L, n2)
;
; Find the matches, using SRCOR.
;
srcor, x1, y1, x2, y2, sep, i1, i2
;
; Convert the SRCOR indices to the expected format.
;
IF (i1(0) GE 0) THEN BEGIN
ind1(i1) = i2
ind2(i2) = i1
ENDIF
;
RETURN
END