code: def closest_to_ref(arrays, ref, cutoff=1E-12):
      
      dist = numpy.zeros(len(arrays))
      logref = log(ref, cutoff)
      for rlz, array in enumerate(arrays):
          diff = log(array, cutoff) - logref
          dist[rlz] = numpy.sqrt((diff * diff).sum())
      rlz = dist.argmin()
      closest = dict(rlz=rlz, value=arrays[rlz], dist=dist[rlz])
      return closest
docs: :param arrays: a sequence of R arrays
      :param ref: the reference array
      :returns: a dictionary with keys rlz, value, and dist