def _kl_hr(pha, amp, nbins):
nPha, npts, nAmp = *pha.shape, amp.shape[0]
step = 2*np.pi/nbins
vecbin = binarize(-np.pi, np.pi+step, step, step)
if len(vecbin) > nbins:
vecbin = vecbin[0:-1]
abin = np.zeros((nAmp, nPha, nbins))
for k, i in enumerate(vecbin):
# Find where phase take vecbin values :
pL, pC = np.where((pha >= i[0]) & (pha < i[1]))
# Matrix to do amp x binMat :
binMat = np.zeros((npts, nPha))
binMat[pC, pL] = 1
meanMat = np.matlib.repmat(binMat.sum(axis=0), nAmp, 1)
meanMat[meanMat == 0] = 1
# Multiply matrix :
abin[:, :, k] = np.divide(np.dot(amp, binMat), meanMat)
abinsum = np.array([abin.sum(axis=2) for k in range(nbins)])
return abin, abinsum
评论列表
文章目录