def circular_mask(size):
"""Create a circular mask for an array
Useful when sampling rasters for a laser shot
"""
r = size/2
c = (r,r)
y,x = np.ogrid[-c[0]:size-c[0], -c[1]:size-c[1]]
mask = ~(x*x + y*y <= r*r)
return mask
#This correctly handles nan, and is efficient for smaller arrays
评论列表
文章目录