functions.py 文件源码

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

项目:decode 作者: deshima-dev 项目源码 文件源码
def plottimestream(array, ax, xtick='time', **kwargs):
    """Plot timestream data.

    Args:
        array (xarray.DataArray): Array which the timestream data are included.
        ax (matplotlib.axes): Axis you want to plot on.
        xtick (str): Type of x axis.
            'time': Time.
            'index': Time index.
        kwargs (optional): Plot options passed to ax.plot().
    """
    logger = getLogger('decode.plot.plottimestream')

    kidtpdict = {0: 'wideband', 1: 'filter', 2: 'blind'}
    if xtick == 'time':
        ax.plot(array.time, array, **kwargs)
    elif xtick == 'index':
        ax.plot(np.ogrid[:len(array.time)], array, **kwargs)
    ax.set_xlabel('{}'.format(xtick), fontsize=20, color='grey')
    # for label in ax.get_xticklabels():
    #     label.set_rotation(45)
    ax.set_ylabel(str(array.datatype.values), fontsize=20, color='grey')
    ax.legend()

    kidid = int(array.kidid)
    try:
        kidtp = kidtpdict[int(array.kidtp)]
    except KeyError:
        kidtp = 'filter'
    ax.set_title('ch #{} ({})'.format(kidid, kidtp), fontsize=20, color='grey')

    logger.info('timestream data (ch={}) has been plotted.'.format(kidid))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号