def power_plot(data, sfreq, toffset, log_scale, zscale, title):
"""Plot the computed power of the iq data."""
print("power")
t_axis = numpy.arange(0, len(data)) / sfreq + toffset
if log_scale:
lrxpwr = 10 * numpy.log10(data + 1E-12)
else:
lrxpwr = data
zscale_low, zscale_high = zscale
if zscale_low == 0 and zscale_high == 0:
if log_scale:
zscale_low = numpy.min(
lrxpwr[numpy.where(lrxpwr.real != -numpy.Inf)])
zscale_high = numpy.max(lrxpwr) + 3.0
else:
zscale_low = numpy.min(lrxpwr)
zscale_high = numpy.max(lrxpwr)
fig = plt.figure()
ax = fig.add_subplot(1, 1, 1)
ax.plot(t_axis, lrxpwr.real)
ax.grid(True)
ax.axis([toffset, t_axis[len(t_axis) - 1], zscale_low, zscale_high])
ax.set_xlabel('time (seconds)')
if log_scale:
ax.set_ylabel('power (dB)')
else:
ax.set_ylabel('power')
ax.set_title(title)
return fig
评论列表
文章目录