tdose_utilities.py 文件源码

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

项目:TDOSE 作者: kasperschmidt 项目源码 文件源码
def roll_2Dprofile(profile,position,padvalue=0.0,showprofiles=False):
    """
    Move 2D profile to given position in array by rolling it in x and y.
    Note that the roll does not handle sub-pixel moves.
    tu.shift_2Dprofile() does this using interpolation

    --- INPUT ---
    profile         profile to shift
    position        position to move center of image (profile) to:  [ypos,xpos]
    padvalue        the values to padd the images with when shifting profile
    showprofiles    Show profile when shifted?

    --- EXAMPLE OF USE ---
    tu.roll_2Dprofile(gauss2D,)

    """
    profile_dim = profile.shape

    yroll = np.int(np.round(position[0]-profile_dim[0]/2.))
    xroll = np.int(np.round(position[1]-profile_dim[1]/2.))
    profile_shifted = np.roll(np.roll(profile,yroll,axis=0),xroll,axis=1)

    if showprofiles:
        vmaxval = np.max(profile_shifted)
        plt.imshow(profile_shifted,interpolation='none',vmin=-vmaxval, vmax=vmaxval)
        plt.title('Positioned Source')
        plt.show()

    if yroll < 0:
        profile_shifted[yroll:,:] = padvalue
    else:
        profile_shifted[:yroll,:] = padvalue

    if xroll < 0:
        profile_shifted[:,xroll:] = padvalue
    else:
        profile_shifted[:,:xroll] = padvalue

    if showprofiles:
        plt.imshow(profile_shifted,interpolation='none',vmin=-vmaxval, vmax=vmaxval)
        plt.title('Positioned Source with 0s inserted')
        plt.show()

    return profile_shifted
# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号