correcting help and default, some comments

This commit is contained in:
Martin Diehl 2014-09-12 14:46:12 +00:00
parent afb9a2186b
commit f2c4db0bb5
5 changed files with 19 additions and 39 deletions

View File

@ -292,15 +292,15 @@ parser.add_option('--points', dest='output_points', action='store_true',
parser.add_option('--nopoints', dest='output_points', action='store_false',
help='omit VTK points file')
parser.add_option('--separator', dest='separator', type='choice', choices=sepChoices, metavar='string',
help='data separator (%s) [t]'%(','.join(map(str,sepChoices))))
parser.add_option('--scaling', dest='scaling', action='extend', type='string',
help='scaling of fluctuation', metavar = '<float LIST>')
help='data separator {%s} [t]'%(' '.join(map(str,sepChoices))))
parser.add_option('--scaling', dest='scaling', action='extend', metavar = '<float LIST>',
help='scaling of fluctuation')
parser.add_option('-u', '--unitlength', dest='unitlength', type='float', metavar = 'float',
help='set unit length for 2D model [%default]')
parser.add_option('--filenodalcoords', dest='filenodalcoords', metavar = 'string',
help='ASCII table containing nodal coords')
parser.add_option('--labelnodalcoords', dest='labelnodalcoords', nargs=3,
help='labels of nodal coords in ASCII table %default', metavar = 'string string string')
help='labels of nodal coords in ASCII table {%s} '%(' '.join(map(str,%default))), metavar = 'string string string')
parser.add_option('-l', '--linear', dest='linearreconstruction', action='store_true',
help='use linear reconstruction of geometry [%default]')
@ -319,7 +319,7 @@ parser.set_defaults(undeformed = False)
parser.set_defaults(unitlength = 0.0)
parser.set_defaults(cell = True)
parser.set_defaults(filenodalcoords = '')
parser.set_defaults(labelnodalcoords = ['coord.x','coord.y','coord.z'])
parser.set_defaults(labelnodalcoords = ('coord.x','coord.y','coord.z'))
parser.set_defaults(linearreconstruction = False)
sep = {'n': '\n', 't': '\t', 's': ' '}
@ -528,8 +528,8 @@ for filename in args:
'quadruple': 4,\
}
structure = vtk.vtkIntArray()
structure.SetName('Microstructures')
# structure = vtk.vtkIntArray()
# structure.SetName('Microstructures')
for datatype in fields.keys():
print '\n%s:'%datatype,
fields[datatype]['_order_'] = []

View File

@ -56,6 +56,7 @@ for file in files:
table.head_read() # read ASCII header info
table.info_append(scriptID + '\t' + ' '.join(sys.argv[1:]))
# --------------- figure out columns to process ---------------------------------------------------
active = defaultdict(list)
column = defaultdict(dict)
missingColumns = False

View File

@ -42,7 +42,7 @@ parser.add_option('-d','--direction', \
'--hkl', dest='hkl', type='int', nargs=3, metavar='int int int',
help='direction of elastic modulus %default')
parser.set_defaults(vector = [])
parser.set_defaults(hkl = [1,1,1])
parser.set_defaults(hkl = (1,1,1))
(options,filenames) = parser.parse_args()

View File

@ -3,7 +3,7 @@
import pdb, os, sys, gc, math, re, threading, time, struct, string
import damask
from optparse import OptionParser, OptionGroup, Option, SUPPRESS_HELP
from optparse import OptionParser
fileExtensions = { \
@ -257,27 +257,6 @@ class MPIEspectral_result: # mimic py_post result object
def element_tensors(self):
return self.N_element_tensors
# -----------------------------
class MyOption(Option):
# -----------------------------
# used for definition of new option parser action 'extend', which enables to take multiple option arguments
# taken from online tutorial http://docs.python.org/library/optparse.html
ACTIONS = Option.ACTIONS + ("extend",)
STORE_ACTIONS = Option.STORE_ACTIONS + ("extend",)
TYPED_ACTIONS = Option.TYPED_ACTIONS + ("extend",)
ALWAYS_TYPED_ACTIONS = Option.ALWAYS_TYPED_ACTIONS + ("extend",)
def take_action(self, action, dest, opt, value, values, parser):
if action == "extend":
lvalue = value.split(",")
values.ensure_value(dest, []).extend(lvalue)
else:
Option.take_action(self, action, dest, opt, value, values, parser)
# -----------------------------
class backgroundMessage(threading.Thread):
@ -644,7 +623,7 @@ def SummarizePostfile(stat,where=sys.stdout,format='marc'):
# --- input parsing
parser = OptionParser(option_class=MyOption, usage='%prog [options] resultfile', description = """
parser = OptionParser(option_class=damask.extendableOption, usage='%prog [options] resultfile', description = """
Extract data from a .t16 (MSC.Marc) or .spectralOut results file.
List of output variables is given by options '--ns','--es','--et','--ho','--cr','--co'.
@ -661,7 +640,7 @@ User mappings need to be formulated in an incremental fashion for each new data
and may use the current (incremental) result, b(ase), as well as the number, n(umber),
of already processed data points for evaluation.
""" + string.replace('$Id$','\n','\\n')
""", version = string.replace('$Id$','\n','\\n')
)
parser.add_option('-i','--info', action='store_true', dest='info', \
@ -799,12 +778,12 @@ if options.nodalScalar and ( options.elemScalar or options.elemTensor
parser.print_help()
parser.error('not allowed to mix nodal with elemental results...')
if not options.nodalScalar: options.nodalScalar = []
if not options.elemScalar: options.elemScalar = []
if not options.elemTensor: options.elemTensor = []
if not options.homogenizationResult: options.homogenizationResult = []
if not options.nodalScalar: options.nodalScalar = []
if not options.elemScalar: options.elemScalar = []
if not options.elemTensor: options.elemTensor = []
if not options.homogenizationResult: options.homogenizationResult = []
if not options.crystalliteResult: options.crystalliteResult = []
if not options.constitutiveResult: options.constitutiveResult = []
if not options.constitutiveResult: options.constitutiveResult = []
options.sort.reverse()
options.sep.reverse()

View File

@ -20,9 +20,9 @@ Uniformly scale values of scalar, vector, or tensor columns by given factor.
""", version = scriptID)
parser.add_option('-v','--vector', dest = 'vector', action = 'extend', metavar = 'string',
help = 'column heading of vector to scale')
help = 'column heading of vector to rotate')
parser.add_option('-t','--tensor', dest = 'tensor', action = 'extend', metavar = 'string',
help = 'column heading of tensor to scale')
help = 'column heading of tensor to rotate')
parser.add_option('-r', '--rotation',dest = 'rotation', type = 'float', nargs = 4, metavar = ' '.join(['float']*4),
help = 'angle and axis to rotate data %default')
parser.add_option('-d', '--degrees', dest = 'degrees', action = 'store_true',