def dist_mat_km(catalog):
<EOL>dist_mat = np.array([np.array([<NUM_LIT:0.0>] * len(catalog))] *<EOL>len(catalog))<EOL>for i, master in enumerate(catalog):<EOL><INDENT>mast_list = []<EOL>if master.preferred_origin():<EOL><INDENT>master_ori = master.preferred_origin()<EOL><DEDENT>else:<EOL><INDENT>master_ori = master.origins[-<NUM_LIT:1>]<EOL><DEDENT>master_tup = (master_ori.latitude,<EOL>master_ori.longitude,<EOL>master_ori.depth // <NUM_LIT:1000>)<EOL>for slave in catalog:<EOL><INDENT>if slave.preferred_origin():<EOL><INDENT>slave_ori = slave.preferred_origin()<EOL><DEDENT>else:<EOL><INDENT>slave_ori = slave.origins[-<NUM_LIT:1>]<EOL><DEDENT>slave_tup = (slave_ori.latitude,<EOL>slave_ori.longitude,<EOL>slave_ori.depth // <NUM_LIT:1000>)<EOL>mast_list.append(dist_calc(master_tup, slave_tup))<EOL><DEDENT>for j in range(i, len(catalog)):<EOL><INDENT>dist_mat[i, j] = mast_list[j]<EOL><DEDENT><DEDENT>for i in range(<NUM_LIT:1>, len(catalog)):<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 the distance matrix for all a catalog using epicentral separation.

Will give physical distance in kilometers.

:type catalog: obspy.core.event.Catalog
:param catalog: Catalog for which to compute the distance matrix

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