added ID information of creator script to header
This commit is contained in:
parent
6f0308844f
commit
4314ab236e
|
@ -28,26 +28,26 @@ class extendableOption(Option):
|
||||||
|
|
||||||
parser = OptionParser(option_class=extendableOption, usage='%prog options [file[s]]', description = """
|
parser = OptionParser(option_class=extendableOption, usage='%prog options [file[s]]', description = """
|
||||||
Generate geometry description and material configuration from EBSD data in given square-gridded 'ang' file.
|
Generate geometry description and material configuration from EBSD data in given square-gridded 'ang' file.
|
||||||
Dual phases can be discriminated based on threshold value in a given data column.
|
Two phases can be discriminated based on threshold value in a given data column.
|
||||||
""" + string.replace('$Id$','\n','\\n')
|
""" + string.replace('$Id$','\n','\\n')
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
parser.add_option('--column', dest='column', type='int', \
|
parser.add_option('--column', dest='column', type='int', \
|
||||||
help='data column to discriminate phase 1 from 2 [%default]')
|
help='data column to discriminate phase 1 from 2 [%default]')
|
||||||
parser.add_option('-t','--threshold', dest='threshold', type='float', \
|
parser.add_option('-t','--threshold', dest='threshold', type='float', \
|
||||||
help='threshold value to discriminate phase 1 from 2 [%default]')
|
help='threshold value to discriminate phase 1 from 2 [%default]')
|
||||||
parser.add_option('--homogenization', dest='homogenization', type='int', \
|
parser.add_option('--homogenization', dest='homogenization', type='int', \
|
||||||
help='homogenization index to be used [%default]')
|
help='homogenization index to be used [%default]')
|
||||||
parser.add_option('--phase', dest='phase', type='int', nargs = 2, \
|
parser.add_option('--phase', dest='phase', type='int', nargs = 2, \
|
||||||
help='two phase indices to be used %default')
|
help='phase indices to be used %default')
|
||||||
parser.add_option('--crystallite', dest='crystallite', type='int', \
|
parser.add_option('--crystallite', dest='crystallite', type='int', \
|
||||||
help='crystallite index to be used [%default]')
|
help='crystallite index to be used [%default]')
|
||||||
parser.add_option('-c', '--configuration', dest='config', action='store_true', \
|
parser.add_option('-c', '--configuration', dest='config', action='store_true', \
|
||||||
help='output material configuration [%default]')
|
help='output material configuration [%default]')
|
||||||
|
|
||||||
parser.set_defaults(column = 1)
|
parser.set_defaults(column = 11)
|
||||||
parser.set_defaults(threshold = 0.0)
|
parser.set_defaults(threshold = 0.5)
|
||||||
parser.set_defaults(homogenization = 1)
|
parser.set_defaults(homogenization = 1)
|
||||||
parser.set_defaults(phase = [1,2])
|
parser.set_defaults(phase = [1,2])
|
||||||
parser.set_defaults(crystallite = 1)
|
parser.set_defaults(crystallite = 1)
|
||||||
|
@ -81,7 +81,7 @@ for file in files:
|
||||||
|
|
||||||
point = 0
|
point = 0
|
||||||
step = [0,0]
|
step = [0,0]
|
||||||
resolution = [1,1]
|
grid = [1,1]
|
||||||
microstructure = ['<microstructure>']
|
microstructure = ['<microstructure>']
|
||||||
texture = ['<texture>']
|
texture = ['<texture>']
|
||||||
|
|
||||||
|
@ -89,11 +89,14 @@ for file in files:
|
||||||
words = line.split()
|
words = line.split()
|
||||||
if words[0] == '#': # process initial comments block
|
if words[0] == '#': # process initial comments block
|
||||||
if len(words) > 2:
|
if len(words) > 2:
|
||||||
if words[1] == 'HexGrid': file['croak'].write('The file has HexGrid format. Please first convert to SquareGrid...\n'); break
|
if words[1] == 'HexGrid':
|
||||||
if words[1] == 'XSTEP:': step[0] = float(words[2])
|
file['croak'].write('The file has HexGrid format. Please first convert to SquareGrid...\n'); break
|
||||||
if words[1] == 'YSTEP:': step[1] = float(words[2])
|
if words[1] == 'XSTEP:': step[0] = float(words[2])
|
||||||
if words[1] == 'NCOLS_ODD:': resolution[0] = int(words[2]); formatwidth = 1+int(math.log10(resolution[0]*resolution[1]))
|
if words[1] == 'YSTEP:': step[1] = float(words[2])
|
||||||
if words[1] == 'NROWS:': resolution[1] = int(words[2]); formatwidth = 1+int(math.log10(resolution[0]*resolution[1]))
|
if words[1] == 'NCOLS_ODD:':
|
||||||
|
grid[0] = int(words[2]); formatwidth = 1+int(math.log10(grid[0]*grid[1]))
|
||||||
|
if words[1] == 'NROWS:':
|
||||||
|
grid[1] = int(words[2]); formatwidth = 1+int(math.log10(grid[0]*grid[1]))
|
||||||
else: # finished with comments block
|
else: # finished with comments block
|
||||||
if options.config: # write configuration (line by line)
|
if options.config: # write configuration (line by line)
|
||||||
point += 1
|
point += 1
|
||||||
|
@ -106,13 +109,21 @@ for file in files:
|
||||||
'(gauss)\tphi1 %4.2f\tPhi %4.2f\tphi2 %4.2f\tscatter 0.0\tfraction 1.0\n'%tuple(map(lambda x: float(x)*180.0/math.pi, words[:3]))
|
'(gauss)\tphi1 %4.2f\tPhi %4.2f\tphi2 %4.2f\tscatter 0.0\tfraction 1.0\n'%tuple(map(lambda x: float(x)*180.0/math.pi, words[:3]))
|
||||||
]
|
]
|
||||||
else:
|
else:
|
||||||
file['output'].write("4 header\n" + \
|
grid.append(1)
|
||||||
"resolution\ta %i\tb %i\tc 1\n"%(resolution[0],resolution[1]) + \
|
file['output'].write("6 header\n" + \
|
||||||
"dimension\tx %g\ty %g\tz %g\n"%(step[0]*resolution[0],step[1]*resolution[1],min(step)) + \
|
"$Id$ \n"
|
||||||
|
"grid\ta %i\tb %i\tc 1\n"%(grid[0],grid[1]) + \
|
||||||
|
"size\tx %g\ty %g\tz %g\n"%(step[0]*grid[0],step[1]*grid[1],min(step)) + \
|
||||||
"origin\tx 0\ty 0\tz 0\n" + \
|
"origin\tx 0\ty 0\tz 0\n" + \
|
||||||
|
"microstructures\t%i\n"%(grid[0]*grid[1]) + \
|
||||||
"homogenization %i\n"%options.homogenization + \
|
"homogenization %i\n"%options.homogenization + \
|
||||||
"1 to %i\n"%(resolution[0]*resolution[1]))
|
"1 to %i\n"%(grid[0]*grid[1]))
|
||||||
break
|
break
|
||||||
|
file['croak'].write('grid a b c: %s\n'%(' x '.join(map(str,grid))) + \
|
||||||
|
'size x y z: %s\n'%(' x '.join(map(str,[step[0]*grid[0],step[1]*grid[1],min(step)]))) + \
|
||||||
|
'origin x y z: %s\n'%(' : '.join(map(str,[0.0,0.0,0.0]))) + \
|
||||||
|
'microstructures: %i\n'%(grid[0]*grid[1]) + \
|
||||||
|
'homogenization: %i\n'%options.homogenization)
|
||||||
|
|
||||||
if options.config:
|
if options.config:
|
||||||
file['output'].write('\n'.join(microstructure) + \
|
file['output'].write('\n'.join(microstructure) + \
|
||||||
|
|
|
@ -200,21 +200,13 @@ for file in files:
|
||||||
if i+1 not in indices: missing += 1
|
if i+1 not in indices: missing += 1
|
||||||
file['croak'].write({True:'all',False:'only'}[missing == 0] + ' %i grains mapped.\n'%(info['grains']-missing))
|
file['croak'].write({True:'all',False:'only'}[missing == 0] + ' %i grains mapped.\n'%(info['grains']-missing))
|
||||||
|
|
||||||
|
new_header.append("$Id$ \n")
|
||||||
new_header.append("grid\ta %i\tb %i\tc %i\n"%(
|
new_header.append("grid\ta %i\tb %i\tc %i\n"%(info['grid'][0],info['grid'][1],info['grid'][2],))
|
||||||
info['grid'][0],
|
new_header.append("size\tx %f\ty %f\tz %f\n"%(info['size'][0],info['size'][1],info['size'][2],))
|
||||||
info['grid'][1],
|
new_header.append("origin\tx %f\ty %f\tz %f\n"%(info['origin'][0],info['origin'][1],info['origin'][2],))
|
||||||
info['grid'][2],))
|
|
||||||
new_header.append("size\tx %f\ty %f\tz %f\n"%(
|
|
||||||
info['size'][0],
|
|
||||||
info['size'][1],
|
|
||||||
info['size'][2],))
|
|
||||||
new_header.append("origin\tx %f\ty %f\tz %f\n"%(
|
|
||||||
info['origin'][0],
|
|
||||||
info['origin'][1],
|
|
||||||
info['origin'][2],))
|
|
||||||
new_header.append("microstructures\t%i\n"%(info['grains']-missing))
|
new_header.append("microstructures\t%i\n"%(info['grains']-missing))
|
||||||
new_header.append("homogenization\t%i\n"%info['homogenization'])
|
new_header.append("homogenization\t%i\n"%info['homogenization'])
|
||||||
|
|
||||||
file['output'].write('%i\theader\n'%(len(new_header)) + ''.join(new_header))
|
file['output'].write('%i\theader\n'%(len(new_header)) + ''.join(new_header))
|
||||||
|
|
||||||
for n in xrange(info['grid'][1:3].prod()): # loop over 2nd and 3rd size
|
for n in xrange(info['grid'][1:3].prod()): # loop over 2nd and 3rd size
|
||||||
|
|
|
@ -74,7 +74,8 @@ seeds[1,:]=(numpy.mod(seedpoint// options.grid[0],options.grid[
|
||||||
seeds[2,:]=(numpy.mod(seedpoint//(options.grid[1]*options.grid[0]),options.grid[2])\
|
seeds[2,:]=(numpy.mod(seedpoint//(options.grid[1]*options.grid[0]),options.grid[2])\
|
||||||
+numpy.random.random())/options.grid[2]
|
+numpy.random.random())/options.grid[2]
|
||||||
|
|
||||||
print "4\theader"
|
print "5\theader"
|
||||||
|
print "$Id$ \n"
|
||||||
print "grid\ta %i\tb %i\tc %i"%(options.grid[0],options.grid[1],options.grid[2],)
|
print "grid\ta %i\tb %i\tc %i"%(options.grid[0],options.grid[1],options.grid[2],)
|
||||||
print "grains\t%i"%options.N
|
print "grains\t%i"%options.N
|
||||||
print "randomSeed\t%i"%(options.randomSeed)
|
print "randomSeed\t%i"%(options.randomSeed)
|
||||||
|
|
Loading…
Reference in New Issue