def _kl_hr(pha, amp, nbins, optimize):
"""Binarize the amplitude according to phase values.
This function is shared by the Kullback-Leibler Distance and the
Height Ratio.
"""
vecbin = np.linspace(-np.pi, np.pi, nbins + 1)
phad = np.digitize(pha, vecbin) - 1
abin = []
for i in np.unique(phad):
# Find where phase take vecbin values :
idx = phad == i
# Take the sum of amplitude inside the bin :
abin_pha = np.einsum('i...j, k...j->ik...', amp, idx,
optimize=optimize)
abin.append(abin_pha)
return np.array(abin)
评论列表
文章目录