def group_delays(stream_list):
groups = []<EOL>group_delays = []<EOL>group_chans = []<EOL>stream_list = [(st, len(st)) for st in stream_list]<EOL>stream_list.sort(key=lambda tup: tup[<NUM_LIT:1>])<EOL>stream_list = [st[<NUM_LIT:0>] for st in stream_list]<EOL>for i, st in enumerate(stream_list):<EOL><INDENT>msg = '<STR_LIT:U+0020>'.join(['<STR_LIT>', str(i), '<STR_LIT>',<EOL>str(len(stream_list))])<EOL>print(msg)<EOL>starttimes = []<EOL>chans = []<EOL>for tr in st:<EOL><INDENT>starttimes.append(tr.stats.starttime)<EOL>chans.append((tr.stats.station, tr.stats.channel))<EOL><DEDENT>delays = [starttimes[m] - min(starttimes)<EOL>for m in range(len(starttimes))]<EOL>delays = [round(d, <NUM_LIT:2>) for d in delays]<EOL>if len(groups) == <NUM_LIT:0>:<EOL><INDENT>groups.append([stream_list[i]])<EOL>group_delays.append(delays)<EOL>group_chans.append(chans)<EOL><DEDENT>else:<EOL><INDENT>j = <NUM_LIT:0><EOL>match = False<EOL>while not match:<EOL><INDENT>kmatch = <NUM_LIT:0><EOL>shared_chans = []<EOL>shared_delays_slave = []<EOL>shared_delays_master = []<EOL>for k, chan in enumerate(chans):<EOL><INDENT>if chan in group_chans[j]:<EOL><INDENT>shared_chans.append(chan)<EOL>shared_delays_slave.append(delays[k])<EOL>shared_delays_master.append(group_delays[j][group_chans[j].index(chan)])<EOL><DEDENT><DEDENT>shared_delays_slave = [delay - min(shared_delays_slave)<EOL>for delay in shared_delays_slave]<EOL>shared_delays_master = [delay - min(shared_delays_master)<EOL>for delay in shared_delays_master]<EOL>for k in range(len(shared_chans)):<EOL><INDENT>if shared_delays_slave[k] == shared_delays_master[k]:<EOL><INDENT>kmatch += <NUM_LIT:1>  <EOL><DEDENT><DEDENT>if kmatch == len(shared_chans):<EOL><INDENT>groups[j].append(stream_list[i])<EOL>match = True<EOL><DEDENT>elif j < len(groups) - <NUM_LIT:1>:<EOL><INDENT>j += <NUM_LIT:1><EOL><DEDENT>else:<EOL><INDENT>groups.append([stream_list[i]])<EOL>group_delays.append(delays)<EOL>group_chans.append(chans)<EOL>match = True  <EOL><DEDENT><DEDENT><DEDENT><DEDENT>return groups<EOL>
Group template waveforms according to their arrival times (delays).

:type stream_list: list
:param stream_list:
    List of :class:`obspy.core.stream.Stream` waveforms you want to group.

:returns:
    list of List of :class:`obspy.core.stream.Stream` where each initial
    list is a group with the same delays.
:rtype: list