def anamVertexRegionSize(vor, L, typical=6):
"""
Given a set of centroids (voronoi generators),
for each vertex in the tessellation, return 1 if the vertex is part of a region that
is not of the 'typical' size
"""
# vertices
v = vor.vertices
sizeFlag = numpy.zeros(len(v)) # flag for anamolous region size
#regSize = [[]]*len(v) # list of region sizes
for reg in vor.regions:
if len(reg) > 0 and -1 not in reg: # Non-empty and non-open region
size = len(reg)
if size != typical:
for vert in reg: # update size of all vertices that are in the region
#regSize[vert].append(size)
sizeFlag[vert] = 1
# Choose all in box
sizeFlag = sizeFlag[ numpy.logical_and(* [ numpy.logical_and(v[:,i]>=0, v[:,i] <= L[i]) for i in range(2) ] )]
sizeFlag = sizeFlag.astype('int')
return sizeFlag
评论列表
文章目录