def distance_matrix(stream_list, allow_shift=False, shift_len=<NUM_LIT:0>, cores=<NUM_LIT:1>):
<EOL>dist_mat = np.array([np.array([<NUM_LIT:0.0>] * len(stream_list))] *<EOL>len(stream_list))<EOL>for i, master in enumerate(stream_list):<EOL><INDENT>pool = Pool(processes=cores)<EOL>results = [pool.apply_async(cross_chan_coherence,<EOL>args=(master, stream_list[j], allow_shift,<EOL>shift_len, j))<EOL>for j in range(len(stream_list))]<EOL>pool.close()<EOL>dist_list = [p.get() for p in results]<EOL>pool.join()<EOL>dist_list.sort(key=lambda tup: tup[<NUM_LIT:1>])<EOL>for j in range(i, len(stream_list)):<EOL><INDENT>if i == j:<EOL><INDENT>dist_mat[i, j] = <NUM_LIT:0.0><EOL><DEDENT>else:<EOL><INDENT>dist_mat[i, j] = <NUM_LIT:1> - dist_list[j][<NUM_LIT:0>]<EOL><DEDENT><DEDENT><DEDENT>for i in range(<NUM_LIT:1>, len(stream_list)):<EOL><INDENT>for j in range(i):<EOL><INDENT>dist_mat[i, j] = dist_mat.T[i, j]<EOL><DEDENT><DEDENT>return dist_mat<EOL>
Compute distance matrix for waveforms based on cross-correlations.

Function to compute the distance matrix for all templates - will give
distance as 1-abs(cccoh), e.g. a well correlated pair of templates will
have small distances, and an equally well correlated reverse image will
have the same distance as a positively correlated image - this is an issue.

:type stream_list: list
:param stream_list:
    List of the :class:`obspy.core.stream.Stream` to compute the distance
    matrix for
:type allow_shift: bool
:param allow_shift: To allow templates to shift or not?
:type shift_len: float
:param shift_len: How many seconds for templates to shift
:type cores: int
:param cores: Number of cores to parallel process using, defaults to 1.

:returns: distance matrix
:rtype: :class:`numpy.ndarray`

.. warning::
    Because distance is given as :math:`1-abs(coherence)`, negatively
    correlated and positively correlated objects are given the same
    distance.