code: def space_time_cluster(catalog, t_thresh, d_thresh):
      
      initial_spatial_groups = space_cluster(catalog=catalog, d_thresh=d_thresh,
                                             show=False)
      # Need initial_spatial_groups to be lists at the moment
      initial_spatial_lists = []
      for group in initial_spatial_groups:
          initial_spatial_lists.append(list(group))
      # Check within these groups and throw them out if they are not close in
      # time.
      groups = []
      for group in initial_spatial_lists:
          for master in group:
              for event in group:
                  if abs(event.preferred_origin().time -
                         master.preferred_origin().time) > t_thresh:
                      # If greater then just put event in on it's own
                      groups.append([event])
                      group.remove(event)
          groups.append(group)
      return [Catalog(group) for group in groups]
docs: 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)