flexible selection of axes
This commit is contained in:
parent
9e3c54b0e3
commit
43457dcfc5
|
@ -14,15 +14,24 @@ scriptID = ' '.join([scriptName,damask.version])
|
||||||
# MAIN
|
# MAIN
|
||||||
#--------------------------------------------------------------------------------------------------
|
#--------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
validDirections = ['x','y','z']
|
||||||
parser = OptionParser(option_class=damask.extendableOption, usage='%prog options [geomfile(s)]', description = """
|
parser = OptionParser(option_class=damask.extendableOption, usage='%prog options [geomfile(s)]', description = """
|
||||||
Mirros spectral geometry description along given direction.
|
Mirrors spectral geometry description along given directions.
|
||||||
|
|
||||||
""", version=scriptID)
|
""", version=scriptID)
|
||||||
|
|
||||||
|
parser.add_option('-d','--direction',
|
||||||
|
dest = 'directions',
|
||||||
|
action = 'extend', metavar = '<string LIST>',
|
||||||
|
help = "directions in which to mirror {'x','y','z'}")
|
||||||
|
|
||||||
(options, filenames) = parser.parse_args()
|
(options, filenames) = parser.parse_args()
|
||||||
|
|
||||||
|
if options.directions is None:
|
||||||
|
parser.error('no direction given.')
|
||||||
|
if not set(options.directions).issubset(validDirections):
|
||||||
|
invalidDirections = [str(e) for e in set(options.directions).difference(validDirections)]
|
||||||
|
parser.error('invalid directions {}. '.format(*invalidDirections))
|
||||||
|
|
||||||
# --- loop over input files -------------------------------------------------------------------------
|
# --- loop over input files -------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -59,8 +68,11 @@ for name in filenames:
|
||||||
|
|
||||||
microstructure = table.microstructure_read(info['grid']).reshape(info['grid'],order='F') # read microstructure
|
microstructure = table.microstructure_read(info['grid']).reshape(info['grid'],order='F') # read microstructure
|
||||||
|
|
||||||
|
if 'z' in options.directions:
|
||||||
microstructure = np.concatenate([microstructure,microstructure[:,:,::-1]],2)
|
microstructure = np.concatenate([microstructure,microstructure[:,:,::-1]],2)
|
||||||
|
if 'y' in options.directions:
|
||||||
microstructure = np.concatenate([microstructure,microstructure[:,::-1,:]],1)
|
microstructure = np.concatenate([microstructure,microstructure[:,::-1,:]],1)
|
||||||
|
if 'x' in options.directions:
|
||||||
microstructure = np.concatenate([microstructure,microstructure[::-1,:,:]],0)
|
microstructure = np.concatenate([microstructure,microstructure[::-1,:,:]],0)
|
||||||
|
|
||||||
# --- do work ------------------------------------------------------------------------------------
|
# --- do work ------------------------------------------------------------------------------------
|
||||||
|
|
Loading…
Reference in New Issue