added (?correct and working?) rotation for conversion from ANG and updated bold verbosity of all other scripts

This commit is contained in:
Martin Diehl 2013-07-18 13:28:54 +00:00
parent d05f1085a8
commit 2201a73a46
12 changed files with 101 additions and 43 deletions

View File

@ -4,6 +4,9 @@
import string,os,sys
from optparse import OptionParser, Option
scriptID = '$Id$'
scriptName = scriptID.split()[1]
#-------------------------------------------------------------------------------------------------
class extendableOption(Option):
#-------------------------------------------------------------------------------------------------
@ -28,8 +31,7 @@ class extendableOption(Option):
#--------------------------------------------------------------------------------------------------
parser = OptionParser(option_class=extendableOption, usage='%prog options [file[s]]', description = """
Converts ang files (EBSD Data) from hexagonal grid to a pixel grid
""" + string.replace('$Id$','\n','\\n')
""" + string.replace(scriptID,'\n','\\n')
)
parser.add_option('-x', dest='columnX', action='store', type='int', \
@ -46,16 +48,25 @@ addPoints = -1
#--- setup file handles ---------------------------------------------------------------------------
files = []
if filenames == []:
files.append({'name':'STDIN', 'input':sys.stdin, 'output':sys.stdout})
if filenames == []:
files.append({'name':'STDIN',
'input':sys.stdin,
'output':sys.stdout,
'croak':sys.stderr,
})
else:
for name in filenames:
if os.path.exists(name):
files.append( {'name':name, 'input':open(name),'output':open(os.path.splitext(name)[0]\
+'_cub'+os.path.splitext(name)[1], 'w')})
files.append({'name':name,
'input':open(name),
'output':open(os.path.splitext(name)[0]+'_cub'+os.path.splitext(name)[1], 'w'),
'croak':sys.stdout,
})
#--- loop over input files ------------------------------------------------------------------------
for file in files:
print file['name']
if file['name'] != 'STDIN': file['croak'].write('\033[1m'+scriptName+'\033[0m: '+file['name']+'\n')
else: file['croak'].write('\033[1m'+scriptName+'\033[0m\n')
x = 0
for line in file['input']:
lineSplit=line.split()
@ -63,7 +74,7 @@ for file in files:
if lineSplit[0]=='#':
if len(lineSplit)>2: # possibly interesting information
if line.split()[2]=='SqrGrid':
print 'The file is already a square grid file.'
file['croak'].write('The file is already a square grid file.')
sys.exit()
if lineSplit[1]=='XSTEP:': stepSizeX = float(lineSplit[2])
if lineSplit[1]=='YSTEP:': stepSizeY = float(lineSplit[2])

View File

@ -2,7 +2,10 @@
# -*- coding: UTF-8 no BOM -*-
import os,sys,math,string,numpy
from optparse import OptionParser, Option
from optparse import OptionParser, OptionGroup, Option, SUPPRESS_HELP
scriptID = '$Id$'
scriptName = scriptID.split()[1]
#--------------------------------------------------------------------------------------------------
class extendableOption(Option):
@ -29,22 +32,25 @@ class extendableOption(Option):
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.
Two phases can be discriminated based on threshold value in a given data column.
""" + string.replace('$Id$','\n','\\n')
""" + string.replace(scriptID,'\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]')
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]')
parser.add_option('--homogenization', dest='homogenization', type='int', \
parser.add_option('--homogenization', dest='homogenization', type='int', \
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')
parser.add_option('--crystallite', dest='crystallite', type='int', \
parser.add_option('--crystallite', dest='crystallite', type='int', \
help='crystallite index to be used [%default]')
parser.add_option('-c', '--configuration', dest='config', action='store_true', \
help='output material configuration [%default]')
parser.add_option('-a', '--axis', dest='axis', type='string', nargs = 3, \
help='axis assignement of eulerangles x,y,z = %default')
parser.set_defaults(column = 11)
parser.set_defaults(threshold = 0.5)
@ -52,9 +58,14 @@ parser.set_defaults(homogenization = 1)
parser.set_defaults(phase = [1,2])
parser.set_defaults(crystallite = 1)
parser.set_defaults(config = False)
parser.set_defaults(axis = ['y','x','-z'])
(options,filenames) = parser.parse_args()
for i in options.axis:
if i.lower() not in ['x','+x','-x','y','+y','-y','z','+z','-z']:
file['croak'].write('invalid axis %s %s %s' %(options.axis[0],options.axis[1],options.axis[2]))
sys.exit()
#--- setup file handles ---------------------------------------------------------------------------
files = []
if filenames == []:
@ -75,7 +86,8 @@ else:
#--- loop over input files ------------------------------------------------------------------------
for file in files:
if file['name'] != 'STDIN': file['croak'].write(file['name']+'\n')
if file['name'] != 'STDIN': file['croak'].write('\033[1m'+scriptName+'\033[0m: '+file['name']+'\n')
else: file['croak'].write('\033[1m'+scriptName+'\033[0m\n')
info = {
'grid': numpy.ones (3,'i'),
@ -111,6 +123,7 @@ for file in files:
'(constituent)\tphase %i\ttexture %s\tfraction 1.0\n'%(options.phase[{True:0,False:1}[float(words[options.column-1])<options.threshold]],me)
]
texture += ['[Grain%s]\n'%me + \
'rotation %s %s %s'%(options.axis[0],options.axis[1],options.axis[2]) +\
'(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: # only info from header needed
@ -138,7 +151,7 @@ for file in files:
file['output'].write('\n'.join(microstructure) + \
'\n'.join(texture))
else:
header = ['$Id$\n']
header = [scriptID+'\n']
header.append("grid\ta %i\tb %i\tc %i\n"%(info['grid'][0],info['grid'][1],info['grid'][2],))
header.append("size\tx %f\ty %f\tz %f\n"%(info['size'][0],info['size'][1],info['size'][2],))
header.append("origin\tx %f\ty %f\tz %f\n"%(info['origin'][0],info['origin'][1],info['origin'][2],))

View File

@ -3,7 +3,10 @@
import os,re,sys,math,numpy,string,damask
from scipy import ndimage
from optparse import OptionParser, Option
from optparse import OptionParser, OptionGroup, Option, SUPPRESS_HELP
scriptID = '$Id$'
scriptName = scriptID.split()[1]
#--------------------------------------------------------------------------------------------------
class extendableOption(Option):
@ -111,8 +114,7 @@ neighborhoods = {
parser = OptionParser(option_class=extendableOption, usage='%prog options [file[s]]', description = """
Produce geom files containing Euclidean distance to grain structural features:
boundaries, triple lines, and quadruple points.
""" + string.replace('$Id$','\n','\\n')
""" + string.replace(scriptID,'\n','\\n')
)
parser.add_option('-t','--type', dest='type', action='extend', type='string', \
@ -157,7 +159,8 @@ else:
#--- loop over input files ------------------------------------------------------------------------
for file in files:
if file['name'] != 'STDIN': file['croak'].write(file['name']+'\n')
if file['name'] != 'STDIN': file['croak'].write('\033[1m'+scriptName+'\033[0m: '+file['name']+'\n')
else: file['croak'].write('\033[1m'+scriptName+'\033[0m\n')
firstline = file['input'].readline()
m = re.search('(\d+)\s*head', firstline.lower())
@ -180,7 +183,7 @@ for file in files:
'homogenization': 0
}
newInfo = {
'microstructures': 0,
'microstructures': 0,
}
new_header = []
@ -211,7 +214,7 @@ for file in files:
file['croak'].write('invalid size x y z.\n')
sys.exit()
new_header.append('$Id$\n')
new_header.append(scriptID+'\n')
new_header.append("grid\ta %i\tb %i\tc %i\n"%(info['grid'][0],info['grid'][1],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],))

