polished option help messages

This commit is contained in:
Philip Eisenlohr 2016-04-22 14:20:36 -05:00
parent dffa119724
commit 3b53d1bc82
5 changed files with 62 additions and 50 deletions

View File

@ -94,18 +94,20 @@ Outputs at cell centers or cell nodes (into separate file).
""", version = scriptID) """, version = scriptID)
parser.add_option('-f', '--defgrad', parser.add_option('-f',
'--defgrad',
dest = 'defgrad', dest = 'defgrad',
metavar = 'string', metavar = 'string',
help = 'column label of deformation gradient [%default]') help = 'column label of deformation gradient [%default]')
parser.add_option('-c', '--coordinates', parser.add_option('-p',
'--pos', '--position',
dest = 'coords', dest = 'coords',
metavar = 'string', metavar = 'string',
help = 'column label of coordinates [%default]') help = 'label of coordinates [%default]')
parser.add_option('--nodal', parser.add_option('--nodal',
dest = 'nodal', dest = 'nodal',
action = 'store_true', action = 'store_true',
help = 'output nodal (not cell-centered) displacements') help = 'output nodal (instad of cell-centered) displacements')
parser.set_defaults(defgrad = 'f', parser.set_defaults(defgrad = 'f',
coords = 'pos', coords = 'pos',
@ -139,13 +141,13 @@ for name in filenames:
if table.label_dimension(options.defgrad) != 9: if table.label_dimension(options.defgrad) != 9:
errors.append('deformation gradient "{}" is not a 3x3 tensor.'.format(options.defgrad)) 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: 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: elif coordDim < 3:
remarks.append('appending {} dimension{} to coordinates "{}"...'.format(3-coordDim, remarks.append('appending {} dimension{} to coordinates "{}"...'.format(3-coordDim,
's' if coordDim < 2 else '', 's' if coordDim < 2 else '',
options.coords)) options.pos))
if remarks != []: damask.util.croak(remarks) if remarks != []: damask.util.croak(remarks)
if errors != []: if errors != []:
@ -155,7 +157,7 @@ for name in filenames:
# --------------- figure out size and grid --------------------------------------------------------- # --------------- figure out size and grid ---------------------------------------------------------
table.data_readArray([options.defgrad,options.coords]) table.data_readArray([options.defgrad,options.pos])
table.data_rewind() table.data_rewind()
if len(table.data.shape) < 2: table.data.shape += (1,) # expand to 2D shape if len(table.data.shape) < 2: table.data.shape += (1,) # expand to 2D shape
@ -202,8 +204,8 @@ for name in filenames:
table.info_append(scriptID + '\t' + ' '.join(sys.argv[1:])) 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 []) + 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)] + ['{}_avg({}).{}' .format(i+1,options.defgrad,options.pos) for i in xrange(3)] +
['{}_fluct({}).{}'.format(i+1,options.defgrad,options.coords) for i in xrange(3)] ) ['{}_fluct({}).{}'.format(i+1,options.defgrad,options.pos) for i in xrange(3)] )
table.head_write() table.head_write()
# ------------------------------------------ output data ------------------------------------------- # ------------------------------------------ output data -------------------------------------------

View File

