streamlined geom-info reporting; added --float option to some scripts; hardened against NaN; "microstructures" now reports uniques not max
This commit is contained in:
parent
e6cec6ecbe
commit
eb13fbc0ce
|
@ -35,7 +35,7 @@ parser.add_option('-f',
|
|||
type = 'float', metavar = 'float',
|
||||
help = '(background) canvas grain index. "0" selects maximum microstructure index + 1 [%default]')
|
||||
parser.add_option('--float',
|
||||
dest = 'real',
|
||||
dest = 'float',
|
||||
action = 'store_true',
|
||||
help = 'use float input')
|
||||
parser.add_option('--blank',
|
||||
|
@ -45,13 +45,13 @@ parser.add_option('--blank',
|
|||
|
||||
parser.set_defaults(grid = ['0','0','0'],
|
||||
offset = (0,0,0),
|
||||
fill = 0,
|
||||
real = False,
|
||||
fill = 0.0,
|
||||
float = False,
|
||||
)
|
||||
|
||||
(options, filenames) = parser.parse_args()
|
||||
|
||||
datatype = 'f' if options.real else 'i'
|
||||
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
|
||||
|
||||
|
@ -107,7 +107,7 @@ 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.real or options.fill > 0 else microstructure.max()+1)
|
||||
microstructure_cropped.fill(options.fill if options.float or options.fill > 0 else np.nanmax(microstructure)+1)
|
||||
|
||||
if not options.blank:
|
||||
xindex = np.arange(max(options.offset[0],0),min(options.offset[0]+newInfo['grid'][0],info['grid'][0]))
|
||||
|
@ -130,7 +130,7 @@ for name in filenames:
|
|||
newInfo['size'] = info['size']/info['grid']*newInfo['grid'] if np.all(info['grid'] > 0) else newInfo['grid']
|
||||
newInfo['origin'] = info['origin']+(info['size']/info['grid'] if np.all(info['grid'] > 0) \
|
||||
else newInfo['size']/newInfo['grid'])*options.offset
|
||||
newInfo['microstructures'] = microstructure_cropped.max()
|
||||
newInfo['microstructures'] = len(np.unique(microstructure_cropped))
|
||||
|
||||
# --- report ---------------------------------------------------------------------------------------
|
||||
|
||||
|
@ -172,7 +172,7 @@ for name in filenames:
|
|||
|
||||
# --- write microstructure information ------------------------------------------------------------
|
||||
|
||||
format = '%g' if options.real else '%{}i'.format(int(math.floor(math.log10(microstructure_cropped.max())+1)))
|
||||
format = '%g' if options.float else '%{}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=' ')
|
||||
|
||||
|
|
|
@ -50,13 +50,7 @@ for name in filenames:
|
|||
|
||||
table.head_read()
|
||||
info,extra_header = table.head_getGeom()
|
||||
|
||||
damask.util.croak(['grid a b c: {}'.format(' x '.join(map(str,info['grid']))),
|
||||
'size x y z: {}'.format(' x '.join(map(str,info['size']))),
|
||||
'origin x y z: {}'.format(' : '.join(map(str,info['origin']))),
|
||||
'homogenization: {}'.format(info['homogenization']),
|
||||
'microstructures: {}'.format(info['microstructures']),
|
||||
])
|
||||
damask.util.report_geom(info)
|
||||
|
||||
errors = []
|
||||
if np.any(info['grid'] < 1): errors.append('invalid grid a b c.')
|
||||
|
@ -73,7 +67,7 @@ for name in filenames:
|
|||
# --- do work ------------------------------------------------------------------------------------
|
||||
|
||||
microstructure = ndimage.filters.generic_filter(microstructure,mostFrequent,size=(options.stencil,)*3).astype('int_')
|
||||
newInfo = {'microstructures': microstructure.max()}
|
||||
newInfo = {'microstructures': len(np.unique(microstructure))}
|
||||
|
||||
# --- report ---------------------------------------------------------------------------------------
|
||||
if ( newInfo['microstructures'] != info['microstructures']):
|
||||
|
@ -91,9 +85,9 @@ for name in filenames:
|
|||
|
||||
# --- write microstructure information ------------------------------------------------------------
|
||||
|
||||
formatwidth = int(math.floor(math.log10(microstructure.max())+1))
|
||||
formatwidth = int(math.floor(math.log10(np.nanmax(microstructure))+1))
|
||||
table.data = microstructure.reshape((info['grid'][0],np.prod(info['grid'][1:])),order='F').transpose()
|
||||
table.data_writeArray('%%%ii'%(formatwidth),delimiter = ' ')
|
||||
table.data_writeArray('%{}i'.format(formatwidth),delimiter = ' ')
|
||||
|
||||
# --- output finalization --------------------------------------------------------------------------
|
||||
|
||||
|
|
|
@ -90,12 +90,7 @@ for name in filenames:
|
|||
|
||||
#--- report ---------------------------------------------------------------------------------------
|
||||
|
||||
damask.util.croak(['grid a b c: %s'%(' x '.join(map(str,info['grid']))),
|
||||
'size x y z: %s'%(' x '.join(map(str,info['size']))),
|
||||
'origin x y z: %s'%(' : '.join(map(str,info['origin']))),
|
||||
'homogenization: %i'%info['homogenization'],
|
||||
'microstructures: %i'%info['microstructures'],
|
||||
])
|
||||
damask.util.report_geom(info)
|
||||
|
||||
errors = []
|
||||
if np.any(info['grid'] < 1): errors.append('invalid grid a b c.')
|
||||
|
|
|
@ -192,12 +192,7 @@ for name in filenames:
|
|||
'homogenization': options.homogenization,
|
||||
}
|
||||
|
||||
damask.util.croak(['grid a b c: {}'.format(' x '.join(map(str,info['grid']))),
|
||||
'size x y z: {}'.format(' x '.join(map(str,info['size']))),
|
||||
'origin x y z: {}'.format(' : '.join(map(str,info['origin']))),
|
||||
'homogenization: {}'.format(info['homogenization']),
|
||||
'microstructures: {}'.format(info['microstructures']),
|
||||
])
|
||||
damask.util.report_geom(info)
|
||||
|
||||
# --- write header ---------------------------------------------------------------------------------
|
||||
|
||||
|
@ -230,7 +225,7 @@ for name in filenames:
|
|||
# --- write microstructure information ------------------------------------------------------------
|
||||
|
||||
table.data = grain.reshape(info['grid'][1]*info['grid'][2],info['grid'][0])
|
||||
table.data_writeArray('%%%ii'%(formatwidth),delimiter=' ')
|
||||
table.data_writeArray('%{}i'.format(formatwidth),delimiter=' ')
|
||||
|
||||
#--- output finalization --------------------------------------------------------------------------
|
||||
|
||||
|
|
|
@ -69,13 +69,7 @@ for name in filenames:
|
|||
|
||||
table.head_read()
|
||||
info,extra_header = table.head_getGeom()
|
||||
|
||||
damask.util.croak(['grid a b c: {}'.format(' x '.join(list(map(str,info['grid'])))),
|
||||
'size x y z: {}'.format(' x '.join(list(map(str,info['size'])))),
|
||||
'origin x y z: {}'.format(' : '.join(list(map(str,info['origin'])))),
|
||||
'homogenization: {}'.format(info['homogenization']),
|
||||
'microstructures: {}'.format(info['microstructures']),
|
||||
])
|
||||
damask.util.report_geom(info)
|
||||
|
||||
errors = []
|
||||
if np.any(info['grid'] < 1): errors.append('invalid grid a b c.')
|
||||
|
@ -200,8 +194,7 @@ for name in filenames:
|
|||
newID += 1
|
||||
microstructure = np.where(microstructure == microstructureID, newID, microstructure)
|
||||
|
||||
newInfo = {'microstructures': 0,}
|
||||
newInfo['microstructures'] = microstructure.max()
|
||||
newInfo = {'microstructures': len(np.unique(microstructure)),}
|
||||
|
||||
# --- report --------------------------------------------------------------------------------------
|
||||
|
||||
|
@ -226,7 +219,7 @@ for name in filenames:
|
|||
|
||||
# --- write microstructure information ------------------------------------------------------------
|
||||
|
||||
formatwidth = int(math.floor(math.log10(microstructure.max())+1))
|
||||
formatwidth = int(math.floor(math.log10(np.nanmax(microstructure))+1))
|
||||
table.data = microstructure[::1 if info['grid'][0]>1 else 2,
|
||||
::1 if info['grid'][1]>1 else 2,
|
||||
::1 if info['grid'][2]>1 else 2,].\
|
||||
|
|
|
@ -23,6 +23,13 @@ parser.add_option('-d','--direction',
|
|||
dest = 'directions',
|
||||
action = 'extend', metavar = '<string LIST>',
|
||||
help = "directions in which to mirror {'x','y','z'}")
|
||||
parser.add_option('--float',
|
||||
dest = 'float',
|
||||
action = 'store_true',
|
||||
help = 'use float input')
|
||||
|
||||
parser.set_defaults(float = False,
|
||||
)
|
||||
|
||||
(options, filenames) = parser.parse_args()
|
||||
|
||||
|
@ -32,6 +39,8 @@ if not set(options.directions).issubset(validDirections):
|
|||
invalidDirections = [str(e) for e in set(options.directions).difference(validDirections)]
|
||||
parser.error('invalid directions {}. '.format(*invalidDirections))
|
||||
|
||||
datatype = 'f' if options.float else 'i'
|
||||
|
||||
# --- loop over input files -------------------------------------------------------------------------
|
||||
|
||||
if filenames == []: filenames = [None]
|
||||
|
@ -39,7 +48,8 @@ if filenames == []: filenames = [None]
|
|||
for name in filenames:
|
||||
try:
|
||||
table = damask.ASCIItable(name = name,
|
||||
buffered = False, labeled = False)
|
||||
buffered = False,
|
||||
labeled = False)
|
||||
except: continue
|
||||
damask.util.report(scriptName,name)
|
||||
|
||||
|
@ -47,13 +57,7 @@ for name in filenames:
|
|||
|
||||
table.head_read()
|
||||
info,extra_header = table.head_getGeom()
|
||||
|
||||
damask.util.croak(['grid a b c: %s'%(' x '.join(map(str,info['grid']))),
|
||||
'size x y z: %s'%(' x '.join(map(str,info['size']))),
|
||||
'origin x y z: %s'%(' : '.join(map(str,info['origin']))),
|
||||
'homogenization: %i'%info['homogenization'],
|
||||
'microstructures: %i'%info['microstructures'],
|
||||
])
|
||||
damask.util.report_geom(info)
|
||||
|
||||
errors = []
|
||||
if np.any(info['grid'] < 1): errors.append('invalid grid a b c.')
|
||||
|
@ -65,7 +69,7 @@ for name in filenames:
|
|||
|
||||
# --- read data ------------------------------------------------------------------------------------
|
||||
|
||||
microstructure = table.microstructure_read(info['grid']).reshape(info['grid'],order='F') # read microstructure
|
||||
microstructure = table.microstructure_read(info['grid'],datatype).reshape(info['grid'],order='F') # read microstructure
|
||||
|
||||
if 'z' in options.directions:
|
||||
microstructure = np.concatenate([microstructure,microstructure[:,:,::-1]],2)
|
||||
|
@ -107,9 +111,9 @@ for name in filenames:
|
|||
|
||||
# --- write microstructure information ------------------------------------------------------------
|
||||
|
||||
formatwidth = int(math.floor(math.log10(microstructure.max())+1))
|
||||
formatwidth = int(math.floor(math.log10(np.nanmax(microstructure))+1))
|
||||
table.data = microstructure.reshape((newInfo['grid'][0],np.prod(newInfo['grid'][1:])),order='F').transpose()
|
||||
table.data_writeArray('%%%ii'%(formatwidth),delimiter = ' ')
|
||||
table.data_writeArray('%{}i'.format(formatwidth),delimiter = ' ')
|
||||
|
||||
# --- output finalization --------------------------------------------------------------------------
|
||||
|
||||
|
|
|
@ -35,13 +35,7 @@ for name in filenames:
|
|||
|
||||
table.head_read()
|
||||
info,extra_header = table.head_getGeom()
|
||||
|
||||
damask.util.croak(['grid a b c: {}'.format(' x '.join(map(str,info['grid']))),
|
||||
'size x y z: {}'.format(' x '.join(map(str,info['size']))),
|
||||
'origin x y z: {}'.format(' : '.join(map(str,info['origin']))),
|
||||
'homogenization: {}'.format(info['homogenization']),
|
||||
'microstructures: {}'.format(info['microstructures']),
|
||||
])
|
||||
damask.util.report_geom(info)
|
||||
|
||||
errors = []
|
||||
if np.any(info['grid'] < 1): errors.append('invalid grid a b c.')
|
||||
|
|
|
@ -35,13 +35,7 @@ for name in filenames:
|
|||
|
||||
table.head_read()
|
||||
info,extra_header = table.head_getGeom()
|
||||
|
||||
damask.util.croak(['grid a b c: %s'%(' x '.join(map(str,info['grid']))),
|
||||
'size x y z: %s'%(' x '.join(map(str,info['size']))),
|
||||
'origin x y z: %s'%(' : '.join(map(str,info['origin']))),
|
||||
'homogenization: %i'%info['homogenization'],
|
||||
'microstructures: %i'%info['microstructures'],
|
||||
])
|
||||
damask.util.report_geom(info)
|
||||
|
||||
errors = []
|
||||
if np.any(info['grid'] < 1): errors.append('invalid grid a b c.')
|
||||
|
@ -93,7 +87,7 @@ for name in filenames:
|
|||
|
||||
# --- write microstructure information -----------------------------------------------------------
|
||||
|
||||
format = '%{}i'.format(int(math.floor(math.log10(newInfo['microstructures'])+1)))
|
||||
format = '%{}i'.format(int(math.floor(math.log10(np.nanmax(renumbered))+1)))
|
||||
table.data = renumbered.reshape((info['grid'][0],info['grid'][1]*info['grid'][2]),order='F').transpose()
|
||||
table.data_writeArray(format,delimiter = ' ')
|
||||
|
||||
|
|
|
@ -31,14 +31,21 @@ parser.add_option('-r', '--renumber',
|
|||
dest = 'renumber',
|
||||
action = 'store_true',
|
||||
help = 'renumber microstructure indices from 1..N [%default]')
|
||||
parser.add_option('--float',
|
||||
dest = 'float',
|
||||
action = 'store_true',
|
||||
help = 'use float input')
|
||||
|
||||
parser.set_defaults(renumber = False,
|
||||
grid = ['0','0','0'],
|
||||
size = ['0.0','0.0','0.0'],
|
||||
float = False,
|
||||
)
|
||||
|
||||
(options, filenames) = parser.parse_args()
|
||||
|
||||
datatype = 'f' if options.float else 'i'
|
||||
|
||||
# --- loop over input files -------------------------------------------------------------------------
|
||||
|
||||
if filenames == []: filenames = [None]
|
||||
|
@ -46,7 +53,8 @@ if filenames == []: filenames = [None]
|
|||
for name in filenames:
|
||||
try:
|
||||
table = damask.ASCIItable(name = name,
|
||||
buffered = False, labeled = False)
|
||||
buffered = False,
|
||||
labeled = False)
|
||||
except: continue
|
||||
damask.util.report(scriptName,name)
|
||||
|
||||
|
@ -54,13 +62,7 @@ for name in filenames:
|
|||
|
||||
table.head_read()
|
||||
info,extra_header = table.head_getGeom()
|
||||
|
||||
damask.util.croak(['grid a b c: %s'%(' x '.join(map(str,info['grid']))),
|
||||
'size x y z: %s'%(' x '.join(map(str,info['size']))),
|
||||
'origin x y z: %s'%(' : '.join(map(str,info['origin']))),
|
||||
'homogenization: %i'%info['homogenization'],
|
||||
'microstructures: %i'%info['microstructures'],
|
||||
])
|
||||
damask.util.report_geom(info)
|
||||
|
||||
errors = []
|
||||
if np.any(info['grid'] < 1): errors.append('invalid grid a b c.')
|
||||
|
@ -72,7 +74,7 @@ for name in filenames:
|
|||
|
||||
# --- read data ------------------------------------------------------------------------------------
|
||||
|
||||
microstructure = table.microstructure_read(info['grid']) # read microstructure
|
||||
microstructure = table.microstructure_read(info['grid'],datatype) # read microstructure
|
||||
|
||||
# --- do work ------------------------------------------------------------------------------------
|
||||
|
||||
|
@ -113,7 +115,7 @@ for name in filenames:
|
|||
newID += 1
|
||||
microstructure = np.where(microstructure == microstructureID, newID,microstructure).reshape(microstructure.shape)
|
||||
|
||||
newInfo['microstructures'] = microstructure.max()
|
||||
newInfo['microstructures'] = len(np.unique(microstructure))
|
||||
|
||||
# --- report ---------------------------------------------------------------------------------------
|
||||
|
||||
|
@ -152,9 +154,9 @@ for name in filenames:
|
|||
|
||||
# --- write microstructure information ------------------------------------------------------------
|
||||
|
||||
formatwidth = int(math.floor(math.log10(microstructure.max())+1))
|
||||
format = '%g' if options.float else '%{}i'.format(int(math.floor(math.log10(np.nanmax(microstructure))+1)))
|
||||
table.data = microstructure.reshape((newInfo['grid'][0],newInfo['grid'][1]*newInfo['grid'][2]),order='F').transpose()
|
||||
table.data_writeArray('%%%ii'%(formatwidth),delimiter = ' ')
|
||||
table.data_writeArray(format,delimiter=' ')
|
||||
|
||||
# --- output finalization --------------------------------------------------------------------------
|
||||
|
||||
|
|
|
@ -43,9 +43,15 @@ parser.add_option('-f', '--fill',
|
|||
dest = 'fill',
|
||||
type = 'int', metavar = 'int',
|
||||
help = 'background grain index. "0" selects maximum microstructure index + 1 [%default]')
|
||||
parser.add_option('--float',
|
||||
dest = 'float',
|
||||
action = 'store_true',
|
||||
help = 'use float input')
|
||||
|
||||
parser.set_defaults(degrees = False,
|
||||
fill = 0)
|
||||
fill = 0,
|
||||
float = False,
|
||||
)
|
||||
|
||||
(options, filenames) = parser.parse_args()
|
||||
|
||||
|
@ -61,6 +67,8 @@ if options.matrix is not None:
|
|||
if options.eulers is not None:
|
||||
eulers = damask.Rotation.fromEulers(np.array(options.eulers),degrees=True).asEulers(degrees=True)
|
||||
|
||||
datatype = 'f' if options.float else 'i'
|
||||
|
||||
# --- loop over input files -------------------------------------------------------------------------
|
||||
|
||||
if filenames == []: filenames = [None]
|
||||
|
@ -77,13 +85,7 @@ for name in filenames:
|
|||
|
||||
table.head_read()
|
||||
info,extra_header = table.head_getGeom()
|
||||
|
||||
damask.util.croak(['grid a b c: {}'.format(' x '.join(map(str,info['grid']))),
|
||||
'size x y z: {}'.format(' x '.join(map(str,info['size']))),
|
||||
'origin x y z: {}'.format(' : '.join(map(str,info['origin']))),
|
||||
'homogenization: {}'.format(info['homogenization']),
|
||||
'microstructures: {}'.format(info['microstructures']),
|
||||
])
|
||||
damask.util.report_geom(info)
|
||||
|
||||
errors = []
|
||||
if np.any(info['grid'] < 1): errors.append('invalid grid a b c.')
|
||||
|
@ -95,9 +97,9 @@ for name in filenames:
|
|||
|
||||
# --- read data ------------------------------------------------------------------------------------
|
||||
|
||||
microstructure = table.microstructure_read(info['grid']).reshape(info['grid'],order='F') # read microstructure
|
||||
microstructure = table.microstructure_read(info['grid'],datatype).reshape(info['grid'],order='F') # read microstructure
|
||||
|
||||
newGrainID = options.fill if options.fill != 0 else microstructure.max()+1
|
||||
newGrainID = options.fill if options.fill != 0 else np.nanmax(microstructure)+1
|
||||
microstructure = ndimage.rotate(microstructure,eulers[2],(0,1),order=0,prefilter=False,output=int,cval=newGrainID) # rotation around Z
|
||||
microstructure = ndimage.rotate(microstructure,eulers[1],(1,2),order=0,prefilter=False,output=int,cval=newGrainID) # rotation around X
|
||||
microstructure = ndimage.rotate(microstructure,eulers[0],(0,1),order=0,prefilter=False,output=int,cval=newGrainID) # rotation around Z
|
||||
|
@ -107,19 +109,18 @@ for name in filenames:
|
|||
newInfo = {
|
||||
'size': microstructure.shape*info['size']/info['grid'],
|
||||
'grid': microstructure.shape,
|
||||
'microstructures': microstructure.max(),
|
||||
'microstructures': len(np.unique(microstructure)),
|
||||
}
|
||||
|
||||
|
||||
# --- report ---------------------------------------------------------------------------------------
|
||||
|
||||
remarks = []
|
||||
if (any(newInfo['grid'] != info['grid'])):
|
||||
remarks.append('--> grid a b c: %s'%(' x '.join(map(str,newInfo['grid']))))
|
||||
remarks.append('--> grid a b c: {}'.format(' x '.join(map(str,newInfo['grid']))))
|
||||
if (any(newInfo['size'] != info['size'])):
|
||||
remarks.append('--> size x y z: %s'%(' x '.join(map(str,newInfo['size']))))
|
||||
remarks.append('--> size x y z: {}'.format(' x '.join(map(str,newInfo['size']))))
|
||||
if ( newInfo['microstructures'] != info['microstructures']):
|
||||
remarks.append('--> microstructures: %i'%newInfo['microstructures'])
|
||||
remarks.append('--> microstructures: {}'.format(newInfo['microstructures']))
|
||||
if remarks != []: damask.util.croak(remarks)
|
||||
|
||||
# --- write header ---------------------------------------------------------------------------------
|
||||
|
@ -138,9 +139,9 @@ for name in filenames:
|
|||
|
||||
# --- write microstructure information ------------------------------------------------------------
|
||||
|
||||
formatwidth = int(math.floor(math.log10(microstructure.max())+1))
|
||||
format = '%g' if options.float else '%{}i'.format(int(math.floor(math.log10(np.nanmax(microstructure))+1)))
|
||||
table.data = microstructure.reshape((newInfo['grid'][0],np.prod(newInfo['grid'][1:])),order='F').transpose()
|
||||
table.data_writeArray('%%%ii'%(formatwidth),delimiter = ' ')
|
||||
table.data_writeArray(format,delimiter=' ')
|
||||
|
||||
# --- output finalization --------------------------------------------------------------------------
|
||||
|
||||
|
|
|
@ -20,15 +20,15 @@ Translate geom description into ASCIItable containing position and microstructur
|
|||
""", version = scriptID)
|
||||
|
||||
parser.add_option('--float',
|
||||
dest = 'real',
|
||||
dest = 'float',
|
||||
action = 'store_true',
|
||||
help = 'use float input')
|
||||
|
||||
parser.set_defaults(real = False,
|
||||
parser.set_defaults(float = False,
|
||||
)
|
||||
(options, filenames) = parser.parse_args()
|
||||
|
||||
datatype = 'f' if options.real else 'i'
|
||||
datatype = 'f' if options.float else 'i'
|
||||
|
||||
# --- loop over input files -------------------------------------------------------------------------
|
||||
|
||||
|
@ -47,13 +47,7 @@ for name in filenames:
|
|||
|
||||
table.head_read()
|
||||
info,extra_header = table.head_getGeom()
|
||||
|
||||
damask.util.croak(['grid a b c: {}'.format(' x '.join(list(map(str,info['grid'])))),
|
||||
'size x y z: {}'.format(' x '.join(list(map(str,info['size'])))),
|
||||
'origin x y z: {}'.format(' : '.join(list(map(str,info['origin'])))),
|
||||
'homogenization: {}'.format(info['homogenization']),
|
||||
'microstructures: {}'.format(info['microstructures']),
|
||||
])
|
||||
damask.util.report_geom(info)
|
||||
|
||||
errors = []
|
||||
if np.any(info['grid'] < 1): errors.append('invalid grid a b c.')
|
||||
|
|
|
@ -31,19 +31,19 @@ parser.add_option('-s', '--substitute',
|
|||
action = 'extend', metavar = '<string LIST>',
|
||||
help = 'substitutions of microstructure indices from,to,from,to,...')
|
||||
parser.add_option('--float',
|
||||
dest = 'real',
|
||||
dest = 'float',
|
||||
action = 'store_true',
|
||||
help = 'use float input')
|
||||
|
||||
parser.set_defaults(origin = (0.0,0.0,0.0),
|
||||
microstructure = 0,
|
||||
substitute = [],
|
||||
real = False,
|
||||
float = False,
|
||||
)
|
||||
|
||||
(options, filenames) = parser.parse_args()
|
||||
|
||||
datatype = 'f' if options.real else 'i'
|
||||
datatype = 'f' if options.float else 'i'
|
||||
|
||||
sub = {}
|
||||
for i in range(len(options.substitute)//2): # split substitution list into "from" -> "to"
|
||||
|
@ -64,13 +64,7 @@ for name in filenames:
|
|||
|
||||
table.head_read()
|
||||
info,extra_header = table.head_getGeom()
|
||||
|
||||
damask.util.croak(['grid a b c: %s'%(' x '.join(map(str,info['grid']))),
|
||||
'size x y z: %s'%(' x '.join(map(str,info['size']))),
|
||||
'origin x y z: %s'%(' : '.join(map(str,info['origin']))),
|
||||
'homogenization: %i'%info['homogenization'],
|
||||
'microstructures: %i'%info['microstructures'],
|
||||
])
|
||||
damask.util.report_geom(info)
|
||||
|
||||
errors = []
|
||||
if np.any(info['grid'] < 1): errors.append('invalid grid a b c.')
|
||||
|
@ -103,9 +97,9 @@ for name in filenames:
|
|||
|
||||
remarks = []
|
||||
if (any(newInfo['origin'] != info['origin'])):
|
||||
remarks.append('--> origin x y z: %s'%(' : '.join(map(str,newInfo['origin']))))
|
||||
remarks.append('--> origin x y z: {}'.format(' : '.join(map(str,newInfo['origin']))))
|
||||
if ( newInfo['microstructures'] != info['microstructures']):
|
||||
remarks.append('--> microstructures: %i'%newInfo['microstructures'])
|
||||
remarks.append('--> microstructures: {}'.format(newInfo['microstructures']))
|
||||
if remarks != []: damask.util.croak(remarks)
|
||||
|
||||
# --- write header -------------------------------------------------------------------------------
|
||||
|
@ -124,7 +118,7 @@ for name in filenames:
|
|||
|
||||
# --- write microstructure information -----------------------------------------------------------
|
||||
|
||||
format = '%g' if options.real else '%{}i'.format(int(math.floor(math.log10(microstructure.max())+1)))
|
||||
format = '%g' if options.float else '%{}i'.format(int(math.floor(math.log10(np.nanmax(substituted))+1)))
|
||||
table.data = substituted.reshape((info['grid'][0],info['grid'][1]*info['grid'][2]),order='F').transpose()
|
||||
table.data_writeArray(format,delimiter = ' ')
|
||||
|
||||
|
|
|
@ -43,13 +43,7 @@ for name in filenames:
|
|||
|
||||
table.head_read()
|
||||
info,extra_header = table.head_getGeom()
|
||||
|
||||
damask.util.croak(['grid a b c: %s'%(' x '.join(map(str,info['grid']))),
|
||||
'size x y z: %s'%(' x '.join(map(str,info['size']))),
|
||||
'origin x y z: %s'%(' : '.join(map(str,info['origin']))),
|
||||
'homogenization: %i'%info['homogenization'],
|
||||
'microstructures: %i'%info['microstructures'],
|
||||
])
|
||||
damask.util.report_geom(info)
|
||||
|
||||
errors = []
|
||||
if np.any(info['grid'] < 1): errors.append('invalid grid a b c.')
|
||||
|
|
|
@ -73,13 +73,7 @@ for name in filenames:
|
|||
|
||||
table.head_read()
|
||||
info,extra_header = table.head_getGeom()
|
||||
|
||||
damask.util.croak(['grid a b c: %s'%(' x '.join(map(str,info['grid']))),
|
||||
'size x y z: %s'%(' x '.join(map(str,info['size']))),
|
||||
'origin x y z: %s'%(' : '.join(map(str,info['origin']))),
|
||||
'homogenization: %i'%info['homogenization'],
|
||||
'microstructures: %i'%info['microstructures'],
|
||||
])
|
||||
damask.util.report_geom(info)
|
||||
|
||||
errors = []
|
||||
if np.any(info['grid'] < 1): errors.append('invalid grid a b c.')
|
||||
|
@ -108,7 +102,7 @@ for name in filenames:
|
|||
extra_keywords={"trigger":options.trigger,"size":1+2*options.vicinity}),
|
||||
microstructure + options.offset,microstructure)
|
||||
|
||||
newInfo['microstructures'] = microstructure.max()
|
||||
newInfo['microstructures'] = len(np.unique(microstructure))
|
||||
|
||||
# --- report ---------------------------------------------------------------------------------------
|
||||
|
||||
|
@ -131,9 +125,9 @@ for name in filenames:
|
|||
|
||||
# --- write microstructure information ------------------------------------------------------------
|
||||
|
||||
formatwidth = int(math.floor(math.log10(microstructure.max())+1))
|
||||
formatwidth = int(math.floor(math.log10(np.nanmax(microstructure))+1))
|
||||
table.data = microstructure.reshape((info['grid'][0],info['grid'][1]*info['grid'][2]),order='F').transpose()
|
||||
table.data_writeArray('%%%ii'%(formatwidth),delimiter = ' ')
|
||||
table.data_writeArray('%{}i'.format(formatwidth),delimiter = ' ')
|
||||
|
||||
# --- output finalization --------------------------------------------------------------------------
|
||||
|
||||
|
|
Loading…
Reference in New Issue