drf_plot.py 文件源码

python
阅读 31 收藏 0 点赞 0 评论 0

项目:digital_rf 作者: MITHaystack 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号