def local_maxima(phi, nlist, th_phi=0.0):
    """Find local maxima

    Args:
        phi    : local angular spectrum function, indices (dt),
                 here 'd' is the index of delay
        nlist  : list of list of neighbor indices
        th_phi : the score of local maxima should exceed the threshold

    Returns:
        lmax   : list of local maxima indices, indexed by time.
    """
    ndoa, nframe = phi.shape
    lmax = []
    for pf in phi.T:
        lmf = []
        ph_sort = sorted(enumerate(pf), key=(lambda x : x[1]), reverse=True)
        ig_set = set()
        for i, p in ph_sort:
            if p <= th_phi:
                break
            if i not in ig_set:
                is_max = True
                for n in nlist[i]:
                    if p < pf[n]:
                        is_max = False
                        break
                if is_max:
                    lmf.append(i)
                ig_set.update(nlist[i])
        lmax.append(lmf)
    return lmax