updated help

This commit is contained in:
Philip Eisenlohr 2016-04-24 10:14:16 -05:00
parent 9e5a8d2391
commit f42c316aa2
1 changed files with 40 additions and 37 deletions

View File

@ -34,64 +34,71 @@ Reports positions with random crystal orientations in seeds file format to STDOU
""", version = scriptID)
parser.add_option('-N', dest='N',
parser.add_option('-N',
dest = 'N',
type = 'int', metavar = 'int',
help = 'number of seed points to distribute [%default]')
parser.add_option('-g','--grid',
help = 'number of seed points [%default]')
parser.add_option('-g',
'--grid',
dest = 'grid',
type = 'int', nargs = 3, metavar = 'int int int',
help='min a,b,c grid of hexahedral box %default')
parser.add_option('-m', '--microstructure',
parser.add_option('-m',
'--microstructure',
dest = 'microstructure',
type = 'int', metavar='int',
type = 'int', metavar = 'int',
help = 'first microstructure index [%default]')
parser.add_option('-r', '--rnd',
parser.add_option('-r',
'--rnd',
dest = 'randomSeed', type = 'int', metavar = 'int',
help = 'seed of random number generator [%default]')
parser.add_option('--format',
dest = 'format', type = 'string', metavar = 'string',
help = 'number format of output [auto]')
help = 'output number format [auto]')
group = OptionGroup(parser, "Laguerre Tessellation",
"Parameters determining shape of weight distribution of seed points"
)
group.add_option('-w', '--weights',
group.add_option( '-w',
'--weights',
action = 'store_true',
dest = 'weights',
help = 'assign random weigts to seed points for Laguerre tessellation [%default]')
group.add_option('--max',
help = 'assign random weights to seed points for Laguerre tessellation [%default]')
group.add_option( '--max',
dest = 'max',
type = 'float', metavar = 'float',
help = 'max of uniform distribution for weights [%default]')
group.add_option('--mean',
group.add_option( '--mean',
dest = 'mean',
type = 'float', metavar = 'float',
help = 'mean of normal distribution for weights [%default]')
group.add_option('--sigma',
dest = 'sigma',
type = 'float', metavar = 'float',
help='standard deviation of normal distribution for weights [%default]')
group.add_option( '--sigma',
dest = 'sigma',
type = 'float', metavar = 'float',
help='standard deviation of normal distribution for weights [%default]')
parser.add_option_group(group)
group = OptionGroup(parser, "Selective Seeding",
"More uniform distribution of seed points using Mitchell's Best Candidate Algorithm"
)
group.add_option('-s','--selective',
group.add_option( '-s',
'--selective',
action = 'store_true',
dest = 'selective',
help = 'selective picking of seed points from random seed points [%default]')
group.add_option('-f','--force',
group.add_option( '-f',
'--force',
action = 'store_true',
dest = 'force',
help = 'try selective picking despite large seed point number [%default]')
group.add_option('--distance',
dest = 'distance',
type = 'float', metavar = 'float',
help = 'minimum distance to the next neighbor [%default]')
group.add_option('--numCandidates',
dest = 'numCandidates',
type = 'int', metavar = 'int',
help = 'size of point group to select best distance from [%default]')
group.add_option( '--distance',
dest = 'distance',
type = 'float', metavar = 'float',
help = 'minimum distance to next neighbor [%default]')
group.add_option( '--numCandidates',
dest = 'numCandidates',
type = 'int', metavar = 'int',
help = 'size of point group to select best distance from [%default]')
parser.add_option_group(group)
parser.set_defaults(randomSeed = None,
@ -124,11 +131,9 @@ random.seed(options.randomSeed)
if filenames == []: filenames = [None]
for name in filenames:
try:
table = damask.ASCIItable(outname = name,
buffered = False)
except:
continue
try: table = damask.ASCIItable(outname = name,
buffered = False)
except: continue
damask.util.report(scriptName,name)
# --- sanity checks -------------------------------------------------------------------------
@ -136,7 +141,7 @@ for name in filenames:
remarks = []
errors = []
if gridSize == 0:
errors.append('zero grid dimension for %s.'%(', '.join([['a','b','c'][x] for x in np.where(options.grid == 0)[0]])))
errors.append('zero grid dimension for {}.'.format(', '.join([['a','b','c'][x] for x in np.where(options.grid == 0)[0]])))
if options.N > gridSize/10.: errors.append('seed count exceeds 0.1 of grid points.')
if options.selective and 4./3.*math.pi*(options.distance/2.)**3*options.N > 0.5:
(remarks if options.force else errors).append('maximum recommended seed point count for given distance is {}.{}'.
@ -186,10 +191,8 @@ for name in filenames:
seeds = seeds.T # prepare shape for stacking
if options.weights:
if options.max > 0.0:
weights = [np.random.uniform(low = 0, high = options.max, size = options.N)]
else:
weights = [np.random.normal(loc = options.mean, scale = options.sigma, size = options.N)]
weights = [np.random.uniform(low = 0, high = options.max, size = options.N)] if options.max > 0.0 \
else [np.random.normal(loc = options.mean, scale = options.sigma, size = options.N)]
else:
weights = []
seeds = np.transpose(np.vstack(tuple([seeds,
@ -204,13 +207,13 @@ for name in filenames:
table.info_clear()
table.info_append([
scriptID + ' ' + ' '.join(sys.argv[1:]),
"grid\ta {grid[0]}\tb {grid[1]}\tc {grid[2]}".format(grid=options.grid),
"grid\ta {}\tb {}\tc {}".format(*options.grid),
"microstructures\t{}".format(options.N),
"randomSeed\t{}".format(options.randomSeed),
])
table.labels_clear()
table.labels_append( ['{dim}_{label}'.format(dim = 1+k,label = 'pos') for k in xrange(3)] +
['{dim}_{label}'.format(dim = 1+k,label = 'eulerangles') for k in xrange(3)] +
['{dim}_{label}'.format(dim = 1+k,label = 'euler') for k in xrange(3)] +
['microstructure'] +
(['weight'] if options.weights else []))
table.head_write()