@ -15,54 +15,61 @@ Add grain index based on similiarity of crystal lattice orientation.
""", version = scriptID) """, version = scriptID)
parser.add_option('-r', '--radius', parser.add_option('-r',
'--radius',
dest = 'radius', dest = 'radius',
type = 'float', metavar = 'float', type = 'float', metavar = 'float',
help = 'search radius') help = 'search radius')
parser.add_option('-d', '--disorientation', parser.add_option('-d',
'--disorientation',
dest = 'disorientation', dest = 'disorientation',
type = 'float', metavar = 'float', type = 'float', metavar = 'float',
help = 'disorientation threshold in degrees [%default]') help = 'disorientation threshold in degrees [%default]')
parser.add_option('-s', '--symmetry', parser.add_option('-s',
'--symmetry',
dest = 'symmetry', dest = 'symmetry',
type = 'string', metavar = 'string', type = 'string', metavar = 'string',
help = 'crystal symmetry [%default]') help = 'crystal symmetry [%default]')
parser.add_option('-e', '--eulers', parser.add_option('-e',
'--eulers',
dest = 'eulers', dest = 'eulers',
type = 'string', metavar = 'string', type = 'string', metavar = 'string',
help = 'Euler angles') help = 'label of Euler angles')
parser.add_option('--degrees', parser.add_option('--degrees',
dest = 'degrees', dest = 'degrees',
action = 'store_true', action = 'store_true',
help = 'Euler angles are given in degrees [%default]') help = 'Euler angles are given in degrees [%default]')
parser.add_option('-m', '--matrix', parser.add_option('-m',
'--matrix',
dest = 'matrix', dest = 'matrix',
type = 'string', metavar = 'string', type = 'string', metavar = 'string',
help = 'orientation matrix') help = 'label of orientation matrix')
parser.add_option('-a', parser.add_option('-a',
dest = 'a', dest = 'a',
type = 'string', metavar = 'string', type = 'string', metavar = 'string',
help = 'crystal frame a vector') help = 'label of crystal frame a vector')
parser.add_option('-b', parser.add_option('-b',
dest = 'b', dest = 'b',
type = 'string', metavar = 'string', type = 'string', metavar = 'string',
help = 'crystal frame b vector') help = 'label of crystal frame b vector')
parser.add_option('-c', parser.add_option('-c',
dest = 'c', dest = 'c',
type = 'string', metavar = 'string', type = 'string', metavar = 'string',
help = 'crystal frame c vector') help = 'label of crystal frame c vector')
parser.add_option('-q', '--quaternion', parser.add_option('-q',
'--quaternion',
dest = 'quaternion', dest = 'quaternion',
type = 'string', metavar = 'string', type = 'string', metavar = 'string',
help = 'quaternion') help = 'label of quaternion')
parser.add_option('-p', '--position', parser.add_option('-p',
dest = 'coords', '--pos', '--position',
dest = 'pos',
type = 'string', metavar = 'string', type = 'string', metavar = 'string',
help = 'spatial position of voxel [%default]') help = 'label of coordinates [%default]')
parser.set_defaults(disorientation = 5, parser.set_defaults(disorientation = 5,
symmetry = 'cubic', symmetry = 'cubic',
coords = 'pos', pos = 'pos',
degrees = False, degrees = False,
) )
@ -108,10 +115,10 @@ for name in filenames:
errors = [] errors = []
remarks = [] remarks = []
if not 3 >= table.label_dimension(options.coords) >= 1: if not 3 >= table.label_dimension(options.pos) >= 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))
if not np.all(table.label_dimension(label) == dim): 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) else: column = table.label_index(label)
if remarks != []: damask.util.croak(remarks) if remarks != []: damask.util.croak(remarks)
@ -140,7 +147,7 @@ for name in filenames:
bg.set_message('reading positions...') 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) grainID = -np.ones(len(table.data),dtype=int)
start = tick = time.clock() start = tick = time.clock()

View File

@ -22,12 +22,12 @@ parser.add_option('-p',
'--pos', '--position', '--pos', '--position',
dest = 'pos', dest = 'pos',
type = 'string', metavar = 'string', type = 'string', metavar = 'string',
help = 'coordinate label [%default]') help = 'label of coordinates [%default]')
parser.add_option('-l', parser.add_option('-l',
'--legacy', '--legacy',
dest = 'legacy', dest = 'legacy',
action = 'store_true', action = 'store_true',
help = 'force legacy VTK output') help = 'legacy VTK output')
parser.set_defaults(pos = 'pos', parser.set_defaults(pos = 'pos',
legacy = False, legacy = False,

View File

@ -28,7 +28,7 @@ parser.add_option('-p',
'--pos', '--position', '--pos', '--position',
dest = 'pos', dest = 'pos',
type = 'string', metavar = 'string', type = 'string', metavar = 'string',
help = 'coordinate label [%default]') help = 'label of coordinates [%default]')
parser.add_option('-g', parser.add_option('-g',
'--geom', '--geom',
dest = 'geom', dest = 'geom',
@ -38,7 +38,7 @@ parser.add_option('-l',
'--legacy', '--legacy',
dest = 'legacy', dest = 'legacy',
action = 'store_true', action = 'store_true',
help = 'force legacy VTK output') help = 'legacy VTK output')
parser.set_defaults(mode = 'cell', parser.set_defaults(mode = 'cell',
pos = 'pos', pos = 'pos',

View File

@ -19,16 +19,18 @@ Translate geom description into ASCIItable containing 1/2/3_pos and microstructu
""", version = scriptID) """, version = scriptID)
parser.add_option('-p','--position', parser.add_option('-p',
dest = 'position', '--pos', '--position',
dest = 'pos',
type = 'string', metavar = 'string', type = 'string', metavar = 'string',
help = 'column label for position [%default]') help = 'label of coordinates [%default]')
parser.add_option('-m','--microstructure', parser.add_option('-m',
'--microstructure',
dest = 'microstructure', dest = 'microstructure',
type = 'string', metavar = 'string', 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', microstructure = 'microstructure',
) )
@ -39,10 +41,11 @@ parser.set_defaults(position = 'pos',
if filenames == []: filenames = [None] if filenames == []: filenames = [None]
for name in filenames: for name in filenames:
try: try: table = damask.ASCIItable(name = name,
table = damask.ASCIItable(name = name,
outname = os.path.splitext(name)[0]+'.txt' if name else name, outname = os.path.splitext(name)[0]+'.txt' if name else name,
buffered = False, labeled = False) buffered = False,
labeled = False,
)
except: continue except: continue
damask.util.report(scriptName,name) damask.util.report(scriptName,name)
@ -75,7 +78,7 @@ for name in filenames:
table.info_clear() table.info_clear()
table.info_append(extra_header + [scriptID + '\t' + ' '.join(sys.argv[1:])]) table.info_append(extra_header + [scriptID + '\t' + ' '.join(sys.argv[1:])])
table.labels_clear() 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.head_write()
table.output_flush() table.output_flush()