added option to label microstructure.

updated to most recent asciitable/damask.util infrastructure.
This commit is contained in:
Philip Eisenlohr 2015-11-20 16:30:55 +00:00
parent 0db4a7fad0
commit cee9a345b7
1 changed files with 15 additions and 10 deletions

View File

@ -15,7 +15,7 @@ scriptName = os.path.splitext(scriptID.split()[1])[0]
#-------------------------------------------------------------------------------------------------- #--------------------------------------------------------------------------------------------------
parser = OptionParser(option_class=damask.extendableOption, usage='%prog [geomfile[s]]', description = """ 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) """, version = scriptID)
@ -23,8 +23,13 @@ parser.add_option('-p','--position',
dest = 'position', dest = 'position',
type = 'string', metavar = 'string', type = 'string', metavar = 'string',
help = 'column label for position [%default]') 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', parser.set_defaults(position = 'pos',
microstructure = 'microstructure',
) )
(options, filenames) = parser.parse_args() (options, filenames) = parser.parse_args()
@ -39,25 +44,25 @@ for name in filenames:
outname = os.path.splitext(name)[0]+'.txt' if name else name, outname = os.path.splitext(name)[0]+'.txt' if name else name,
buffered = False, labeled = False) buffered = False, labeled = False)
except: continue except: continue
table.croak('\033[1m'+scriptName+'\033[0m'+(': '+name if name else '')) damask.util.report(scriptName,name)
# --- interpret header ---------------------------------------------------------------------------- # --- interpret header ----------------------------------------------------------------------------
table.head_read() table.head_read()
info,extra_header = table.head_getGeom() info,extra_header = table.head_getGeom()
table.croak(['grid a b c: %s'%(' x '.join(map(str,info['grid']))), 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']))), 'size x y z: %s'%(' x '.join(map(str,info['size']))),
'origin x y z: %s'%(' : '.join(map(str,info['origin']))), 'origin x y z: %s'%(' : '.join(map(str,info['origin']))),
'homogenization: %i'%info['homogenization'], 'homogenization: %i'%info['homogenization'],
'microstructures: %i'%info['microstructures'], 'microstructures: %i'%info['microstructures'],
]) ])
errors = [] errors = []
if np.any(info['grid'] < 1): errors.append('invalid grid a b c.') 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 np.any(info['size'] <= 0.0): errors.append('invalid size x y z.')
if errors != []: if errors != []:
table.croak(errors) damask.util.croak(errors)
table.close(dismiss = True) table.close(dismiss = True)
continue continue
@ -70,7 +75,7 @@ for name in filenames:
table.info_clear() table.info_clear()
table.info_append(extra_header + [scriptID + '\t' + ' '.join(sys.argv[1:])]) table.info_append(extra_header + [scriptID + '\t' + ' '.join(sys.argv[1:])])
table.labels_clear() 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.head_write()
table.output_flush() table.output_flush()