code: def find_matches_by_sigma(cos_vects, unc_vect, cut_sigma):
      
      match_dict = {}
      sig_2_vect = unc_vect * unc_vect
      for i, v1 in enumerate(cos_vects.T):
          cos_t_vect = (v1 * cos_vects.T).sum(1)
          cos_t_vect[cos_t_vect < -1.0] = -1.0
          cos_t_vect[cos_t_vect > 1.0] = 1.0
          sig_2_i = sig_2_vect[i]
          acos_t_vect = np.degrees(np.arccos(cos_t_vect))
          total_unc = np.sqrt(sig_2_i + sig_2_vect)
          sigma_vect = acos_t_vect / total_unc
          mask = sigma_vect < cut_sigma
          for j in np.where(mask[:i])[0]:
              match_dict[(j, i)] = sigma_vect[j]
  
      return match_dict
docs: Find all the pairs of sources within a given distance of each
      other.
  
      Parameters
      ----------
      cos_vects : np.ndarray(3,nsrc)  
          Directional cosines (i.e., x,y,z component) values of all the sources
  
      unc_vect : np.ndarray(nsrc)  
          Uncertainties on the source positions
  
      cut_sigma : float    
          Angular cut in positional errors standard deviations that will
          be used to select pairs by their separation.
  
      Returns
      -------
      match_dict : dict((int,int):float)    
          Each entry gives a pair of source indices, and the
          corresponding sigma