diff --git a/processing/post/3Dvisualize.py b/processing/post/3Dvisualize.py index 33100780e..c2e1c8404 100755 --- a/processing/post/3Dvisualize.py +++ b/processing/post/3Dvisualize.py @@ -274,7 +274,7 @@ parser.add_option('-v', '--vector', action='extend', dest='vector', type='string help='list of vectors to visualize', metavar = '') parser.add_option('-t', '--tensor', action='extend', dest='tensor', type='string', \ help='list of tensors to visualize', metavar = '') -parser.add_option('-d', '--deformation', dest='defgrad', type='string', \ +parser.add_option('-d', '--deformation', dest='defgrad', action='store', type='string', \ help='heading of deformation gradient columns [%default]', metavar = 'string') parser.add_option('--reference', dest='undeformed', action='store_true',\ help='map results to reference (undeformed) configuration [%default]') @@ -290,15 +290,15 @@ parser.add_option('--points', dest='output_points', action='store_true', \ help='produce VTK points file [%default]') parser.add_option('--nopoints', dest='output_points', action='store_false', \ help='omit VTK points file') -parser.add_option('--separator', dest='separator', type='string', \ +parser.add_option('--separator', dest='separator', action='store', type='string', \ help='data separator (t(ab), n(ewline), s(pace)) [%default]', metavar = 'string') parser.add_option('--scaling', dest='scaling', action='extend', type='string', \ help='scaling of fluctuation', metavar = '') -parser.add_option('-u', '--unitlength', dest='unitlength', type='float', \ +parser.add_option('-u', '--unitlength', dest='unitlength', action='store', type='float', \ help='set unit length for 2D model [%default]', metavar = 'float') -parser.add_option('--filenodalcoords', dest='filenodalcoords', type='string', \ +parser.add_option('--filenodalcoords', dest='filenodalcoords', action='store', type='string', \ help='ASCII table containing nodal coords', metavar = 'string') -parser.add_option('--labelnodalcoords', dest='labelnodalcoords', type='string', nargs=3, \ +parser.add_option('--labelnodalcoords', dest='labelnodalcoords', action='store', type='string', nargs=3, \ help='labels of nodal coords in ASCII table %default', metavar = 'string string string') parser.add_option('-l', '--linear', dest='linearreconstruction', action='store_true',\ help='use linear reconstruction of geometry [%default]') diff --git a/processing/post/addCauchy.py b/processing/post/addCauchy.py index 3100cb0ea..5c8131d2b 100755 --- a/processing/post/addCauchy.py +++ b/processing/post/addCauchy.py @@ -21,9 +21,9 @@ deformation gradient and first Piola--Kirchhoff stress. """, version = string.replace(scriptID,'\n','\\n') ) -parser.add_option('-f','--defgrad', dest='defgrad', type='string', metavar='string', \ +parser.add_option('-f','--defgrad', dest='defgrad', action='store', type='string', metavar='string', \ help='heading of columns containing deformation gradient [%default]') -parser.add_option('-p','--stress', dest='stress', type='string', metavar='string', \ +parser.add_option('-p','--stress', dest='stress', action='store', type='string', metavar='string', \ help='heading of columns containing first Piola--Kirchhoff stress [%default]') parser.set_defaults(defgrad = 'f') parser.set_defaults(stress = 'p') diff --git a/processing/post/addCompatibilityMismatch.py b/processing/post/addCompatibilityMismatch.py index 1bb5acd50..d14d85bad 100755 --- a/processing/post/addCompatibilityMismatch.py +++ b/processing/post/addCompatibilityMismatch.py @@ -24,9 +24,9 @@ parser.add_option('--no-shape','-s', dest='noShape', action='store_false', \ help='do not calcuate shape mismatch [%default]') parser.add_option('--no-volume','-v', dest='noVolume', action='store_false', \ help='do not calculate volume mismatch [%default]') -parser.add_option('-c','--coordinates', dest='coords', type='string', metavar='string', \ +parser.add_option('-c','--coordinates', dest='coords', action='store', type='string', metavar='string', \ help='column heading for coordinates [%default]') -parser.add_option('-f','--deformation', dest='defgrad', type='string', metavar='string ', \ +parser.add_option('-f','--deformation', dest='defgrad', action='store', type='string', metavar='string ', \ help='column heading for coordinates [%defgrad]') parser.set_defaults(noVolume = False) parser.set_defaults(noShape = False) diff --git a/processing/post/addCurl.py b/processing/post/addCurl.py index ed915bf03..8cc814799 100755 --- a/processing/post/addCurl.py +++ b/processing/post/addCurl.py @@ -22,7 +22,7 @@ Deals with both vector- and tensor-valued fields. """, version = string.replace(scriptID,'\n','\\n') ) -parser.add_option('-c','--coordinates', dest='coords', type='string', metavar='string', \ +parser.add_option('-c','--coordinates', dest='coords', action='store', type='string', metavar='string', \ help='column heading for coordinates [%default]') parser.add_option('-v','--vector', dest='vector', action='extend', type='string', metavar='', \ help='heading of columns containing vector field values') diff --git a/processing/post/addDeformedConfiguration.py b/processing/post/addDeformedConfiguration.py index f9a5b3906..8215c6182 100755 --- a/processing/post/addDeformedConfiguration.py +++ b/processing/post/addDeformedConfiguration.py @@ -21,9 +21,9 @@ Operates on periodic ordered three-dimensional data sets. """, version = string.replace(scriptID,'\n','\\n') ) -parser.add_option('-c','--coordinates', dest='coords', type='string', metavar='string', \ +parser.add_option('-c','--coordinates', dest='coords', action='store', type='string', metavar='string', \ help='column heading for coordinates [%default]') -parser.add_option('-d','--defgrad', dest='defgrad', type='string', metavar='string', \ +parser.add_option('-d','--defgrad', dest='defgrad', action='store', type='string', metavar='string', \ help='heading of columns containing tensor field values') parser.add_option('-l', '--linear', dest='linearreconstruction', action='store_true',\ help='use linear reconstruction of geometry [%default]') diff --git a/processing/post/addDivergence.py b/processing/post/addDivergence.py index 006f83112..04a0bc329 100755 --- a/processing/post/addDivergence.py +++ b/processing/post/addDivergence.py @@ -27,7 +27,7 @@ parser.add_option('--fdm', dest='accuracy', action='extend', type=' help='degree of central difference accuracy (%s)'%(','.join(accuracyChoices))) parser.add_option('--fft', dest='fft', action='store_true', \ help='calculate divergence in Fourier space') -parser.add_option('-c','--coordinates', dest='coords', type='string', metavar = 'string', \ +parser.add_option('-c','--coordinates', dest='coords', action='store', type='string', metavar = 'string', \ help='column heading for coordinates [%default]') parser.add_option('-v','--vector', dest='vector', action='extend', type='string', metavar='', \ help='heading of columns containing vector field values') diff --git a/processing/post/addEuclideanDistance.py b/processing/post/addEuclideanDistance.py index 324db7227..65245796f 100755 --- a/processing/post/addEuclideanDistance.py +++ b/processing/post/addEuclideanDistance.py @@ -1,39 +1,25 @@ #!/usr/bin/env python # -*- coding: UTF-8 no BOM -*- -import os,re,sys,math,numpy,string,damask +import os,re,sys,math,string +import numpy as np +from optparse import OptionParser from scipy import ndimage -from optparse import OptionParser, Option - -# ----------------------------- -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) +import damask +scriptID = '$Id$' +scriptName = scriptID.split()[1] def periodic_3Dpad(array, rimdim=(1,1,1)): - rimdim = numpy.array(rimdim,'i') - size = numpy.array(array.shape,'i') - padded = numpy.empty(size+2*rimdim,array.dtype) + rimdim = np.array(rimdim,'i') + size = np.array(array.shape,'i') + padded = np.empty(size+2*rimdim,array.dtype) padded[rimdim[0]:rimdim[0]+size[0], rimdim[1]:rimdim[1]+size[1], rimdim[2]:rimdim[2]+size[2]] = array - p = numpy.zeros(3,'i') + p = np.zeros(3,'i') for side in xrange(3): for p[(side+2)%3] in xrange(padded.shape[(side+2)%3]): for p[(side+1)%3] in xrange(padded.shape[(side+1)%3]): @@ -56,7 +42,7 @@ features = [ \ ] neighborhoods = { - 'neumann':numpy.array([ + 'neumann':np.array([ [-1, 0, 0], [ 1, 0, 0], [ 0,-1, 0], @@ -64,7 +50,7 @@ neighborhoods = { [ 0, 0,-1], [ 0, 0, 1], ]), - 'moore':numpy.array([ + 'moore':np.array([ [-1,-1,-1], [ 0,-1,-1], [ 1,-1,-1], @@ -95,22 +81,22 @@ neighborhoods = { ]) } -parser = OptionParser(option_class=extendableOption, usage='%prog options [file[s]]', description = """ +parser = OptionParser(option_class=damask.extendableOption, usage='%prog options [file[s]]', description = """ Add column(s) containing Euclidean distance to grain structural features: boundaries, triple lines, and quadruple points. -""" + string.replace('$Id$','\n','\\n') +""", version = string.replace(scriptID,'\n','\\n') ) -parser.add_option('-i','--identifier', dest='id', action='store', type='string', \ - help='heading of column containing grain identifier [%default]', \ - metavar='