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)
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
@ -202,8 +204,8 @@ for name in filenames:
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)] )
['{}_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 -------------------------------------------

View File

@ -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()

View File

@ -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,

View File

@ -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',

View File

@ -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,
try: table = damask.ASCIItable(name = name,
outname = os.path.splitext(name)[0]+'.txt' if name else name,
buffered = False, labeled = False)
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()