View File

@ -4,6 +4,9 @@
import os,sys,string,math,numpy,time
from optparse import OptionParser, OptionGroup, Option, SUPPRESS_HELP
scriptID = '$Id$'
scriptName = scriptID.split()[1]
#------------------------------------------------------------------------------------------------
class extendedOption(Option):
#------------------------------------------------------------------------------------------------
@ -30,7 +33,7 @@ parser = OptionParser(option_class=extendedOption, usage='%prog', description =
Generate a geometry file of an osteon enclosing the Harvesian canal and separated by interstitial tissue.
The osteon phase is lamellar with a twisted plywood structure.
Its fiber orientation is oscillating by +/- amplitude within one period.
""" + string.replace('$Id$','\n','\\n')
""" + string.replace(scriptID,'\n','\\n')
)
parser.add_option('-g', '--grid', dest='grid', type='int', nargs=2, \
@ -131,7 +134,8 @@ for y in xrange(info['grid'][1]):
alphaOfGrain[info['microstructures']] = alpha[y,x]
betaOfGrain[ info['microstructures']] = beta[y,x]
info['microstructures'] += 1
#--- report ---------------------------------------------------------------------------------------
else: file['croak'].write('\033[1m'+scriptName+'\033[0m\n')
file['croak'].write('grid a b c: %s\n'%(' x '.join(map(str,info['grid']))) + \
'size x y z: %s\n'%(' x '.join(map(str,info['size']))) + \
'origin x y z: %s\n'%(' : '.join(map(str,info['origin']))) + \
@ -171,7 +175,7 @@ if options.config:
betaOfGrain[i]))
else:
header = ['$Id$\n']
header = [scriptID+'\n']
header.append("grid\ta %i\tb %i\tc %i\n"%(info['grid'][0],info['grid'][1],info['grid'][2],))
header.append("size\tx %f\ty %f\tz %f\n"%(info['size'][0],info['size'][1],info['size'][2],))
header.append("origin\tx %f\ty %f\tz %f\n"%(info['origin'][0],info['origin'][1],info['origin'][2],))

View File

@ -2,7 +2,11 @@
# -*- coding: UTF-8 no BOM -*-
import os,sys,math,string,numpy
from optparse import OptionParser, Option
from optparse import OptionParser, OptionGroup, Option, SUPPRESS_HELP
scriptID = '$Id$'
scriptName = scriptID.split()[1]
#--------------------------------------------------------------------------------------------------
class extendableOption(Option):
@ -128,7 +132,7 @@ for file in files:
file['output'].write('\n'.join(microstructure) + \
'\n'.join(texture))
else:
header = ['$Id$\n']
header = [scriptID+'\n']
header.append("grid\ta %i\tb %i\tc %i\n"%(info['grid'][0],info['grid'][1],info['grid'][2],))
header.append("size\tx %f\ty %f\tz %f\n"%(info['size'][0],info['size'][1],info['size'][2],))
header.append("origin\tx %f\ty %f\tz %f\n"%(info['origin'][0],info['origin'][1],info['origin'][2],))

View File

@ -7,6 +7,9 @@ from optparse import OptionParser, OptionGroup, Option, SUPPRESS_HELP
from scipy import ndimage
from multiprocessing import Pool
scriptID = '$Id$'
scriptName = scriptID.split()[1]
#--------------------------------------------------------------------------------------------------
class extendedOption(Option):
#--------------------------------------------------------------------------------------------------
@ -129,7 +132,7 @@ Smoothens out interface roughness by simulated curvature flow.
This is achieved by the diffusion of each initially sharply bounded grain volume within the periodic domain
up to a given distance 'd' voxels.
The final geometry is assembled by selecting at each voxel that grain index for which the concentration remains largest.
""" + string.replace('$Id$','\n','\\n')
""" + string.replace(scriptID,'\n','\\n')
)
parser.add_option('-d', '--distance', dest='d', type='int', \
@ -169,7 +172,8 @@ else:
#--- loop over input files ------------------------------------------------------------------------
for file in files:
if file['name'] != 'STDIN': file['croak'].write(file['name']+'\n')
if file['name'] != 'STDIN': file['croak'].write('\033[1m'+scriptName+'\033[0m: '+file['name']+'\n')
else: file['croak'].write('\033[1m'+scriptName+'\033[0m\n')
theTable = damask.ASCIItable(file['input'],file['output'],labels=False)
theTable.head_read()
@ -271,7 +275,7 @@ for file in files:
theTable.labels_clear()
theTable.info_clear()
theTable.info_append(extra_header+[
"$Id$",
scriptID,
"grid\ta %i\tb %i\tc %i"%(info['grid'][0],info['grid'][1],info['grid'][2],),
"size\tx %f\ty %f\tz %f"%(info['size'][0],info['size'][1],info['size'][2],),
"origin\tx %f\ty %f\tz %f"%(info['origin'][0],info['origin'][1],info['origin'][2],),

View File

@ -4,6 +4,9 @@
import os,sys,string,re,math,numpy
from optparse import OptionParser, OptionGroup, Option, SUPPRESS_HELP
scriptID = '$Id$'
scriptName = scriptID.split()[1]
#--------------------------------------------------------------------------------------------------
class extendedOption(Option):
#--------------------------------------------------------------------------------------------------
@ -42,7 +45,7 @@ mappings = {
parser = OptionParser(option_class=extendedOption, usage='%prog options [file[s]]', description = """
Offset microstructure index for points which see a microstructure different from themselves within a given (cubic) vicinity,
i.e. within the region close to a grain/phase boundary.
""" + string.replace('$Id$','\n','\\n')
""" + string.replace(scriptID,'\n','\\n')
)
parser.add_option('-v', '--vicinity', dest='vicinity', type='int', \
@ -78,7 +81,8 @@ else:
#--- loop over input files ------------------------------------------------------------------------
for file in files:
if file['name'] != 'STDIN': file['croak'].write(file['name']+'\n')
if file['name'] != 'STDIN': file['croak'].write('\033[1m'+scriptName+'\033[0m: '+file['name']+'\n')
else: file['croak'].write('\033[1m'+scriptName+'\033[0m\n')
firstline = file['input'].readline()
m = re.search('(\d+)\s*head', firstline.lower())
@ -105,7 +109,7 @@ for file in files:
}
new_header = []
new_header.append('$Id$\n')
new_header.append(scriptID+'\n')
for header in headers:
headitems = map(str.lower,header.split())
if headitems[0] == 'resolution': headitems[0] = 'grid'

View File

@ -10,6 +10,9 @@ that are written during the first run of the model.
import sys,os,re
from optparse import OptionParser
scriptID = '$Id$'
scriptName = scriptID.split()[1]
# -----------------------------
def ParseOutputFormat(filename,what,me):
# -----------------------------
@ -98,6 +101,7 @@ me = { 'Homogenization': options.homog,
for file in files:
print '\033[1m'+scriptName+'\033[0m: '+file+'\n'
if options.useFile != '':
formatFile = os.path.splitext(options.useFile)[0]
else:

View File

@ -4,6 +4,9 @@
import sys,os,pwd,math,re,string,numpy, damask
from optparse import OptionParser
scriptID = '$Id$'
scriptName = scriptID.split()[1]
sys.path.append(damask.solver.Marc().libraryPath('../../'))
try:
@ -155,8 +158,7 @@ def servoLink():
#--------------------------------------------------------------------------------------------------
parser = OptionParser(usage='%prog [options]', description = """
Set up servo linking to achieve periodic boundary conditions for a regular hexahedral mesh presently opened in MSC.Mentat
""" + string.replace('$Id$','\n','\\n')
""" + string.replace(scriptID,'\n','\\n')
)
parser.add_option("-p", "--port", type="int",\
@ -171,6 +173,7 @@ parser.set_defaults(verbose = False)
(options, args) = parser.parse_args()
outputLocals = {}
print '\033[1m'+scriptName+'\033[0m\n'
print 'waiting to connect...'
py_connect('',options.port)
print 'connected...'

View File

@ -4,6 +4,9 @@
import os, sys, math, re, threading, time, string, damask
from optparse import OptionParser, OptionGroup, Option, SUPPRESS_HELP
scriptID = '$Id$'
scriptName = scriptID.split()[1]
#-------------------------------------------------------------------------------------------------
def outMentat(cmd,locals):
#-------------------------------------------------------------------------------------------------
@ -231,8 +234,7 @@ Generate FE hexahedral mesh from spectral description file.
Acceptable formats are
geom: header plus list of grain numbers or
spectral: phi1,Phi,phi2,x,y,z,id,phase.
""" + string.replace('$Id$','\n','\\n')
""" + string.replace(scriptID,'\n','\\n')
)
parser.add_option("-p", "--port", type="int",\
dest="port",\
@ -243,7 +245,6 @@ parser.add_option("-g", "--geom", action="store_const", const="geom",\
parser.add_option("-s", "--spectral", action="store_const", const="spectral",\
dest="filetype",\
help="file has 'spectral' format (VPSC Lebensohn)")
parser.add_option("--homogenization", type="int",\
dest="homogenization",\
help="homogenization index from material.config (only required for geom file type)")
@ -270,6 +271,7 @@ file = open(args[0])
content = file.readlines()
file.close()
print '\033[1m'+scriptName+'\033[0m\n'
if options.filetype not in ['spectral','geom']:
options.filetype = os.path.splitext(args[0])[1][1:]

View File

@ -4,6 +4,9 @@
import sys,os,math,re,string, damask
from optparse import OptionParser, OptionGroup, Option, SUPPRESS_HELP
scriptID = '$Id$'
scriptName = scriptID.split()[1]
try: # check for Python Image Lib
import Image,ImageDraw
@ -784,8 +787,7 @@ def fftbuild(rcData,height,xframe,yframe,resolution,extrusion): # bui
parser = OptionParser(option_class=extendedOption, usage='%prog [options] datafile[s]', description = """
Produce image, spectral geometry description, and (auto) Mentat procedure from TSL/OIM
reconstructed boundary file
""" + string.replace('$Id$','\n','\\n')
""" + string.replace(scriptID,'\n','\\n')
)
parser.add_option("-o", "--output", action='extend', dest='output', type='string', \
@ -855,6 +857,7 @@ parser.set_defaults(twoD = False)
(options, args) = parser.parse_args()
print '\033[1m'+scriptName+'\033[0m\n'
if not len(args):
parser.error('no boundary file specified')

View File

@ -4,6 +4,9 @@
import os,sys,string,re,math,numpy,random
from optparse import OptionParser, OptionGroup, Option, SUPPRESS_HELP
scriptID = '$Id$'
scriptName = scriptID.split()[1]
#------------------------------------------------------------------------------------------------
class extendedOption(Option):
#------------------------------------------------------------------------------------------------
@ -37,7 +40,7 @@ mappings = {
parser = OptionParser(option_class=extendedOption, usage='%prog [options]', description = """
Distribute given number of points randomly within the three-dimensional cube [0.0,0.0,0.0]--[1.0,1.0,1.0].
Reports positions with random crystal orientations in seeds file format to STDOUT.
""" + string.replace('$Id$','\n','\\n')
""" + string.replace(scriptID,'\n','\\n')
)
parser.add_option('-N', dest='N', type='int', \
@ -78,7 +81,7 @@ seeds[2,:]=(numpy.mod(seedpoint//(options.grid[1]*options.grid[0]),options.grid[
+numpy.random.random())/options.grid[2]
print "5\theader"
print "$Id$"
print scriptID
print "grid\ta %i\tb %i\tc %i"%(options.grid[0],options.grid[1],options.grid[2],)
print "microstructures\t%i"%options.N
print "randomSeed\t%i"%(options.randomSeed)