added utility function coordGridAndSize

This commit is contained in:
Philip Eisenlohr 2018-01-30 09:18:59 -05:00
parent 710970d728
commit dc77e996cc
1 changed files with 13 additions and 1 deletions

View File

@ -100,6 +100,18 @@ def execute(cmd,
if process.returncode != 0: raise RuntimeError('{} failed with returncode {}'.format(cmd,process.returncode))
return out,error
def coordGridAndSize(coordinates):
"""Determines grid count and overall physical size along each dimension of an ordered array of coordinates"""
dim = coordinates.shape[1]
coords = [np.unique(coordinates[:,i]) for i in range(dim)]
mincorner = np.array(map(min,coords))
maxcorner = np.array(map(max,coords))
grid = np.array(map(len,coords),'i')
size = grid/np.maximum(np.ones(dim,'d'), grid-1.0) * (maxcorner-mincorner) # size from edge to edge = dim * n/(n-1)
size = np.where(grid > 1, size, min(size[grid > 1]/grid[grid > 1])) # spacing for grid==1 equal to smallest among other ones
return grid,size
# -----------------------------
class extendableOption(Option):
"""
@ -130,7 +142,7 @@ class backgroundMessage(threading.Thread):
'hexagon': ['', ''],
'square': ['', '', '', ''],
'triangle': ['', '', '', '', '', ''],
'amoeba': ['', '', '', '', '', '', '', ''],
'amoeba': ['', '', '', '', '', '', '', ''],
'beat': ['', '', '', '', '', '', '', '', '', '', ''],
'prison': ['', '', '', '', '', '', '', ''],
'breath': ['', '', '', '', '', '', '', '', ''],