PRO cross_dogs, ra1, dec1, ra2, dec2, radius, index, multi = multi ; DOGS serve CATS ; ; ; well.... This is actually the previous cross_cats.pro. ; The syntax is the same as cross_cats, but is much slower ; than the current cross_cats for catalogs with more than ; a few thousand sources. If you have huge catalogs, use ; cross_cats. Cats are much faster and powerful than dogs. ; n1 = n_elements(ra1) n2 = n_elements(ra22) index = lon64arr(n1)*0-1 ; exclude sources in the second set that are not within ; the ra/dec ranges of the first set Z = where(ra2 LE max(ra1) + 5.0*radius/3600.0d * cos(min(abs(dec1)) * !pi/180.0d) AND $ ra2 GE min(ra1) - 5.0*radius/3600.0d * cos(min(abs(dec1)) * !pi/180.0d) AND $ dec2 LE max(dec1) + 5.0*radius/3600.0d AND dec2 GE min(dec1) - 5.0*radius/3600.0d) IF total(Z) EQ -1 THEN goto,finish Z = long64(Z) ra22 = ra2[Z] dec22 = dec2[Z] If n_elements(multi) EQ 0 THEN multi = 0 IF multi EQ 1 THEN distance = fltarr(n1) i = long64(0) WHILE i LT n1 DO BEGIN dra = (ra1[i] - ra22)*cos(dec1[i]*!pi/180.0) ddec = (dec1[i] - dec22) d = 3600.0 * sqrt(dra^2.0 + ddec^2.0) dmin = min(d,ind) IF dmin LE radius THEN index[i] = ind IF multi EQ 1 AND dmin LE radius THEN distance[i] = dmin i=i+1 ENDWHILE ;index2 = fix(index) ;IF total(index-index2) EQ 0 THEN index = index2 If multi EQ 1 THEN BEGIN A = where(index NE -1) nA = n_elements(A) i = long(0) WHILE i LT nA DO BEGIN B = where(index[A] EQ index[A[i]]) IF n_elements(B) GE 2 THEN BEGIN dmin = min(distance[A[B]], ind) temp = index[A[B[ind]]] index[A[B]] = -1 index[A[B[ind]]] = temp ENDIF i = i+1 ENDWHILE ENDIF A = where(index GE 0) IF total(A) NE -1 THEN index[A] = Z[index[A]] ; Here can be a source of bug. IF min(index) LT -1 THEN print, 'trouble' finish: END