plot_spectra.py 文件源码

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

项目:DR1_analysis 作者: GBTAmmoniaSurvey 项目源码 文件源码
def trim_edge_cube(cube):
    """  trim_edge_cube: Function that reads in a cube and removes the edges 
    in the cube. 
    It runs the erode function to make sure that pixels within 3 pixels away 
    from the edges are blanked. 
    This is useful to remove very noisy pixels due to lower coverage by KFPA.
    ----------------------------------------
    Warning: This function modifies the cube.
    """
    # 
    mask = np.isfinite(cube)
    if len(cube.shape) == 2:
        mask_2d = mask[:,:]
    else:
        mask_2d = mask[0,:,:]
    # remove image edges
    mask_2d[:,0] = mask_2d[:,-1] = False
    mask_2d[0,:] = mask_2d[-1,:] = False
    # now erode image (using disk) and convert back to 3D mask
    # then replace all voxels with NaN
    mask &= erosion(mask_2d,disk(5))
    cube[~mask] = np.nan
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号