From 3b53d1bc828afdeafe2236f8978cfe37083d01e1 Mon Sep 17 00:00:00 2001 From: Philip Eisenlohr Date: Fri, 22 Apr 2016 14:20:36 -0500 Subject: [PATCH] polished option help messages --- ...addDisplacements.py => addDisplacement.py} | 28 ++++++----- processing/post/addGrainID.py | 49 +++++++++++-------- processing/post/vtk_pointcloud.py | 4 +- processing/post/vtk_rectilinearGrid.py | 6 +-- processing/pre/geom_toTable.py | 25 +++++----- 5 files changed, 62 insertions(+), 50 deletions(-) rename processing/post/{addDisplacements.py => addDisplacement.py} (93%) diff --git a/processing/post/addDisplacements.py b/processing/post/addDisplacement.py similarity index 93% rename from processing/post/addDisplacements.py rename to processing/post/addDisplacement.py index b73994bde..8a87a4b9f 100755 --- a/processing/post/addDisplacements.py +++ b/processing/post/addDisplacement.py @@ -94,18 +94,20 @@ Outputs at cell centers or cell nodes (into separate file). """, version = scriptID) -parser.add_option('-f', '--defgrad', +parser.add_option('-f', + '--defgrad', dest = 'defgrad', metavar = 'string', help = 'column label of deformation gradient [%default]') -parser.add_option('-c', '--coordinates', +parser.add_option('-p', + '--pos', '--position', dest = 'coords', metavar = 'string', - help = 'column label of coordinates [%default]') + help = 'label of coordinates [%default]') parser.add_option('--nodal', dest = 'nodal', action = 'store_true', - help = 'output nodal (not cell-centered) displacements') + help = 'output nodal (instad of cell-centered) displacements') parser.set_defaults(defgrad = 'f', coords = 'pos', @@ -120,8 +122,8 @@ if filenames == []: filenames = [None] for name in filenames: try: table = damask.ASCIItable(name = name, - outname = (os.path.splitext(name)[0]+ - '_nodal'+ + outname = (os.path.splitext(name)[0] + + '_nodal' + os.path.splitext(name)[1]) if (options.nodal and name) else None, buffered = False) except: continue @@ -139,13 +141,13 @@ for name in filenames: if table.label_dimension(options.defgrad) != 9: errors.append('deformation gradient "{}" is not a 3x3 tensor.'.format(options.defgrad)) - coordDim = table.label_dimension(options.coords) + coordDim = table.label_dimension(options.pos) if not 3 >= coordDim >= 1: - errors.append('coordinates "{}" need to have one, two, or three dimensions.'.format(options.coords)) + errors.append('coordinates "{}" need to have one, two, or three dimensions.'.format(options.pos)) elif coordDim < 3: remarks.append('appending {} dimension{} to coordinates "{}"...'.format(3-coordDim, 's' if coordDim < 2 else '', - options.coords)) + options.pos)) if remarks != []: damask.util.croak(remarks) if errors != []: @@ -155,7 +157,7 @@ for name in filenames: # --------------- figure out size and grid --------------------------------------------------------- - table.data_readArray([options.defgrad,options.coords]) + table.data_readArray([options.defgrad,options.pos]) table.data_rewind() if len(table.data.shape) < 2: table.data.shape += (1,) # expand to 2D shape @@ -201,9 +203,9 @@ for name in filenames: table.labels_clear() table.info_append(scriptID + '\t' + ' '.join(sys.argv[1:])) - table.labels_append((['{}_pos' .format(i+1) for i in xrange(3)] if options.nodal else []) + - ['{}_avg({}).{}' .format(i+1,options.defgrad,options.coords) for i in xrange(3)] + - ['{}_fluct({}).{}'.format(i+1,options.defgrad,options.coords) for i in xrange(3)] ) + table.labels_append((['{}_pos' .format(i+1) for i in xrange(3)] if options.nodal else []) + + ['{}_avg({}).{}' .format(i+1,options.defgrad,options.pos) for i in xrange(3)] + + ['{}_fluct({}).{}'.format(i+1,options.defgrad,options.pos) for i in xrange(3)] ) table.head_write() # ------------------------------------------ output data ------------------------------------------- diff --git a/processing/post/addGrainID.py b/processing/post/addGrainID.py index a250c197c..b7d9a2274 100755 --- a/processing/post/addGrainID.py +++ b/processing/post/addGrainID.py @@ -15,54 +15,61 @@ Add grain index based on similiarity of crystal lattice orientation. """, version = scriptID) -parser.add_option('-r', '--radius', +parser.add_option('-r', + '--radius', dest = 'radius', type = 'float', metavar = 'float', help = 'search radius') -parser.add_option('-d', '--disorientation', +parser.add_option('-d', + '--disorientation', dest = 'disorientation', type = 'float', metavar = 'float', help = 'disorientation threshold in degrees [%default]') -parser.add_option('-s', '--symmetry', +parser.add_option('-s', + '--symmetry', dest = 'symmetry', type = 'string', metavar = 'string', help = 'crystal symmetry [%default]') -parser.add_option('-e', '--eulers', +parser.add_option('-e', + '--eulers', dest = 'eulers', type = 'string', metavar = 'string', - help = 'Euler angles') -parser.add_option( '--degrees', + help = 'label of Euler angles') +parser.add_option('--degrees', dest = 'degrees', action = 'store_true', help = 'Euler angles are given in degrees [%default]') -parser.add_option('-m', '--matrix', +parser.add_option('-m', + '--matrix', dest = 'matrix', type = 'string', metavar = 'string', - help = 'orientation matrix') + help = 'label of orientation matrix') parser.add_option('-a', dest = 'a', type = 'string', metavar = 'string', - help = 'crystal frame a vector') + help = 'label of crystal frame a vector') parser.add_option('-b', dest = 'b', type = 'string', metavar = 'string', - help = 'crystal frame b vector') + help = 'label of crystal frame b vector') parser.add_option('-c', dest = 'c', type = 'string', metavar = 'string', - help = 'crystal frame c vector') -parser.add_option('-q', '--quaternion', + help = 'label of crystal frame c vector') +parser.add_option('-q', + '--quaternion', dest = 'quaternion', type = 'string', metavar = 'string', - help = 'quaternion') -parser.add_option('-p', '--position', - dest = 'coords', + help = 'label of quaternion') +parser.add_option('-p', + '--pos', '--position', + dest = 'pos', type = 'string', metavar = 'string', - help = 'spatial position of voxel [%default]') + help = 'label of coordinates [%default]') parser.set_defaults(disorientation = 5, symmetry = 'cubic', - coords = 'pos', + pos = 'pos', degrees = False, ) @@ -108,10 +115,10 @@ for name in filenames: errors = [] remarks = [] - if not 3 >= table.label_dimension(options.coords) >= 1: - errors.append('coordinates "{}" need to have one, two, or three dimensions.'.format(options.coords)) + if not 3 >= table.label_dimension(options.pos) >= 1: + errors.append('coordinates "{}" need to have one, two, or three dimensions.'.format(options.pos)) if not np.all(table.label_dimension(label) == dim): - errors.append('input {} does not have dimension {}.'.format(label,dim)) + errors.append('input "{}" does not have dimension {}.'.format(label,dim)) else: column = table.label_index(label) if remarks != []: damask.util.croak(remarks) @@ -140,7 +147,7 @@ for name in filenames: bg.set_message('reading positions...') - table.data_readArray(options.coords) # read position vectors + table.data_readArray(options.pos) # read position vectors grainID = -np.ones(len(table.data),dtype=int) start = tick = time.clock() diff --git a/processing/post/vtk_pointcloud.py b/processing/post/vtk_pointcloud.py index 0ffa52fa2..3a0f323f9 100755 --- a/processing/post/vtk_pointcloud.py +++ b/processing/post/vtk_pointcloud.py @@ -22,12 +22,12 @@ parser.add_option('-p', '--pos', '--position', dest = 'pos', type = 'string', metavar = 'string', - help = 'coordinate label [%default]') + help = 'label of coordinates [%default]') parser.add_option('-l', '--legacy', dest = 'legacy', action = 'store_true', - help = 'force legacy VTK output') + help = 'legacy VTK output') parser.set_defaults(pos = 'pos', legacy = False, diff --git a/processing/post/vtk_rectilinearGrid.py b/processing/post/vtk_rectilinearGrid.py index 962179b5c..90c8263fc 100755 --- a/processing/post/vtk_rectilinearGrid.py +++ b/processing/post/vtk_rectilinearGrid.py @@ -23,12 +23,12 @@ parser.add_option('-m', '--mode', dest = 'mode', type = 'choice', choices = ['cell','point'], - help = 'cell-centered or point-centered coordinates ') + help = 'cell-centered or point-centered coordinates') parser.add_option('-p', '--pos', '--position', dest = 'pos', type = 'string', metavar = 'string', - help = 'coordinate label [%default]') + help = 'label of coordinates [%default]') parser.add_option('-g', '--geom', dest = 'geom', @@ -38,7 +38,7 @@ parser.add_option('-l', '--legacy', dest = 'legacy', action = 'store_true', - help = 'force legacy VTK output') + help = 'legacy VTK output') parser.set_defaults(mode = 'cell', pos = 'pos', diff --git a/processing/pre/geom_toTable.py b/processing/pre/geom_toTable.py index dff0c8150..2a0498a6e 100755 --- a/processing/pre/geom_toTable.py +++ b/processing/pre/geom_toTable.py @@ -19,16 +19,18 @@ Translate geom description into ASCIItable containing 1/2/3_pos and microstructu """, version = scriptID) -parser.add_option('-p','--position', - dest = 'position', +parser.add_option('-p', + '--pos', '--position', + dest = 'pos', type = 'string', metavar = 'string', - help = 'column label for position [%default]') -parser.add_option('-m','--microstructure', + help = 'label of coordinates [%default]') +parser.add_option('-m', + '--microstructure', dest = 'microstructure', type = 'string', metavar = 'string', - help = 'column label for microstructure index [%default]') + help = 'label of microstructure index [%default]') -parser.set_defaults(position = 'pos', +parser.set_defaults(pos = 'pos', microstructure = 'microstructure', ) @@ -39,10 +41,11 @@ parser.set_defaults(position = 'pos', if filenames == []: filenames = [None] for name in filenames: - try: - table = damask.ASCIItable(name = name, - outname = os.path.splitext(name)[0]+'.txt' if name else name, - buffered = False, labeled = False) + try: table = damask.ASCIItable(name = name, + outname = os.path.splitext(name)[0]+'.txt' if name else name, + buffered = False, + labeled = False, + ) except: continue damask.util.report(scriptName,name) @@ -75,7 +78,7 @@ for name in filenames: table.info_clear() table.info_append(extra_header + [scriptID + '\t' + ' '.join(sys.argv[1:])]) table.labels_clear() - table.labels_append(['{}_{}'.format(1+i,options.position) for i in xrange(3)]+[options.microstructure]) + table.labels_append(['{}_{}'.format(1+i,options.pos) for i in xrange(3)]+[options.microstructure]) table.head_write() table.output_flush()