def sort_windows_on_channel(sta_win):
    """
    Group windows from one station into channels and count
    the number of windows in that channel
    :param sta_win:
    :return:
    """
    sort_dict = {}
    for trace_id, trace_win in sta_win.items():
        chan = trace_id.split('.')[-1][0:2]
        if chan not in sort_dict:
            sort_dict[chan] = {'traces': [], 'nwins': 0}
        sort_dict[chan]['traces'].append(trace_id)
        sort_dict[chan]['nwins'] += len(trace_win)
    return sort_dict
