malib.py 文件源码

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

项目:pygeotools 作者: dshean 项目源码 文件源码
def nanfill(a, f_a, *args, **kwargs):
    """Fill masked areas with np.nan

    Wrapper for functions that can't handle ma (e.g. scipy.ndimage)

    This will force filters to ignore nan, but causes adjacent pixels to be set to nan as well: http://projects.scipy.org/scipy/ticket/1155 
    """
    a = checkma(a)
    ndv = a.fill_value  
    #Note: The following fails for arrays that are not float (np.nan is float)
    b = f_a(a.filled(np.nan), *args, **kwargs)
    #the fix_invalid fill_value parameter doesn't seem to work
    out = np.ma.fix_invalid(b, copy=False)
    out.set_fill_value(ndv)
    return out

#=======================
#Masked array stats
#=======================
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号