From 355d576b4dbe292f3c94f73c7b2900ca73cd626a Mon Sep 17 00:00:00 2001 From: Philip Eisenlohr Date: Tue, 30 Jan 2018 09:20:47 -0500 Subject: [PATCH] shortened code with utility function coordGridAndSize --- processing/post/addCurl.py | 7 +------ processing/post/addDivergence.py | 7 +------ processing/post/addGaussian.py | 14 ++++---------- processing/post/addGradient.py | 7 +------ 4 files changed, 7 insertions(+), 28 deletions(-) diff --git a/processing/post/addCurl.py b/processing/post/addCurl.py index 01499b672..c197c5664 100755 --- a/processing/post/addCurl.py +++ b/processing/post/addCurl.py @@ -139,12 +139,7 @@ for name in filenames: table.data_readArray() - coords = [np.unique(table.data[:,coordCol+i]) for i in range(3)] - 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(3,'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 + grid,size = damask.util.gridAndSize(table.data[:,table.label_indexrange(options.pos)]) # ------------------------------------------ process value field ----------------------------------- diff --git a/processing/post/addDivergence.py b/processing/post/addDivergence.py index d7905630e..98916f56c 100755 --- a/processing/post/addDivergence.py +++ b/processing/post/addDivergence.py @@ -136,12 +136,7 @@ for name in filenames: table.data_readArray() - coords = [np.unique(table.data[:,coordCol+i]) for i in range(3)] - 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(3,'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 + grid,size = damask.util.coordGridAndSize(table.data[:,table.label_indexrange(options.pos)]) # ------------------------------------------ process value field ----------------------------------- diff --git a/processing/post/addGaussian.py b/processing/post/addGaussian.py index bc5599d49..c198ef62f 100755 --- a/processing/post/addGaussian.py +++ b/processing/post/addGaussian.py @@ -18,7 +18,7 @@ scriptID = ' '.join([scriptName,damask.version]) parser = OptionParser(option_class=damask.extendableOption, usage='%prog option(s) [ASCIItable(s)]', description = """ Add column(s) containing Gaussian filtered values of requested column(s). Operates on periodic and non-periodic ordered three-dimensional data sets. -For Details see scipy.ndimage documentation. +For details see scipy.ndimage documentation. """, version = scriptID) @@ -43,15 +43,14 @@ parser.add_option('--sigma', parser.add_option('--periodic', dest = 'periodic', action = 'store_true', - help = 'assume periodic grain structure' - ) + help = 'assume periodic grain structure') parser.set_defaults(pos = 'pos', order = 0, sigma = 1, - periodic = False + periodic = False, ) (options,filenames) = parser.parse_args() @@ -110,12 +109,7 @@ for name in filenames: table.data_readArray() - coords = [np.unique(table.data[:,colCoord+i]) for i in range(3)] - 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(3,'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 + grid,size = damask.util.coordGridAndSize(table.data[:,table.label_indexrange(options.pos)]) # ------------------------------------------ process value field ----------------------------------- diff --git a/processing/post/addGradient.py b/processing/post/addGradient.py index 5a73af3a3..c788f5286 100755 --- a/processing/post/addGradient.py +++ b/processing/post/addGradient.py @@ -135,12 +135,7 @@ for name in filenames: table.data_readArray() - coords = [np.unique(table.data[:,coordCol+i]) for i in range(3)] - 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(3,'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 + grid,size = damask.util.coordGridAndSize(table.data[:,table.label_indexrange(options.pos)]) # ------------------------------------------ process value field -----------------------------------