From f8ce57abc80802d725e439d40da340dadb367330 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Mon, 8 Dec 2014 08:48:55 +0000 Subject: [PATCH] removed aliases 'resolution' and 'dimension' for 'grid' and 'size' because some scripts did not have it anyway and the rename happened quite a while ago --- processing/pre/geom_addPrimitive.py | 9 +------ processing/pre/geom_canvas.py | 10 +------- processing/pre/geom_check.py | 6 ----- processing/pre/geom_fromEuclideanDistance.py | 6 ----- processing/pre/geom_grainGrowth.py | 16 ++++-------- processing/pre/geom_pack.py | 6 ----- processing/pre/geom_rescale.py | 6 ----- processing/pre/geom_toTable.py | 8 +----- processing/pre/geom_translate.py | 16 ++++-------- processing/pre/geom_unpack.py | 6 ----- processing/pre/geom_vicinityOffset.py | 26 -------------------- processing/pre/gmsh_identifySurfaces.py | 2 +- processing/pre/seeds_check.py | 6 ----- processing/pre/seeds_fromGeom.py | 6 ----- processing/pre/seeds_fromTable.py | 6 ----- 15 files changed, 14 insertions(+), 121 deletions(-) diff --git a/processing/pre/geom_addPrimitive.py b/processing/pre/geom_addPrimitive.py index 250ed4c26..cdb54c9d6 100755 --- a/processing/pre/geom_addPrimitive.py +++ b/processing/pre/geom_addPrimitive.py @@ -14,10 +14,6 @@ oversampling = 2. #-------------------------------------------------------------------------------------------------- # MAIN #-------------------------------------------------------------------------------------------------- -synonyms = { - 'grid': ['resolution'], - 'size': ['dimension'], - } identifiers = { 'grid': ['a','b','c'], 'size': ['x','y','z'], @@ -37,8 +33,7 @@ Depending on the sign of the dimension parameters, these objects can be boxes, c """, version = scriptID) -parser.add_option('-o', '--origin', - '-c', '--center', dest='center', type='int', nargs = 3, metavar=' '.join(['int']*3), +parser.add_option('-c', '--center', dest='center', type='int', nargs = 3, metavar=' '.join(['int']*3), help='a,b,c origin of primitive %default') parser.add_option('-d', '--dimension', dest='dimension', type='int', nargs = 3, metavar=' '.join(['int']*3), help='a,b,c extension of hexahedral box; negative values are diameters') @@ -115,8 +110,6 @@ for file in files: for header in table.info: headitems = map(str.lower,header.split()) if len(headitems) == 0: continue # skip blank lines - for synonym,alternatives in synonyms.iteritems(): - if headitems[0] in alternatives: headitems[0] = synonym if headitems[0] in mappings.keys(): if headitems[0] in identifiers.keys(): for i in xrange(len(identifiers[headitems[0]])): diff --git a/processing/pre/geom_canvas.py b/processing/pre/geom_canvas.py index 1a4f536c1..c40cc2e72 100755 --- a/processing/pre/geom_canvas.py +++ b/processing/pre/geom_canvas.py @@ -12,12 +12,6 @@ scriptName = os.path.splitext(scriptID.split()[1])[0] # -------------------------------------------------------------------- # MAIN # -------------------------------------------------------------------- - - -synonyms = { - 'grid': ['resolution'], - 'size': ['dimension'], - } identifiers = { 'grid': ['a','b','c'], 'size': ['x','y','z'], @@ -44,7 +38,7 @@ parser.add_option('-f', '--fill', dest='fill', type='int', metavar = 'int', help='(background) canvas grain index. "0" selects maximum microstructure index + 1 [%default]') parser.set_defaults(grid = ['0','0','0']) -parser.set_defaults(offset = [0,0,0]) +parser.set_defaults(offset = (0,0,0)) parser.set_defaults(fill = 0) (options, filenames) = parser.parse_args() @@ -91,8 +85,6 @@ for file in files: for header in theTable.info: headitems = map(str.lower,header.split()) if len(headitems) == 0: continue # skip blank lines - for synonym,alternatives in synonyms.iteritems(): - if headitems[0] in alternatives: headitems[0] = synonym if headitems[0] in mappings.keys(): if headitems[0] in identifiers.keys(): for i in xrange(len(identifiers[headitems[0]])): diff --git a/processing/pre/geom_check.py b/processing/pre/geom_check.py index 924c28f52..59da265fd 100755 --- a/processing/pre/geom_check.py +++ b/processing/pre/geom_check.py @@ -12,10 +12,6 @@ scriptName = os.path.splitext(scriptID.split()[1])[0] #-------------------------------------------------------------------------------------------------- # MAIN #-------------------------------------------------------------------------------------------------- -synonyms = { - 'grid': ['resolution'], - 'size': ['dimension'], - } identifiers = { 'grid': ['a','b','c'], 'size': ['x','y','z'], @@ -77,8 +73,6 @@ for file in files: for header in theTable.info: headitems = map(str.lower,header.split()) if len(headitems) == 0: continue - for synonym,alternatives in synonyms.iteritems(): - if headitems[0] in alternatives: headitems[0] = synonym if headitems[0] in mappings.keys(): if headitems[0] in identifiers.keys(): for i in xrange(len(identifiers[headitems[0]])): diff --git a/processing/pre/geom_fromEuclideanDistance.py b/processing/pre/geom_fromEuclideanDistance.py index ab916b51f..ce4c2f50d 100755 --- a/processing/pre/geom_fromEuclideanDistance.py +++ b/processing/pre/geom_fromEuclideanDistance.py @@ -34,10 +34,6 @@ def periodic_3Dpad(array, rimdim=(1,1,1)): #-------------------------------------------------------------------------------------------------- # MAIN #-------------------------------------------------------------------------------------------------- -synonyms = { - 'grid': ['resolution'], - 'size': ['dimension'], - } identifiers = { 'grid': ['a','b','c'], 'size': ['x','y','z'], @@ -169,8 +165,6 @@ for file in files: for header in table.info: headitems = map(str.lower,header.split()) if len(headitems) == 0: continue # skip blank lines - for synonym,alternatives in synonyms.iteritems(): - if headitems[0] in alternatives: headitems[0] = synonym if headitems[0] in mappings.keys(): if headitems[0] in identifiers.keys(): for i in xrange(len(identifiers[headitems[0]])): diff --git a/processing/pre/geom_grainGrowth.py b/processing/pre/geom_grainGrowth.py index af4681fe7..be9da42dd 100755 --- a/processing/pre/geom_grainGrowth.py +++ b/processing/pre/geom_grainGrowth.py @@ -8,15 +8,11 @@ from scipy import ndimage import damask scriptID = string.replace('$Id$','\n','\\n') -scriptName = scriptID.split()[1][:-3] +scriptName = os.path.splitext(scriptID.split()[1])[0] #-------------------------------------------------------------------------------------------------- # MAIN #-------------------------------------------------------------------------------------------------- -synonyms = { - 'grid': ['resolution'], - 'size': ['dimension'], - } identifiers = { 'grid': ['a','b','c'], 'size': ['x','y','z'], @@ -35,8 +31,8 @@ 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(scriptID,'\n','\\n') -) + +""", version = scriptID) parser.add_option('-d', '--distance', dest='d', type='int', metavar='int', help='diffusion distance in voxels [%default]') @@ -97,8 +93,6 @@ for file in files: for header in theTable.info: headitems = map(str.lower,header.split()) if len(headitems) == 0: continue - for synonym,alternatives in synonyms.iteritems(): - if headitems[0] in alternatives: headitems[0] = synonym if headitems[0] in mappings.keys(): if headitems[0] in identifiers.keys(): for i in xrange(len(identifiers[headitems[0]])): @@ -243,6 +237,6 @@ for file in files: #--- output finalization -------------------------------------------------------------------------- if file['name'] != 'STDIN': - theTable.__IO__['in'].close() - theTable.__IO__['out'].close() + theTable.input_close() + theTable.output_close() os.rename(file['name']+'_tmp',file['name']) diff --git a/processing/pre/geom_pack.py b/processing/pre/geom_pack.py index d3c7723ec..521ca9316 100755 --- a/processing/pre/geom_pack.py +++ b/processing/pre/geom_pack.py @@ -12,10 +12,6 @@ scriptName = os.path.splitext(scriptID.split()[1])[0] #-------------------------------------------------------------------------------------------------- # MAIN #-------------------------------------------------------------------------------------------------- -synonyms = { - 'grid': ['resolution'], - 'size': ['dimension'], - } identifiers = { 'grid': ['a','b','c'], 'size': ['x','y','z'], @@ -74,8 +70,6 @@ for file in files: for header in table.info: headitems = map(str.lower,header.split()) if len(headitems) == 0: continue - for synonym,alternatives in synonyms.iteritems(): - if headitems[0] in alternatives: headitems[0] = synonym if headitems[0] in mappings.keys(): if headitems[0] in identifiers.keys(): for i in xrange(len(identifiers[headitems[0]])): diff --git a/processing/pre/geom_rescale.py b/processing/pre/geom_rescale.py index 5f10c2ade..e0dd5e86e 100755 --- a/processing/pre/geom_rescale.py +++ b/processing/pre/geom_rescale.py @@ -12,10 +12,6 @@ scriptName = os.path.splitext(scriptID.split()[1])[0] #-------------------------------------------------------------------------------------------------- # MAIN #-------------------------------------------------------------------------------------------------- -synonyms = { - 'grid': ['resolution'], - 'size': ['dimension'], - } identifiers = { 'grid': ['a','b','c'], 'size': ['x','y','z'], @@ -91,8 +87,6 @@ for file in files: for header in table.info: headitems = map(str.lower,header.split()) if len(headitems) == 0: continue - for synonym,alternatives in synonyms.iteritems(): - if headitems[0] in alternatives: headitems[0] = synonym if headitems[0] in mappings.keys(): if headitems[0] in identifiers.keys(): for i in xrange(len(identifiers[headitems[0]])): diff --git a/processing/pre/geom_toTable.py b/processing/pre/geom_toTable.py index da95b2d4e..4e37fb049 100755 --- a/processing/pre/geom_toTable.py +++ b/processing/pre/geom_toTable.py @@ -7,16 +7,12 @@ from optparse import OptionParser import damask scriptID = string.replace('$Id$','\n','\\n') -scriptName = scriptID.split()[1][:-3] +scriptName = os.path.splitext(scriptID.split()[1])[0] #-------------------------------------------------------------------------------------------------- # MAIN #-------------------------------------------------------------------------------------------------- -synonyms = { - 'grid': ['resolution'], - 'size': ['dimension'], - } identifiers = { 'grid': ['a','b','c'], 'size': ['x','y','z'], @@ -76,8 +72,6 @@ for file in files: for header in theTable.info: headitems = map(str.lower,header.split()) if len(headitems) == 0: continue - for synonym,alternatives in synonyms.iteritems(): - if headitems[0] in alternatives: headitems[0] = synonym if headitems[0] in mappings.keys(): if headitems[0] in identifiers.keys(): for i in xrange(len(identifiers[headitems[0]])): diff --git a/processing/pre/geom_translate.py b/processing/pre/geom_translate.py index 7d426ea3c..9b916b361 100755 --- a/processing/pre/geom_translate.py +++ b/processing/pre/geom_translate.py @@ -12,10 +12,6 @@ scriptName = os.path.splitext(scriptID.split()[1])[0] #-------------------------------------------------------------------------------------------------- # MAIN #-------------------------------------------------------------------------------------------------- -synonyms = { - 'grid': ['resolution'], - 'size': ['dimension'], - } identifiers = { 'grid': ['a','b','c'], 'size': ['x','y','z'], @@ -34,14 +30,14 @@ translate microstructure indices (shift or substitute) and/or geometry origin. """, 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') -parser.add_option('-m', '--microstructure', dest='microstructure', type='int', \ +parser.add_option('-o', '--origin', dest='origin', type='float', nargs = 3, + help='offset from old to new origin of grid', metavar=' '.join(['float']*3)) +parser.add_option('-m', '--microstructure', dest='microstructure', type='int', help='offset from old to new microstructure indices', metavar='int') -parser.add_option('-s', '--substitute', action='extend', dest='substitute', \ +parser.add_option('-s', '--substitute', action='extend', dest='substitute', help='substitutions of microstructure indices from,to,from,to,...', metavar='') -parser.set_defaults(origin = [0.0,0.0,0.0]) +parser.set_defaults(origin = (0.0,0.0,0.0)) parser.set_defaults(microstructure = 0) parser.set_defaults(substitute = []) parser.set_defaults(twoD = False) @@ -93,8 +89,6 @@ for file in files: for header in theTable.info: headitems = map(str.lower,header.split()) if len(headitems) == 0: continue - for synonym,alternatives in synonyms.iteritems(): - if headitems[0] in alternatives: headitems[0] = synonym if headitems[0] in mappings.keys(): if headitems[0] in identifiers.keys(): for i in xrange(len(identifiers[headitems[0]])): diff --git a/processing/pre/geom_unpack.py b/processing/pre/geom_unpack.py index 7b5fd475a..4d4c25124 100755 --- a/processing/pre/geom_unpack.py +++ b/processing/pre/geom_unpack.py @@ -12,10 +12,6 @@ scriptName = os.path.splitext(scriptID.split()[1])[0] #-------------------------------------------------------------------------------------------------- # MAIN #-------------------------------------------------------------------------------------------------- -synonyms = { - 'grid': ['resolution'], - 'size': ['dimension'], - } identifiers = { 'grid': ['a','b','c'], 'size': ['x','y','z'], @@ -70,8 +66,6 @@ for file in files: for header in table.info: headitems = map(str.lower,header.split()) if len(headitems) == 0: continue - for synonym,alternatives in synonyms.iteritems(): - if headitems[0] in alternatives: headitems[0] = synonym if headitems[0] in mappings.keys(): if headitems[0] in identifiers.keys(): for i in xrange(len(identifiers[headitems[0]])): diff --git a/processing/pre/geom_vicinityOffset.py b/processing/pre/geom_vicinityOffset.py index f467f2b4e..56d44d5ed 100755 --- a/processing/pre/geom_vicinityOffset.py +++ b/processing/pre/geom_vicinityOffset.py @@ -10,33 +10,9 @@ import damask scriptID = string.replace('$Id$','\n','\\n') scriptName = os.path.splitext(scriptID.split()[1])[0] -#-------------------------------------------------------------------------------------------------- -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 #-------------------------------------------------------------------------------------------------- - -synonyms = { - 'grid': ['resolution'], - 'size': ['dimension'], - } identifiers = { 'grid': ['a','b','c'], 'size': ['x','y','z'], @@ -107,8 +83,6 @@ for file in files: for header in theTable.info: headitems = map(str.lower,header.split()) if len(headitems) == 0: continue - for synonym,alternatives in synonyms.iteritems(): - if headitems[0] in alternatives: headitems[0] = synonym if headitems[0] in mappings.keys(): if headitems[0] in identifiers.keys(): for i in xrange(len(identifiers[headitems[0]])): diff --git a/processing/pre/gmsh_identifySurfaces.py b/processing/pre/gmsh_identifySurfaces.py index c800efa66..66dad7a74 100755 --- a/processing/pre/gmsh_identifySurfaces.py +++ b/processing/pre/gmsh_identifySurfaces.py @@ -6,7 +6,7 @@ from optparse import OptionParser import damask scriptID = string.replace('$Id$','\n','\\n') -scriptName = scriptID.split()[1][:-3] +scriptName = os.path.splitext(scriptID.split()[1])[0] def all_same(items,a): return all(x == a for x in items) diff --git a/processing/pre/seeds_check.py b/processing/pre/seeds_check.py index 7c017df32..48f738a19 100755 --- a/processing/pre/seeds_check.py +++ b/processing/pre/seeds_check.py @@ -12,10 +12,6 @@ scriptName = os.path.splitext(scriptID.split()[1])[0] #-------------------------------------------------------------------------------------------------- # MAIN #-------------------------------------------------------------------------------------------------- -synonyms = { - 'grid': ['resolution'], - 'size': ['dimension'], - } identifiers = { 'grid': ['a','b','c'], 'size': ['x','y','z'], @@ -78,8 +74,6 @@ for file in files: for header in theTable.info: headitems = map(str.lower,header.split()) if len(headitems) == 0: continue - for synonym,alternatives in synonyms.iteritems(): - if headitems[0] in alternatives: headitems[0] = synonym if headitems[0] in mappings.keys(): if headitems[0] in identifiers.keys(): for i in xrange(len(identifiers[headitems[0]])): diff --git a/processing/pre/seeds_fromGeom.py b/processing/pre/seeds_fromGeom.py index 38e659d0e..0af7a6592 100755 --- a/processing/pre/seeds_fromGeom.py +++ b/processing/pre/seeds_fromGeom.py @@ -12,10 +12,6 @@ scriptName = os.path.splitext(scriptID.split()[1])[0] #-------------------------------------------------------------------------------------------------- # MAIN #-------------------------------------------------------------------------------------------------- -synonyms = { - 'grid': ['resolution'], - 'size': ['dimension'], - } identifiers = { 'grid': ['a','b','c'], 'size': ['x','y','z'], @@ -90,8 +86,6 @@ for file in files: for header in table.info: headitems = map(str.lower,header.split()) if len(headitems) == 0: continue # skip blank lines - for synonym,alternatives in synonyms.iteritems(): - if headitems[0] in alternatives: headitems[0] = synonym if headitems[0] in mappings.keys(): if headitems[0] in identifiers.keys(): for i in xrange(len(identifiers[headitems[0]])): diff --git a/processing/pre/seeds_fromTable.py b/processing/pre/seeds_fromTable.py index bc011018d..b0ccbbe19 100755 --- a/processing/pre/seeds_fromTable.py +++ b/processing/pre/seeds_fromTable.py @@ -10,14 +10,9 @@ import damask scriptID = string.replace('$Id$','\n','\\n') scriptName = os.path.splitext(scriptID.split()[1])[0] - #-------------------------------------------------------------------------------------------------- # MAIN #-------------------------------------------------------------------------------------------------- -synonyms = { - 'grid': ['resolution'], - 'size': ['dimension'], - } identifiers = { 'grid': ['a','b','c'], 'size': ['x','y','z'], @@ -31,7 +26,6 @@ mappings = { 'microstructures': lambda x: int(x), } - parser = OptionParser(option_class=damask.extendableOption, usage='%prog options [file[s]]', description = """ Create seed file by taking microstructure indices from given ASCIItable column. White and black-listing of microstructure indices is possible.