'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
This commit is contained in:
parent
e7b8ae08d0
commit
34f7bbe2a0
|
@ -32,30 +32,17 @@ parser.add_option('-o',
|
||||||
parser.add_option('-f',
|
parser.add_option('-f',
|
||||||
'--fill',
|
'--fill',
|
||||||
dest = 'fill',
|
dest = 'fill',
|
||||||
type = 'float', metavar = 'float',
|
type = 'int', metavar = 'int',
|
||||||
help = '(background) canvas grain index. "0" selects maximum microstructure index + 1 [%default]')
|
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),
|
offset = (0,0,0),
|
||||||
fill = 0.0,
|
|
||||||
float = False,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
(options, filenames) = parser.parse_args()
|
(options, filenames) = parser.parse_args()
|
||||||
|
|
||||||
datatype = 'f' if options.float else 'i'
|
datatype = '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
|
|
||||||
|
|
||||||
# --- loop over input files -------------------------------------------------------------------------
|
|
||||||
|
|
||||||
if filenames == []: filenames = [None]
|
if filenames == []: filenames = [None]
|
||||||
|
|
||||||
|
@ -66,15 +53,7 @@ for name in filenames:
|
||||||
except: continue
|
except: continue
|
||||||
damask.util.report(scriptName,name)
|
damask.util.report(scriptName,name)
|
||||||
|
|
||||||
if options.blank:
|
if True:
|
||||||
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:
|
|
||||||
|
|
||||||
# --- interpret header ----------------------------------------------------------------------------
|
# --- interpret header ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -107,9 +86,9 @@ for name in filenames:
|
||||||
newInfo['grid'] = np.where(newInfo['grid'] > 0, newInfo['grid'],info['grid'])
|
newInfo['grid'] = np.where(newInfo['grid'] > 0, newInfo['grid'],info['grid'])
|
||||||
|
|
||||||
microstructure_cropped = np.zeros(newInfo['grid'],datatype)
|
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]))
|
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]))
|
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]))
|
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 ------------------------------------------------------------
|
# --- 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 = microstructure_cropped.reshape((newInfo['grid'][0],newInfo['grid'][1]*newInfo['grid'][2]),order='F').transpose()
|
||||||
table.data_writeArray(format,delimiter=' ')
|
table.data_writeArray(format,delimiter=' ')
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue