added missing string import in marc_addUserOutput (introduced with rev 3718) and removed unwanted imports and introduce use of damask.extendableParser in some other scripts
This commit is contained in:
parent
f5b4bbe32a
commit
b656113b11
|
@ -2,37 +2,19 @@
|
|||
# -*- coding: UTF-8 no BOM -*-
|
||||
|
||||
import string,os,sys
|
||||
from optparse import OptionParser, Option
|
||||
from optparse import OptionParser
|
||||
import damask
|
||||
|
||||
scriptID = string.replace('$Id$','\n','\\n')
|
||||
scriptName = scriptID.split()[1][:-3]
|
||||
|
||||
#-------------------------------------------------------------------------------------------------
|
||||
class extendableOption(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)
|
||||
|
||||
|
||||
#--------------------------------------------------------------------------------------------------
|
||||
# MAIN
|
||||
#--------------------------------------------------------------------------------------------------
|
||||
parser = OptionParser(option_class=extendableOption, usage='%prog options [file[s]]', description = """
|
||||
parser = OptionParser(option_class=damask.extendableOption, usage='%prog options [file[s]]', description = """
|
||||
Converts ang files (EBSD Data) from hexagonal grid to a pixel grid
|
||||
""" + string.replace(scriptID,'\n','\\n')
|
||||
)
|
||||
|
||||
""", version = scriptID)
|
||||
|
||||
parser.add_option('-x', dest='columnX', type='int', metavar='int', \
|
||||
help='column containing x coordinates [%default]')
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: UTF-8 no BOM -*-
|
||||
|
||||
import os,sys,string,re,math,random
|
||||
import os,sys,string,math
|
||||
import numpy as np
|
||||
from optparse import OptionParser
|
||||
import damask
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: UTF-8 no BOM -*-
|
||||
|
||||
import os,sys,string,re,math
|
||||
import os,sys,string,math
|
||||
import numpy as np
|
||||
from optparse import OptionParser
|
||||
import damask
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: UTF-8 no BOM -*-
|
||||
|
||||
import os,sys,string,re,math,itertools
|
||||
import os,sys,string,math
|
||||
import numpy as np
|
||||
from optparse import OptionParser
|
||||
from scipy import ndimage
|
||||
from multiprocessing import Pool
|
||||
import damask
|
||||
|
||||
scriptID = string.replace('$Id$','\n','\\n')
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: UTF-8 no BOM -*-
|
||||
|
||||
import os,sys,string,re,math
|
||||
import os,sys,string,math
|
||||
import numpy as np
|
||||
from optparse import OptionParser
|
||||
import damask
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: UTF-8 no BOM -*-
|
||||
|
||||
import os,sys,string,re,math
|
||||
import os,sys,string,math
|
||||
import numpy as np
|
||||
from optparse import OptionParser
|
||||
import damask
|
||||
|
|
|
@ -1,33 +1,15 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: UTF-8 no BOM -*-
|
||||
|
||||
import os,sys,string,re,vtk
|
||||
import os,sys,string,vtk
|
||||
import numpy as np
|
||||
from optparse import OptionParser, OptionGroup, Option, SUPPRESS_HELP
|
||||
from optparse import OptionParser
|
||||
import damask
|
||||
|
||||
scriptID = string.replace('$Id$','\n','\\n')
|
||||
scriptName = scriptID.split()[1][:-3]
|
||||
|
||||
#--------------------------------------------------------------------------------------------------
|
||||
class extendedOption(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)
|
||||
|
||||
|
||||
#--------------------------------------------------------------------------------------------------
|
||||
# MAIN
|
||||
#--------------------------------------------------------------------------------------------------
|
||||
|
@ -48,11 +30,10 @@ mappings = {
|
|||
'microstructures': lambda x: int(x),
|
||||
}
|
||||
|
||||
parser = OptionParser(option_class=extendedOption, usage='%prog [geomfile[s]]', description = """
|
||||
parser = OptionParser(option_class=damask.extendableOption, usage='%prog [geomfile[s]]', description = """
|
||||
Produce ASCIItable of structure data from geom description
|
||||
|
||||
""" + string.replace(scriptID,'\n','\\n')
|
||||
)
|
||||
""", version = scriptID)
|
||||
|
||||
(options, filenames) = parser.parse_args()
|
||||
|
||||
|
|
|
@ -1,31 +1,14 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: UTF-8 no BOM -*-
|
||||
|
||||
import os,sys,string,re,math,numpy
|
||||
import os,sys,string,math
|
||||
import numpy as np
|
||||
import damask
|
||||
from optparse import OptionParser, OptionGroup, Option, SUPPRESS_HELP
|
||||
from optparse import OptionParser
|
||||
|
||||
scriptID = string.replace('$Id$','\n','\\n')
|
||||
scriptName = scriptID.split()[1][:-3]
|
||||
|
||||
#--------------------------------------------------------------------------------------------------
|
||||
class extendedOption(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)
|
||||
|
||||
#--------------------------------------------------------------------------------------------------
|
||||
# MAIN
|
||||
#--------------------------------------------------------------------------------------------------
|
||||
|
@ -46,10 +29,10 @@ mappings = {
|
|||
'microstructures': lambda x: int(x),
|
||||
}
|
||||
|
||||
parser = OptionParser(option_class=extendedOption, usage='%prog options [file[s]]', description = """
|
||||
parser = OptionParser(option_class=damask.extendableOption, usage='%prog options [file[s]]', description = """
|
||||
translate microstructure indices (shift or substitute) and/or geometry origin.
|
||||
""" + string.replace(scriptID,'\n','\\n')
|
||||
)
|
||||
|
||||
""", version=scriptID)
|
||||
|
||||
parser.add_option('-o', '--origin', dest='origin', type='float', nargs = 3, \
|
||||
help='offset from old to new origin of grid', metavar='float float float')
|
||||
|
@ -96,14 +79,14 @@ for file in files:
|
|||
|
||||
#--- interpret header ----------------------------------------------------------------------------
|
||||
info = {
|
||||
'grid': numpy.zeros(3,'i'),
|
||||
'size': numpy.zeros(3,'d'),
|
||||
'origin': numpy.zeros(3,'d'),
|
||||
'grid': np.zeros(3,'i'),
|
||||
'size': np.zeros(3,'d'),
|
||||
'origin': np.zeros(3,'d'),
|
||||
'homogenization': 0,
|
||||
'microstructures': 0,
|
||||
}
|
||||
newInfo = {
|
||||
'origin': numpy.zeros(3,'d'),
|
||||
'origin': np.zeros(3,'d'),
|
||||
'microstructures': 0,
|
||||
}
|
||||
extra_header = []
|
||||
|
@ -129,15 +112,15 @@ for file in files:
|
|||
'homogenization: %i\n'%info['homogenization'] + \
|
||||
'microstructures: %i\n'%info['microstructures'])
|
||||
|
||||
if numpy.any(info['grid'] < 1):
|
||||
if np.any(info['grid'] < 1):
|
||||
file['croak'].write('invalid grid a b c.\n')
|
||||
continue
|
||||
if numpy.any(info['size'] <= 0.0):
|
||||
if np.any(info['size'] <= 0.0):
|
||||
file['croak'].write('invalid size x y z.\n')
|
||||
continue
|
||||
|
||||
#--- read data ------------------------------------------------------------------------------------
|
||||
microstructure = numpy.zeros(info['grid'].prod(),'i')
|
||||
microstructure = np.zeros(info['grid'].prod(),'i')
|
||||
i = 0
|
||||
theTable.data_rewind()
|
||||
while theTable.data_read():
|
||||
|
@ -153,7 +136,7 @@ for file in files:
|
|||
i += s
|
||||
|
||||
#--- do work ------------------------------------------------------------------------------------
|
||||
substituted = numpy.copy(microstructure)
|
||||
substituted = np.copy(microstructure)
|
||||
for k, v in sub.iteritems(): substituted[microstructure==k] = v # substitute microstructure indices
|
||||
|
||||
substituted += options.microstructure # shift microstructure indices
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: UTF-8 no BOM -*-
|
||||
|
||||
import os,sys,string,re,math
|
||||
import os,sys,string,math
|
||||
import numpy as np
|
||||
from optparse import OptionParser
|
||||
import damask
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: UTF-8 no BOM -*-
|
||||
|
||||
import os,sys,string,re,math,numpy, damask
|
||||
import os,sys,string,math
|
||||
import numpy as np
|
||||
from scipy import ndimage
|
||||
from optparse import OptionParser, OptionGroup, Option, SUPPRESS_HELP
|
||||
from optparse import OptionParser
|
||||
import damask
|
||||
|
||||
scriptID = string.replace('$Id$','\n','\\n')
|
||||
scriptName = scriptID.split()[1][:-3]
|
||||
|
@ -48,11 +50,11 @@ mappings = {
|
|||
'microstructures': lambda x: int(x),
|
||||
}
|
||||
|
||||
parser = OptionParser(option_class=extendedOption, usage='%prog options [file[s]]', description = """
|
||||
parser = OptionParser(option_class=damask.extendableOption, 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(scriptID,'\n','\\n')
|
||||
)
|
||||
|
||||
""", version = scriptID)
|
||||
|
||||
parser.add_option('-v', '--vicinity', dest='vicinity', type='int', metavar='int', \
|
||||
help='voxel distance checked for presence of other microstructure [%default]')
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: UTF-8 no BOM -*-
|
||||
|
||||
import os,sys,string
|
||||
import damask
|
||||
import re
|
||||
import os,sys,string,re
|
||||
from optparse import OptionParser
|
||||
import damask
|
||||
|
||||
scriptID = string.replace('$Id$','\n','\\n')
|
||||
scriptName = scriptID.split()[1][:-3]
|
||||
|
|
|
@ -7,8 +7,9 @@ based on the files
|
|||
<modelname_jobname>.output<Homogenization/Crystallite/Constitutive>
|
||||
that are written during the first run of the model.
|
||||
'''
|
||||
import sys,os,re
|
||||
import sys,os,re,string
|
||||
from optparse import OptionParser
|
||||
import damask
|
||||
|
||||
scriptID = string.replace('$Id$','\n','\\n')
|
||||
scriptName = scriptID.split()[1][:-3]
|
||||
|
@ -54,8 +55,7 @@ def ParseOutputFormat(filename,what,me):
|
|||
format['outputs'].append([output,length])
|
||||
return format
|
||||
|
||||
|
||||
parser = OptionParser(usage='%prog [options] Marc.inputfile(s)', description="""
|
||||
parser = OptionParser(option_class=damask.extendableOption, usage='%prog [options] Marc.inputfile(s)', description="""
|
||||
Transfer the output variables requested in the material.config to
|
||||
properly labelled user defined variables within the Marc input file (*.dat).
|
||||
|
||||
|
@ -65,7 +65,10 @@ that are written during the first run of the model.
|
|||
|
||||
Specify which user block format you want to apply by stating the homogenization, crystallite, and phase identifiers.
|
||||
Or have an existing set of user variables copied over from another *.dat 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', \
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: UTF-8 no BOM -*-
|
||||
|
||||
import sys,os,pwd,math,re,string,numpy, damask
|
||||
import sys,os,pwd,math,string
|
||||
import numpy as np
|
||||
from optparse import OptionParser
|
||||
import damask
|
||||
|
||||
scriptID = string.replace('$Id$','\n','\\n')
|
||||
scriptName = scriptID.split()[1][:-3]
|
||||
|
@ -54,12 +56,12 @@ def servoLink():
|
|||
|
||||
cmds = []
|
||||
base = ['x','y','z']
|
||||
box = {'min': numpy.zeros(3,dtype='d'),
|
||||
'max': numpy.zeros(3,dtype='d'),
|
||||
'delta': numpy.zeros(3,dtype='d'),
|
||||
box = {'min': np.zeros(3,dtype='d'),
|
||||
'max': np.zeros(3,dtype='d'),
|
||||
'delta': np.zeros(3,dtype='d'),
|
||||
}
|
||||
Nnodes = py_get_int("nnodes()")
|
||||
NodeCoords = numpy.zeros((Nnodes,3),dtype='d')
|
||||
NodeCoords = np.zeros((Nnodes,3),dtype='d')
|
||||
for node in xrange(Nnodes):
|
||||
NodeCoords[node,0] = py_get_float("node_x(%i)"%(node+1))
|
||||
NodeCoords[node,1] = py_get_float("node_y(%i)"%(node+1))
|
||||
|
@ -120,7 +122,7 @@ def servoLink():
|
|||
for dir in xrange(3): # check for each direction
|
||||
if node['faceMember'][dir]: # me on this front face
|
||||
linkCoord[0][dir] = box['min'][dir] # project me onto rear face along dir
|
||||
linkCoord.append(numpy.array(box['min'])) # append base corner
|
||||
linkCoord.append(np.array(box['min'])) # append base corner
|
||||
|
||||
linkCoord[-1][dir] = box['max'][dir] # stretch it to corresponding control leg of "dir"
|
||||
|
||||
|
@ -156,10 +158,10 @@ def servoLink():
|
|||
#--------------------------------------------------------------------------------------------------
|
||||
# MAIN
|
||||
#--------------------------------------------------------------------------------------------------
|
||||
parser = OptionParser(usage='%prog [options]', description = """
|
||||
parser = OptionParser(option_class=damask.extendableOption, 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(scriptID,'\n','\\n')
|
||||
)
|
||||
|
||||
""", version = scriptID)
|
||||
|
||||
parser.add_option("-p", "--port", type="int",\
|
||||
dest="port",\
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: UTF-8 no BOM -*-
|
||||
|
||||
import os, sys, math, re, threading, time, string
|
||||
import os, sys, string
|
||||
from optparse import OptionParser
|
||||
import damask
|
||||
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: UTF-8 no BOM -*-
|
||||
|
||||
import sys,os,math,re,string, damask
|
||||
from optparse import OptionParser, OptionGroup, Option, SUPPRESS_HELP
|
||||
import sys,os,math,re,string
|
||||
from optparse import OptionParser
|
||||
import damask
|
||||
|
||||
scriptID = string.replace('$Id$','\n','\\n')
|
||||
scriptName = scriptID.split()[1][:-3]
|
||||
|
@ -23,26 +24,6 @@ except:
|
|||
MentatCapability = False
|
||||
|
||||
|
||||
# -----------------------------
|
||||
class extendedOption(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)
|
||||
|
||||
|
||||
|
||||
def outMentat(cmd,locals):
|
||||
if cmd[0:3] == '(!)':
|
||||
exec(cmd[3:])
|
||||
|
@ -800,12 +781,11 @@ def fftbuild(rcData,height,xframe,yframe,resolution,extrusion): # bui
|
|||
|
||||
|
||||
# ----------------------- MAIN -------------------------------
|
||||
|
||||
parser = OptionParser(option_class=extendedOption, usage='%prog [options] datafile[s]', description = """
|
||||
parser = OptionParser(option_class=damask.extendableOption, usage='%prog [options] datafile[s]', description = """
|
||||
Produce image, spectral geometry description, and (auto) Mentat procedure from TSL/OIM
|
||||
reconstructed boundary file
|
||||
""" + string.replace(scriptID,'\n','\\n')
|
||||
)
|
||||
|
||||
""", version = scriptID)
|
||||
|
||||
parser.add_option("-o", "--output", action='extend', dest='output', \
|
||||
help="types of output [image, mentat, procedure, spectral]")
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: UTF-8 no BOM -*-
|
||||
|
||||
import os,sys,string,re,vtk
|
||||
import os,sys,string,vtk
|
||||
import numpy as np
|
||||
import damask
|
||||
from optparse import OptionParser
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: UTF-8 no BOM -*-
|
||||
|
||||
import os,sys,string,re,math,random
|
||||
import os,sys,string,math,random
|
||||
import numpy as np
|
||||
from optparse import OptionParser
|
||||
import damask
|
||||
|
|
Loading…
Reference in New Issue