viewRecon.py 文件源码

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

项目:emc_and_dm 作者: eucall-software 项目源码 文件源码
def make_error_time_plot(fn):
    M.rcParams.update({'font.size': 12})
    errList = read.extract_arr_from_h5(fn, "/history/error", n=-1)
    timesList = read.extract_arr_from_h5(fn, "/history/time", n=-1)
    quatList = read.extract_arr_from_h5(fn, "/history/quaternion", n=-1)
    quatSwitchPos = N.where(quatList[:-1]-quatList[1:] != 0)[0] + 1
    P.ioff()
    fig, ax = P.subplots(2, 1, sharex=True, figsize=(6,6))
    fig.subplots_adjust(hspace=0.1)

    iters = range(1, len(errList)+1)
    ax[0].set_title("model change vs iterations")
    #ax[0].set_xlabel("iteration")
    ax[0].set_ylabel("log10(rms diffraction \nvolume change per voxel)")
    err_to_plot = N.log10(errList)
    ax[0].plot(iters, err_to_plot, 'k-')
    ax[0].plot(iters, err_to_plot, 'ko')
    (e_min, e_max) = (err_to_plot.min()-0.3, err_to_plot.max())
    e_int = 0.1*(e_max-e_min)
    ax[0].plot([1, 1], [e_min, e_max + e_int], 'k-')
    ax[0].text(2, e_max+e_int, "quat%d"%quatList[0], size=8, rotation=-0, ha='left', va='center', color='w', bbox=dict(boxstyle="larrow,pad=0.1",facecolor='0.1') )
    for n,qs in enumerate(quatSwitchPos):
        ax[0].plot([qs+1, qs+1], [e_min, e_max + e_int], 'k-')
        ax[0].text(qs, e_max+(1-n)*e_int, "quat%d"%quatList[qs], size=8, rotation=-0, ha='right', va='center', color='w', bbox=dict(boxstyle="rarrow,pad=0.1",facecolor='0.1') )

    ax[1].set_xlabel("iteration")
    ax[1].set_ylabel("time per iteration (s)")
    ax[1].plot(iters, timesList, 'k-')
    ax[1].plot(iters, timesList, 'ko')
    (t_min, t_max) = (timesList.min()-100, timesList.max())
    t_int = 0.1*(t_max-t_min)
    ax[1].plot([1, 1], [t_min, t_max + t_int], 'k-')
    ax[1].text(2, t_max+t_int, "quat%d"%quatList[0], size=8, rotation=-0, ha='left', va='center', color='w', bbox=dict(boxstyle="larrow,pad=0.1",facecolor='0.1') )
    for n,qs in enumerate(quatSwitchPos):
        ax[1].plot([qs+1, qs+1], [t_min, t_max+t_int], 'k-')
        ax[1].text(qs+0.5, t_min, "quat%d"%quatList[qs], size=8, rotation=45, ha='right', va='center', color='w', bbox=dict(boxstyle="rarrow,pad=0.1",facecolor='0.1'))
    img_name = "time_and_error_plot.pdf"
    P.savefig(img_name, bbox_inches='tight')
    print("Image has been saved as %s" % img_name)
    P.close(fig)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号