diff --git a/processing/pre/OIMang_hex2cub.py b/processing/pre/OIMang_hex2cub.py index b7943bd4d..73ad97810 100755 --- a/processing/pre/OIMang_hex2cub.py +++ b/processing/pre/OIMang_hex2cub.py @@ -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]') diff --git a/processing/pre/geom_fromMinimalSurface.py b/processing/pre/geom_fromMinimalSurface.py index 693061c27..f0f8dd6fa 100755 --- a/processing/pre/geom_fromMinimalSurface.py +++ b/processing/pre/geom_fromMinimalSurface.py @@ -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 diff --git a/processing/pre/geom_fromOsteonGeometry.py b/processing/pre/geom_fromOsteonGeometry.py index ae26a4f53..f2a03d299 100755 --- a/processing/pre/geom_fromOsteonGeometry.py +++ b/processing/pre/geom_fromOsteonGeometry.py @@ -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 diff --git a/processing/pre/geom_grainGrowth.py b/processing/pre/geom_grainGrowth.py index 956aa2d4b..af4681fe7 100755 --- a/processing/pre/geom_grainGrowth.py +++ b/processing/pre/geom_grainGrowth.py @@ -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') diff --git a/processing/pre/geom_pack.py b/processing/pre/geom_pack.py index 55c496f60..369857c2c 100755 --- a/processing/pre/geom_pack.py +++ b/processing/pre/geom_pack.py @@ -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 diff --git a/processing/pre/geom_rescale.py b/processing/pre/geom_rescale.py index 1af26592d..10994afb3 100755 --- a/processing/pre/geom_rescale.py +++ b/processing/pre/geom_rescale.py @@ -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 diff --git a/processing/pre/geom_toTable.py b/processing/pre/geom_toTable.py index da7dfcc2c..da95b2d4e 100755 --- a/processing/pre/geom_toTable.py +++ b/processing/pre/geom_toTable.py @@ -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() diff --git a/processing/pre/geom_translate.py b/processing/pre/geom_translate.py index da56f8078..0b603cb7d 100755 --- a/processing/pre/geom_translate.py +++ b/processing/pre/geom_translate.py @@ -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 diff --git a/processing/pre/geom_unpack.py b/processing/pre/geom_unpack.py index 9a1898d52..46342487b 100755 --- a/processing/pre/geom_unpack.py +++ b/processing/pre/geom_unpack.py @@ -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 diff --git a/processing/pre/geom_vicinityOffset.py b/processing/pre/geom_vicinityOffset.py index 2cbd09270..938e471c0 100755 --- a/processing/pre/geom_vicinityOffset.py +++ b/processing/pre/geom_vicinityOffset.py @@ -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]') diff --git a/processing/pre/gmsh_identifySurfaces.py b/processing/pre/gmsh_identifySurfaces.py index 4ffea7cda..87f98daa4 100755 --- a/processing/pre/gmsh_identifySurfaces.py +++ b/processing/pre/gmsh_identifySurfaces.py @@ -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] diff --git a/processing/pre/marc_addUserOutput.py b/processing/pre/marc_addUserOutput.py index 87f91e8fa..68f577836 100755 --- a/processing/pre/marc_addUserOutput.py +++ b/processing/pre/marc_addUserOutput.py @@ -7,8 +7,9 @@ based on the files .output 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', \ diff --git a/processing/pre/mentat_pbcOnBoxMesh.py b/processing/pre/mentat_pbcOnBoxMesh.py index 539280ff4..6c294e91a 100755 --- a/processing/pre/mentat_pbcOnBoxMesh.py +++ b/processing/pre/mentat_pbcOnBoxMesh.py @@ -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",\ diff --git a/processing/pre/mentat_spectralBox.py b/processing/pre/mentat_spectralBox.py index 79890d2f0..3f810d7b7 100755 --- a/processing/pre/mentat_spectralBox.py +++ b/processing/pre/mentat_spectralBox.py @@ -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 diff --git a/processing/pre/patchFromReconstructedBoundaries.py b/processing/pre/patchFromReconstructedBoundaries.py index f9cc06617..e16af894e 100755 --- a/processing/pre/patchFromReconstructedBoundaries.py +++ b/processing/pre/patchFromReconstructedBoundaries.py @@ -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]") diff --git a/processing/pre/seeds_check.py b/processing/pre/seeds_check.py index 7ef74655d..94bc06f19 100755 --- a/processing/pre/seeds_check.py +++ b/processing/pre/seeds_check.py @@ -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 diff --git a/processing/pre/seeds_fromRandom.py b/processing/pre/seeds_fromRandom.py index 88fd0143f..b1da2dee4 100755 --- a/processing/pre/seeds_fromRandom.py +++ b/processing/pre/seeds_fromRandom.py @@ -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