5.4.1.3. eqcorrscan.utils.clustering.cluster¶
-
eqcorrscan.utils.clustering.
cluster
(template_list, show=True, corr_thresh=0.3, allow_shift=False, shift_len=0, save_corrmat=False, cores='all', debug=1)[source]¶ Cluster template waveforms based on average correlations.
Function to take a set of templates and cluster them, will return groups as lists of streams. Clustering is done by computing the cross-channel correlation sum of each stream in stream_list with every other stream in the list.
scipy.cluster.hierarchy
functions are then used to compute the complete distance matrix, where distance is 1 minus the normalised cross-correlation sum such that larger distances are less similar events. Groups are then created by clustering the distance matrix at distances less than 1 - corr_thresh.Will compute the distance matrix in parallel, using all available cores
Parameters: - template_list (list) – List of tuples of the template (
obspy.core.stream.Stream
) and the template id to compute clustering for - show (bool) – plot linkage on screen if True, defaults to True
- corr_thresh (float) – Cross-channel correlation threshold for grouping
- allow_shift (bool) – Whether to allow the templates to shift when correlating
- shift_len (float) – How many seconds to allow the templates to shift
- save_corrmat (bool) – If True will save the distance matrix to dist_mat.npy in the local directory.
- cores (int) – number of cores to use when computing the distance matrix, defaults to ‘all’ which will work out how many cpus are available and hog them.
- debug (int) – Level of debugging from 1-5, higher is more output, currently only level 1 implemented.
Returns: List of groups. Each group is a list of
obspy.core.stream.Stream
making up that group.- template_list (list) – List of tuples of the template (