From 24382ed827c8c0daf9634024003e9f49e2e5eb93 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Mon, 16 Nov 2015 10:52:56 +0000 Subject: [PATCH] unified options to enable automated parsing for documentation --- processing/pre/abq_addUserOutput.py | 42 +++--- processing/pre/geom_canvas.py | 4 +- processing/pre/geom_fromEuclideanDistance.py | 4 +- processing/pre/geom_fromMinimalSurface.py | 8 -- processing/pre/geom_fromVPSC.py | 2 +- .../pre/geom_fromVoronoiTessellation.py | 15 +-- processing/pre/geom_unpack.py | 12 +- processing/pre/gmsh_identifySurfaces.py | 34 ++--- processing/pre/hybridIA_linODFsampling.py | 6 +- .../pre/patchFromReconstructedBoundaries.py | 127 ++++++++---------- 10 files changed, 105 insertions(+), 149 deletions(-) diff --git a/processing/pre/abq_addUserOutput.py b/processing/pre/abq_addUserOutput.py index dc6f49b0c..537587169 100755 --- a/processing/pre/abq_addUserOutput.py +++ b/processing/pre/abq_addUserOutput.py @@ -72,32 +72,28 @@ Or have an existing set of user variables copied over from another *.inp file. """, version= scriptID) -parser.add_option('-n','--number', dest='number', type='int', \ - help='maximum requested User Defined Variable [%default]') -parser.add_option('--homogenization', dest='homog', \ - help='homogenization identifier (as string or integer [%default])') -parser.add_option('--crystallite', dest='cryst', \ - help='crystallite identifier (as string or integer [%default])') -parser.add_option('--phase', dest='phase', \ - help='phase identifier (as string or integer [%default])') -parser.add_option('--use', dest='useFile', \ - help='Optionally parse output descriptors from '+ - 'different .outputZZZ file. Saves the effort '+ - 'to start a calculation for each job [%default])') -parser.add_option('--option', dest='damaskOption', \ - help='Add damask option to input file '+ - 'for example: "periodic x z" [%default]') -parser.set_defaults(number = 0) -parser.set_defaults(homog = '1') -parser.set_defaults(cryst = '1') -parser.set_defaults(phase = '1') -parser.set_defaults(useFile = '') -parser.set_defaults(damaskOption = '') +parser.add_option('-m', dest='number', type='int', metavar = 'int', + help='maximum requested User Defined Variable [%default]') +parser.add_option('--homogenization', dest='homog', metavar = 'string', + help='homogenization name or index [%default]') +parser.add_option('--crystallite', dest='cryst', metavar = 'string', + help='crystallite identifier name or index [%default]') +parser.add_option('--phase', dest='phase', metavar = 'string', + help='phase identifier name or index [%default]') +parser.add_option('--use', dest='useFile', metavar = 'string', + help='optionally parse output descriptors from '+ + 'outputXXX files of given name') +parser.add_option('--option', dest='damaskOption', metavar = 'string', + help='Add DAMASK option to input file, e.g. "periodic x z"') + +parser.set_defaults(number = 0, + homog = '1', + cryst = '1', + phase = '1') (options, files) = parser.parse_args() if not files: - parser.print_help() parser.error('no file(s) specified...') me = { 'Homogenization': options.homog, @@ -108,7 +104,7 @@ me = { 'Homogenization': options.homog, for file in files: print '\033[1m'+scriptName+'\033[0m: '+file+'\n' - if options.useFile != '': + if options.useFile: formatFile = os.path.splitext(options.useFile)[0] else: formatFile = os.path.splitext(file)[0] diff --git a/processing/pre/geom_canvas.py b/processing/pre/geom_canvas.py index 2a7d1985b..54b2ab692 100755 --- a/processing/pre/geom_canvas.py +++ b/processing/pre/geom_canvas.py @@ -21,11 +21,11 @@ Changes the (three-dimensional) canvas of a spectral geometry description. parser.add_option('-g', '--grid', dest = 'grid', type = 'string', nargs = 3, metavar = ' '.join(['string']*3), - help = 'a,b,c grid of hexahedral box [unchanged]') + help = 'a,b,c grid of hexahedral box [auto]') parser.add_option('-o', '--offset', dest = 'offset', type = 'int', nargs = 3, metavar = ' '.join(['int']*3), - help = 'a,b,c offset from old to new origin of grid %default') + help = 'a,b,c offset from old to new origin of grid [%default]') parser.add_option('-f', '--fill', dest = 'fill', type = 'int', metavar = 'int', diff --git a/processing/pre/geom_fromEuclideanDistance.py b/processing/pre/geom_fromEuclideanDistance.py index 928990621..f121f49af 100755 --- a/processing/pre/geom_fromEuclideanDistance.py +++ b/processing/pre/geom_fromEuclideanDistance.py @@ -92,11 +92,11 @@ boundaries, triple lines, and quadruple points. parser.add_option('-t','--type', dest = 'type', action = 'extend', metavar = '', - help = 'feature type (%s) '%(', '.join(map(lambda x:'|'.join(x['alias']),features))) ) + help = 'feature type {%s} '%(', '.join(map(lambda x:'|'.join(x['alias']),features))) ) parser.add_option('-n','--neighborhood', dest = 'neighborhood', choices = neighborhoods.keys(), metavar = 'string', - help = 'type of neighborhood (%s) [neumann]'%(', '.join(neighborhoods.keys()))) + help = 'type of neighborhood {%s} [neumann]'%(', '.join(neighborhoods.keys()))) parser.add_option('-s', '--scale', dest = 'scale', type = 'float', metavar = 'float', diff --git a/processing/pre/geom_fromMinimalSurface.py b/processing/pre/geom_fromMinimalSurface.py index 6f35033b0..9d2953b2f 100755 --- a/processing/pre/geom_fromMinimalSurface.py +++ b/processing/pre/geom_fromMinimalSurface.py @@ -55,10 +55,6 @@ parser.add_option('--m', dest = 'microstructure', type = 'int', nargs = 2, metavar = 'int int', help = 'two microstructure indices to be used [%default]') -parser.add_option('-1', '--onedimensional', - dest = 'oneD', - action = 'store_true', - help = 'output geom file with two-dimensional data arrangement [%default]') parser.set_defaults(type = minimal_surfaces[0], threshold = 0.0, periods = 1, @@ -66,7 +62,6 @@ parser.set_defaults(type = minimal_surfaces[0], size = (1.0,1.0,1.0), homogenization = 1, microstructure = (1,2), - oneD = False, ) (options,filenames) = parser.parse_args() @@ -135,9 +130,6 @@ for name in filenames: table.data_clear() for x in xrange(options.grid[0]): table.data_append(options.microstructure[options.threshold < surface[options.type](X[x],Y[y],Z[z])]) - if options.oneD: - table.data_write() - table.data_clear() table.data_write() table.close() diff --git a/processing/pre/geom_fromVPSC.py b/processing/pre/geom_fromVPSC.py index a4d5a68f7..5ea56dc5b 100755 --- a/processing/pre/geom_fromVPSC.py +++ b/processing/pre/geom_fromVPSC.py @@ -30,7 +30,7 @@ parser.add_option('--crystallite', dest='crystallite', type='int', metavar = 'in parser.add_option('--compress', dest='compress', action='store_true', help='lump identical microstructure and texture information [%default]') parser.add_option('-p', '--precision', dest='precision', choices=['0','1','2','3'], metavar = 'int', - help = 'euler angles decimal places for output format and compressing (0,1,2,3) [2]') + help = 'euler angles decimal places for output format and compressing {0,1,2,3} [2]') parser.set_defaults(column = 7) parser.set_defaults(threshold = 1.0) diff --git a/processing/pre/geom_fromVoronoiTessellation.py b/processing/pre/geom_fromVoronoiTessellation.py index 3c45e964a..a51c1181c 100755 --- a/processing/pre/geom_fromVoronoiTessellation.py +++ b/processing/pre/geom_fromVoronoiTessellation.py @@ -113,11 +113,11 @@ Generate geometry description and material configuration by standard Voronoi tes parser.add_option('-g', '--grid', dest = 'grid', type = 'int', nargs = 3, metavar = ' '.join(['int']*3), - help = 'a,b,c grid of hexahedral box [from seeds file]') + help = 'a,b,c grid of hexahedral box [auto]') parser.add_option('-s', '--size', dest = 'size', type = 'float', nargs = 3, metavar=' '.join(['float']*3), - help = 'x,y,z size of hexahedral box [from seeds file or 1.0 along largest grid point number]') + help = 'x,y,z size of hexahedral box [auto]') parser.add_option('-o', '--origin', dest = 'origin', type = 'float', nargs = 3, metavar=' '.join(['float']*3), @@ -141,7 +141,7 @@ parser.add_option('-e', '--eulers', parser.add_option('--axes', dest = 'axes', type = 'string', nargs = 3, metavar = ' '.join(['string']*3), - help = 'orientation coordinate frame in terms of position coordinate frame [same]') + help = 'orientation coordinate frame in terms of position coordinate frame') parser.add_option('--homogenization', dest = 'homogenization', type = 'int', metavar = 'int', @@ -165,7 +165,7 @@ parser.add_option('--secondphase', parser.add_option('-l', '--laguerre', dest = 'laguerre', action = 'store_true', - help = 'use Laguerre (weighted Voronoi) tessellation [%default]') + help = 'use Laguerre (weighted Voronoi) tessellation') parser.add_option('--cpus', dest = 'cpus', type = 'int', metavar = 'int', @@ -173,12 +173,9 @@ parser.add_option('--cpus', parser.add_option('--nonperiodic', dest = 'nonperiodic', action = 'store_true', - help = 'use nonperiodic tessellation [%default]') + help = 'use nonperiodic tessellation') -parser.set_defaults(grid = None, - size = None, - origin = None, - position = 'pos', +parser.set_defaults(position = 'pos', weight = 'weight', microstructure = 'microstructure', eulers = 'eulerangles', diff --git a/processing/pre/geom_unpack.py b/processing/pre/geom_unpack.py index 987135239..bc437f275 100755 --- a/processing/pre/geom_unpack.py +++ b/processing/pre/geom_unpack.py @@ -15,16 +15,9 @@ scriptName = os.path.splitext(scriptID.split()[1])[0] parser = OptionParser(option_class=damask.extendableOption, usage='%prog options [file[s]]', description = """ Unpack geometry files containing ranges "a to b" and/or "n of x" multiples (exclusively in one line). + """, version = scriptID) -parser.add_option('-1', '--onedimensional', - dest = 'oneD', - action = 'store_true', - help = 'output geom file with one-dimensional data arrangement [%default]') - -parser.set_defaults(oneD = False, - ) - (options, filenames) = parser.parse_args() # --- loop over input files ------------------------------------------------------------------------- @@ -76,8 +69,7 @@ for name in filenames: microstructure = table.microstructure_read(info['grid']) # read microstructure formatwidth = int(math.floor(math.log10(microstructure.max())+1)) # efficient number printing format - table.data = microstructure if options.oneD else \ - microstructure.reshape((info['grid'][0],info['grid'][1]*info['grid'][2]),order='F').transpose() + table.data = microstructure.reshape((info['grid'][0],info['grid'][1]*info['grid'][2]),order='F').transpose() table.data_writeArray('%%%ii'%(formatwidth),delimiter = ' ') #--- output finalization -------------------------------------------------------------------------- diff --git a/processing/pre/gmsh_identifySurfaces.py b/processing/pre/gmsh_identifySurfaces.py index f94d5f264..e2e66d6dc 100755 --- a/processing/pre/gmsh_identifySurfaces.py +++ b/processing/pre/gmsh_identifySurfaces.py @@ -23,28 +23,22 @@ def func(seq): #-------------------------------------------------------------------------------------------------- parser = OptionParser(option_class=damask.extendableOption, usage='%prog options [file[s]]', description = """ - Recognize bounding surfaces and append them as physical sufaces in the geo file. """, version = scriptID) -parser.add_option('-n','--numvol', dest = 'N', \ - type='int',\ - metavar='int',\ +Recognize bounding surfaces and append them as physical sufaces in the geo file. + +""", version = scriptID) + +parser.add_option('-n','--numvol', dest = 'N', type='int', metavar='int', help='number of physical volumes' ) -parser.add_option('-f','--faces', dest = 'surfaces', \ - action = 'extend', \ - type = 'string', \ - metavar = '', \ - help = 'surfaces to tag (x, y, and/or z)') -parser.add_option('-s','--size', dest = 'size', \ - type='float',\ - metavar='float',\ - help='mesh size' ) -parser.add_option('-d','--dim', dest = 'dimension', \ - type='int',\ - metavar='float',\ - help='dimension of geometry' ) +parser.add_option('-f','--faces', dest = 'surfaces', action = 'extend', type = 'string', metavar = '', + help = 'surfaces to tag {x, y, z}') +parser.add_option('-s','--size', dest = 'size', type='float', metavar='float', + help='mesh size [%default]' ) +parser.add_option('-d','--dim', dest = 'dimension', type='int', metavar='int', + help='dimension of geometry [%default]' ) (options, filename) = parser.parse_args() -parser.set_defaults(size = 0.1) -parser.set_defaults(dimension = 3) +parser.set_defaults(size = 0.1, + dimension = 3) my_geofile = filename[0] numVol = options.N @@ -200,5 +194,3 @@ elif (options.dimension == 2): f.write('Background Field = 1;\n') f.close() - - diff --git a/processing/pre/hybridIA_linODFsampling.py b/processing/pre/hybridIA_linODFsampling.py index 14d8fa19d..700ab86f0 100755 --- a/processing/pre/hybridIA_linODFsampling.py +++ b/processing/pre/hybridIA_linODFsampling.py @@ -201,17 +201,19 @@ def TothVanHoutteSTAT (ODF,nSamples): # -------------------------------------------------------------------- parser = OptionParser(option_class=damask.extendableOption, usage='%prog options [file[s]]', description = """ Transform linear binned ODF data into given number of orientations. +IA: integral approximation, STAT: Van Houtte, MC: Monte Carlo """, version = scriptID) +algorithms = ['IA', 'STAT','MC'] parser.add_option('-n', '--nsamples', dest = 'number', type = 'int', metavar = 'int', help = 'number of orientations to be generated [%default]') parser.add_option('-a','--algorithm', dest = 'algorithm', - type = 'string', metavar = 'string', - help = 'sampling algorithm. IA: integral approximation, STAT: Van Houtte, MC: Monte Carlo. [%default].') #make choice + choices = algorithms, metavar = 'string', + help = 'sampling algorithm {%s} [IA]'%(', '.join(algorithms))) parser.add_option('-p','--phase', dest = 'phase', type = 'int', metavar = 'int', diff --git a/processing/pre/patchFromReconstructedBoundaries.py b/processing/pre/patchFromReconstructedBoundaries.py index 12ae1d510..13dfacd52 100755 --- a/processing/pre/patchFromReconstructedBoundaries.py +++ b/processing/pre/patchFromReconstructedBoundaries.py @@ -787,78 +787,63 @@ reconstructed boundary file """, version = scriptID) -parser.add_option("-o", "--output", action='extend', dest='output', \ - help="types of output [image, mentat, procedure, spectral]") -parser.add_option("-p", "--port", type="int",\ - dest="port",\ - help="Mentat connection port [%default]") -parser.add_option("-2", "--twodimensional", action="store_true",\ - dest="twoD",\ - help="twodimensional model [%default]") -parser.add_option("-s","--patchsize", type="float",\ - dest="size",\ - help="height of patch [%default]") -parser.add_option("-e", "--strain", type="float",\ - dest="strain",\ - help="final strain to reach in simulation [%default]") -parser.add_option("--rate", type="float",\ - dest="strainrate",\ - help="(engineering) strain rate to simulate [%default]") -parser.add_option("-N", "--increments", type="int",\ - dest="increments",\ - help="number of increments to take [%default]") -parser.add_option("-t", "--tolerance", type="float",\ - dest="tolerance",\ - help="relative tolerance of pixel positions to be swept [%default]") -parser.add_option("-m", "--mesh", choices=['dt_planar_trimesh','af_planar_trimesh','af_planar_quadmesh'],\ - dest="mesh",\ - help="algorithm and element type for automeshing (dt_planar_trimesh, af_planar_trimesh, af_planar_quadmesh) [%default]") -parser.add_option("-x", "--xmargin", type="float",\ - dest="xmargin",\ - help="margin in x in units of patch size [%default]") -parser.add_option("-y", "--ymargin", type="float",\ - dest="ymargin",\ - help="margin in y in units of patch size [%default]") -parser.add_option("-r", "--resolution", type="int",\ - dest="resolution",\ - help="number of Fourier points/Finite Elements across patch size + x_margin [%default]") -parser.add_option("-z", "--extrusion", type="int",\ - dest="extrusion",\ - help="number of repetitions in z-direction [%default]") -parser.add_option("-i", "--imagesize", type="int",\ - dest="imgsize",\ - help="size of PNG image [%default]") -parser.add_option("-M", "--coordtransformation", type="float", nargs=4, \ - dest="M",\ - help="2x2 transformation from rcb to Euler coords [%default]") -parser.add_option("--scatter", type="float",\ - dest="scatter",\ - help="orientation scatter %default") -parser.add_option("--segment", type="int",\ - dest="segmentcolumn",\ - help="column holding the first entry for the segment end points in the rcb file [%default]") -parser.add_option("--id", type="int",\ - dest="idcolumn",\ - help="column holding the right hand grain ID in the rcb file [%default]") +meshes=['dt_planar_trimesh','af_planar_trimesh','af_planar_quadmesh'] +parser.add_option('-o', '--output', action='extend', dest='output', metavar = '', + help='types of output {image, mentat, procedure, spectral}') +parser.add_option('-p', '--port', type='int', metavar = 'int', + dest='port', help='Mentat connection port [%default]') +parser.add_option('-2', '--twodimensional', action='store_true', + dest='twoD',help='use 2D model') +parser.add_option('-s','--patchsize', type='float', metavar = 'float', + dest='size', help='height of patch [%default]') +parser.add_option('-e', '--strain', type='float', metavar = 'float', + dest='strain', help='final strain to reach in simulation [%default]') +parser.add_option('--rate', type='float', metavar = 'float', + dest='strainrate', help='engineering strain rate to simulate [%default]') +parser.add_option('-N', '--increments', type='int', metavar = 'int', + dest='increments', help='number of increments to take [%default]') +parser.add_option('-t', '--tolerance', type='float', metavar = 'float', + dest='tolerance', help='relative tolerance of pixel positions to be swept [%default]') +parser.add_option('-m', '--mesh', choices = meshes, + metavar = '', dest='mesh', + help='algorithm and element type for automeshing {%s} [dt_planar_trimesh]'%(', '.join(meshes))) +parser.add_option('-x', '--xmargin', type='float', metavar = 'float', + dest='xmargin',help='margin in x in units of patch size [%default]') +parser.add_option('-y', '--ymargin', type='float', metavar = 'float', + dest='ymargin', help='margin in y in units of patch size [%default]') +parser.add_option('-r', '--resolution', type='int', metavar = 'int', + dest='resolution',help='number of Fourier points/Finite Elements across patch size + x_margin [%default]') +parser.add_option('-z', '--extrusion', type='int', metavar = 'int', + dest='extrusion', help='number of repetitions in z-direction [%default]') +parser.add_option('-i', '--imagesize', type='int', metavar = 'int', + dest='imgsize', help='size of PNG image [%default]') +parser.add_option('-M', '--coordtransformation', type='float', nargs=4, metavar = ' '.join(['float']*4), + dest='M', help='2x2 transformation from rcb to Euler coords [%default]') +parser.add_option('--scatter', type='float', metavar = 'float', + dest='scatter',help='orientation scatter [%default]') +parser.add_option('--segment', type='int', metavar = 'int', dest='segmentcolumn', + help='column holding the first entry for the segment end points in the rcb file [%default]') +parser.add_option('--id', type='int', dest='idcolumn', metavar = 'int', + help='column holding the right hand grain ID in the rcb file [%default]') -parser.set_defaults(output = []) -parser.set_defaults(size = 1.0) -parser.set_defaults(port = 40007) -parser.set_defaults(xmargin = 0.0) -parser.set_defaults(ymargin = 0.0) -parser.set_defaults(resolution = 64) -parser.set_defaults(extrusion = 2) -parser.set_defaults(imgsize = 512) -parser.set_defaults(M = [0.0,1.0,1.0,0.0]) # M_11, M_12, M_21, M_22. x,y in RCB is y,x of Eulers!! -parser.set_defaults(tolerance = 1.0e-3) -parser.set_defaults(scatter = 0.0) -parser.set_defaults(strain = 0.2) -parser.set_defaults(strainrate = 1.0e-3) -parser.set_defaults(increments = 200) -parser.set_defaults(mesh = 'dt_planar_trimesh') -parser.set_defaults(twoD = False) -parser.set_defaults(segmentcolumn = 9) -parser.set_defaults(idcolumn = 13) +parser.set_defaults(output = [], + size = 1.0, + port = 40007, + xmargin = 0.0, + ymargin = 0.0, + resolution = 64, + extrusion = 2, + imgsize = 512, + M = (0.0,1.0,1.0,0.0), # M_11, M_12, M_21, M_22. x,y in RCB is y,x of Eulers!! + tolerance = 1.0e-3, + scatter = 0.0, + strain = 0.2, + strainrate = 1.0e-3, + increments = 200, + mesh = 'dt_planar_trimesh', + twoD = False, + segmentcolumn = 9, + idcolumn = 13) (options, args) = parser.parse_args()