From 34f7bbe2a0823bd1b49a3a3b35bf4687860b489d Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sun, 26 May 2019 13:06:22 +0200 Subject: [PATCH] 'blank' option does not fit to flow of script seeds_fromRandom -N 1 | geom_fromVoronoiTessellation -g 30 30 30 -s 1 1 1 > file.geom or a few lines of python code give the same results --- processing/pre/geom_canvas.py | 35 +++++++---------------------------- 1 file changed, 7 insertions(+), 28 deletions(-) diff --git a/processing/pre/geom_canvas.py b/processing/pre/geom_canvas.py index 01682deb8..a3f1b7f3b 100755 --- a/processing/pre/geom_canvas.py +++ b/processing/pre/geom_canvas.py @@ -32,30 +32,17 @@ parser.add_option('-o', parser.add_option('-f', '--fill', dest = 'fill', - type = 'float', metavar = 'float', + type = 'int', metavar = 'int', help = '(background) canvas grain index. "0" selects maximum microstructure index + 1 [%default]') -parser.add_option('--float', - dest = 'float', - action = 'store_true', - help = 'use float input') -parser.add_option('--blank', - dest = 'blank', - action = 'store_true', - help = 'blank out (optional) input canvas content') -parser.set_defaults(grid = ['0','0','0'], +parser.set_defaults(grid = ('0','0','0'), offset = (0,0,0), - fill = 0.0, - float = False, ) (options, filenames) = parser.parse_args() -datatype = 'f' if options.float else 'i' -options.grid = ['1','1','1'] if options.blank and options.grid == ['0','0','0'] else options.grid -options.fill = 1 if options.blank and options.fill == 0 else options.fill +datatype = 'i' -# --- loop over input files ------------------------------------------------------------------------- if filenames == []: filenames = [None] @@ -66,15 +53,7 @@ for name in filenames: except: continue damask.util.report(scriptName,name) - if options.blank: - extra_header = [] - info = {} - info['grid'] = np.zeros(3,dtype=int) - info['size'] = np.zeros(3,dtype=float) - info['origin'] = np.zeros(3,dtype=float) - info['microstructures'] = 0 - info['homogenization'] = 1 - else: + if True: # --- interpret header ---------------------------------------------------------------------------- @@ -107,9 +86,9 @@ for name in filenames: newInfo['grid'] = np.where(newInfo['grid'] > 0, newInfo['grid'],info['grid']) microstructure_cropped = np.zeros(newInfo['grid'],datatype) - microstructure_cropped.fill(options.fill if options.float or options.fill > 0 else np.nanmax(microstructure)+1) + microstructure_cropped.fill(options.fill if options.fill is not None else np.nanmax(microstructure)+1) - if not options.blank: + if True: xindex = np.arange(max(options.offset[0],0),min(options.offset[0]+newInfo['grid'][0],info['grid'][0])) yindex = np.arange(max(options.offset[1],0),min(options.offset[1]+newInfo['grid'][1],info['grid'][1])) zindex = np.arange(max(options.offset[2],0),min(options.offset[2]+newInfo['grid'][2],info['grid'][2])) @@ -172,7 +151,7 @@ for name in filenames: # --- write microstructure information ------------------------------------------------------------ - format = '%g' if options.float else '%{}i'.format(int(math.floor(math.log10(np.nanmax(microstructure_cropped))+1))) + format = '%{}i'.format(int(math.floor(math.log10(np.nanmax(microstructure_cropped))+1))) table.data = microstructure_cropped.reshape((newInfo['grid'][0],newInfo['grid'][1]*newInfo['grid'][2]),order='F').transpose() table.data_writeArray(format,delimiter=' ')