def space_time_cluster(catalog, t_thresh, d_thresh):
initial_spatial_groups = space_cluster(catalog=catalog, d_thresh=d_thresh,<EOL>show=False)<EOL>initial_spatial_lists = []<EOL>for group in initial_spatial_groups:<EOL><INDENT>initial_spatial_lists.append(list(group))<EOL><DEDENT>groups = []<EOL>for group in initial_spatial_lists:<EOL><INDENT>for master in group:<EOL><INDENT>for event in group:<EOL><INDENT>if abs(event.preferred_origin().time -<EOL>master.preferred_origin().time) > t_thresh:<EOL><INDENT>groups.append([event])<EOL>group.remove(event)<EOL><DEDENT><DEDENT><DEDENT>groups.append(group)<EOL><DEDENT>return [Catalog(group) for group in groups]<EOL>
Cluster detections in space and time.

Use to separate repeaters from other events.  Clusters by distance
first, then removes events in those groups that are at different times.

:type catalog: obspy.core.event.Catalog
:param catalog: Catalog of events to clustered
:type t_thresh: float
:param t_thresh: Maximum inter-event time threshold in seconds
:type d_thresh: float
:param d_thresh: Maximum inter-event distance in km

:returns: list of :class:`obspy.core.event.Catalog` objects
:rtype: list

>>> from eqcorrscan.utils.clustering import space_time_cluster
>>> from obspy.clients.fdsn import Client
>>> from obspy import UTCDateTime
>>> client = Client("https://earthquake.usgs.gov")
>>> starttime = UTCDateTime("2002-01-01")
>>> endtime = UTCDateTime("2002-02-01")
>>> cat = client.get_events(starttime=starttime, endtime=endtime,
...                         minmagnitude=6)
>>> groups = space_time_cluster(catalog=cat, t_thresh=86400, d_thresh=1000)