code: def find_dist_to_centroids(cluster_dict, cvects, weights=None):
      
      distances = np.zeros((cvects.shape[1]))
      cent_dict = {}
      for k, v in cluster_dict.items():
          l = [k] + v
          distances[l], centroid = find_dist_to_centroid(cvects, l, weights)
          cent_dict[k] = make_lat_lons(centroid)
      return distances, cent_dict
docs: Find the centroids and the distances to the centroid for all sources in a set of clusters
  
      Parameters
      ----------
      cluster_dict : dict(int:[int,...])  
           Each cluster is a source index and the list of other sources in the cluster.  
  
      cvects : np.ndarray(3,nsrc)  
         Directional cosines (i.e., x,y,z component) values of all the sources
  
      weights : ~numpy.ndarray(nsrc) with the weights to use.  None for equal weighting
  
      Returns
      ----------
      distances : ~numpy.ndarray(nsrc) with the distances to the centroid of the cluster.  0 for unclustered sources
  
      cent_dict : dict(int:numpy.ndarray(2)), dictionary for the centroid locations