added option to label microstructure.
updated to most recent asciitable/damask.util infrastructure.
This commit is contained in:
parent
0db4a7fad0
commit
cee9a345b7
|
@ -15,7 +15,7 @@ scriptName = os.path.splitext(scriptID.split()[1])[0]
|
|||
#--------------------------------------------------------------------------------------------------
|
||||
|
||||
parser = OptionParser(option_class=damask.extendableOption, usage='%prog [geomfile[s]]', description = """
|
||||
Produce ASCIItable of structure data from geom description
|
||||
Translate geom description into ASCIItable containing 1/2/3_pos and microstructure.
|
||||
|
||||
""", version = scriptID)
|
||||
|
||||
|
@ -23,8 +23,13 @@ parser.add_option('-p','--position',
|
|||
dest = 'position',
|
||||
type = 'string', metavar = 'string',
|
||||
help = 'column label for position [%default]')
|
||||
parser.add_option('-m','--microstructure',
|
||||
dest = 'microstructure',
|
||||
type = 'string', metavar = 'string',
|
||||
help = 'column label for microstructure index [%default]')
|
||||
|
||||
parser.set_defaults(position = 'pos',
|
||||
microstructure = 'microstructure',
|
||||
)
|
||||
|
||||
(options, filenames) = parser.parse_args()
|
||||
|
@ -39,25 +44,25 @@ for name in filenames:
|
|||
outname = os.path.splitext(name)[0]+'.txt' if name else name,
|
||||
buffered = False, labeled = False)
|
||||
except: continue
|
||||
table.croak('\033[1m'+scriptName+'\033[0m'+(': '+name if name else ''))
|
||||
damask.util.report(scriptName,name)
|
||||
|
||||
# --- interpret header ----------------------------------------------------------------------------
|
||||
|
||||
table.head_read()
|
||||
info,extra_header = table.head_getGeom()
|
||||
|
||||
table.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.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'],
|
||||
])
|
||||
|
||||
errors = []
|
||||
if np.any(info['grid'] < 1): errors.append('invalid grid a b c.')
|
||||
if np.any(info['size'] <= 0.0): errors.append('invalid size x y z.')
|
||||
if errors != []:
|
||||
table.croak(errors)
|
||||
damask.util.croak(errors)
|
||||
table.close(dismiss = True)
|
||||
continue
|
||||
|
||||
|
@ -70,7 +75,7 @@ for name in filenames:
|
|||
table.info_clear()
|
||||
table.info_append(extra_header + [scriptID + '\t' + ' '.join(sys.argv[1:])])
|
||||
table.labels_clear()
|
||||
table.labels_append(['{dim}_{label}'.format(dim = 1+i,label = options.position) for i in range(3)]+['microstructure'])
|
||||
table.labels_append(['{}_{}'.format(1+i,options.position) for i in xrange(3)]+[options.microstructure])
|
||||
table.head_write()
|
||||
table.output_flush()
|
||||
|
||||
|
|
Loading…
Reference in New Issue