From b3a90a8a3b353e6ac8d81e0c4813b9e78098383b Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Fri, 17 May 2013 16:44:03 +0000 Subject: [PATCH] last changes on preprocessing tools, only documentation needs to be done --- processing/pre/geom_fromAng.py | 16 ++++++++-------- processing/pre/geom_fromVPSC.py | 6 +++--- processing/pre/geom_fromVoronoiTessellation.py | 1 + 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/processing/pre/geom_fromAng.py b/processing/pre/geom_fromAng.py index 3b9cba269..e2d102ff6 100755 --- a/processing/pre/geom_fromAng.py +++ b/processing/pre/geom_fromAng.py @@ -40,7 +40,7 @@ parser.add_option('-t','--threshold', dest='threshold', type='float', \ 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, \ - help='phase indices to be used %default') + help='two phase indices to be used %default') 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', \ @@ -78,7 +78,7 @@ for file in files: if file['name'] != 'STDIN': file['croak'].write(file['name']+'\n') info = { - 'grid': numpy.array([0,0,1]), + 'grid': numpy.ones (3,'i'), 'size': numpy.zeros(3,'d'), 'origin': numpy.zeros(3,'d'), 'microstructures': 0, @@ -98,10 +98,10 @@ for file in files: file['croak'].write('The file has HexGrid format. Please first convert to SquareGrid...\n'); break if words[1] == 'XSTEP:': step[0] = float(words[2]) if words[1] == 'YSTEP:': step[1] = float(words[2]) - if words[1] == 'NCOLS_ODD:': - info['grid'][0] = int(words[2]); formatwidth = 1+int(math.log10(info['grid'][0]*info['grid'][1])) - if words[1] == 'NROWS:': - info['grid'][1] = int(words[2]); formatwidth = 1+int(math.log10(info['grid'][0]*info['grid'][1])) + if words[1] == 'NCOLS_ODD:': + info['grid'][0] = int(words[2]); formatwidth = 1+int(math.log10(info['grid'][0]*info['grid'][1])) + if words[1] == 'NROWS:': + info['grid'][1] = int(words[2]); formatwidth = 1+int(math.log10(info['grid'][0]*info['grid'][1])) else: # finished with comments block if options.config: # write configuration (line by line) point += 1 @@ -127,10 +127,10 @@ for file in files: 'microstructures: %i\n\n'%info['microstructures']) if numpy.any(info['grid'] < 1): - file['croak'].write('no valid grid info found.\n') + file['croak'].write('invalid grid a b c.\n') sys.exit() if numpy.any(info['size'] <= 0.0): - file['croak'].write('no valid size info found.\n') + file['croak'].write('invalid size x y z.\n') sys.exit() #--- write data ----------------------------------------------------------------------------------- diff --git a/processing/pre/geom_fromVPSC.py b/processing/pre/geom_fromVPSC.py index 1f69f41db..06e7a9370 100755 --- a/processing/pre/geom_fromVPSC.py +++ b/processing/pre/geom_fromVPSC.py @@ -34,7 +34,7 @@ Generate geometry description and material configuration from input files used b parser.add_option('--column', dest='column', type='int', \ help='data column to discriminate phase 1 from 2 [%default]') -parser.add_option('-t','--treshold', dest='threshold', type='float', \ +parser.add_option('-t','--treshold', dest='threshold', type='float', \ help='threshold value to discriminate phase 1 from 2 [%default]') parser.add_option('--homogenization', dest='homogenization', type='int', \ help='homogenization index to be used [%default]') @@ -117,10 +117,10 @@ for file in files: 'microstructures: %i\n\n'%info['microstructures']) if numpy.any(info['grid'] < 1): - file['croak'].write('no valid grid info found.\n') + file['croak'].write('invalid grid a b c.\n') sys.exit() if numpy.any(info['size'] <= 0.0): - file['croak'].write('no valid size info found.\n') + file['croak'].write('invalid size x y z.\n') sys.exit() #--- write data ----------------------------------------------------------------------------------- diff --git a/processing/pre/geom_fromVoronoiTessellation.py b/processing/pre/geom_fromVoronoiTessellation.py index 6c11cf9bd..d6b03915d 100755 --- a/processing/pre/geom_fromVoronoiTessellation.py +++ b/processing/pre/geom_fromVoronoiTessellation.py @@ -206,6 +206,7 @@ for file in files: new_header.append("homogenization\t%i\n"%info['homogenization']) file['output'].write('%i\theader\n'%(len(new_header)) + ''.join(new_header)) +# --- write microstructure information ------------------------------------------------------------ for n in xrange(info['grid'][1:3].prod()): # loop over 2nd and 3rd size file['output'].write({ True: ' ', False:'\n'}[options.twoD].\