本文整理匯總了Python中Filter.average_pulse方法的典型用法代碼示例。如果您正苦於以下問題:Python Filter.average_pulse方法的具體用法?Python Filter.average_pulse怎麽用?Python Filter.average_pulse使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Filter
的用法示例。
在下文中一共展示了Filter.average_pulse方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: tesana
# 需要導入模塊: import Filter [as 別名]
# 或者: from Filter import average_pulse [as 別名]
#.........這裏部分代碼省略.........
# Calculate offset (needs to be done before applying filter)
if p.size > 0:
offset = Filter.offset(p)
# Generate Filter
if filt is None:
pass
else:
if filt.lower() == "hanning":
f = np.hanning(p.shape[-1])
elif filt.lower() == "hamming":
f = np.hamming(p.shape[-1])
elif filt.lower() == "blackman":
f = np.blackman(p.shape[-1])
elif filt.lower() == "tukey":
f = tukey(p.shape[-1])
else:
raise ValueError('Unsupported filter: %s' % filt.lower())
print "Window filter function: %s" % filt.lower()
# Amplitude correction
cf = f.sum() / len(f)
p *= (f / cf)
n *= (f / cf)
# Equivalent noise bandwidth correction
enb = len(f)*(f**2).sum()/f.sum()**2
df *= enb
if p.size > 0:
# Calculate averaged pulse
avgp = Filter.average_pulse(p, max_shift=max_shift)
if savedat:
np.savetxt('%s-averagepulse.dat' % session, np.vstack((t, avgp)).T,
header='Time (s), Averaged Pulse (%s)' % ('R' if Rspace else ('A' if gain else 'V')), delimiter='\t')
if plotting:
figure()
plot(t, avgp)
xlabel('Time$\quad$(s)')
ylabel('Averaged Pulse$\quad$(%s)' % ('R' if Rspace else ('A' if gain else 'V')))
tight_layout()
savefig('%s-averagepulse.pdf' % session)
# Calculate averaged pulse spectrum
avgps = np.sqrt(Filter.power(avgp)) / df
if savedat:
np.savetxt('%s-avgpulse-power.dat' % session, np.vstack((np.arange(len(avgps))*df, avgps)).T,
header='Frequency (Hz), Average Pulse Power (%s/srHz)' % ('R' if Rspace else ('A' if gain else 'V')), delimiter='\t')
if plotting:
avgps[0] = 0 # for better plot
figure()
plot(np.arange(len(avgps))*df, avgps)
loglog()
xlabel('Frequency$\quad$(Hz)')
ylabel('Average Pulse Power$\quad$(%s/Hz)' % ('R' if Rspace else ('A' if gain else 'V')))
tight_layout()
savefig('%s-avgpulse-power.pdf' % session)
if n.size > 0:
# Plot noise spectrum