fixed bug for STDIN processing

This commit is contained in:
Philip Eisenlohr 2015-08-12 21:28:07 +00:00
parent 1149053c61
commit dfbd2fd013
5 changed files with 20 additions and 14 deletions

View File

@ -36,7 +36,8 @@ if filenames == []: filenames = [None]
for name in filenames: for name in filenames:
try: try:
table = damask.ASCIItable(name = name, outname = os.path.splitext(name)[0] +'.geom', table = damask.ASCIItable(name = name,
outname = os.path.splitext(name)[0]+'.geom' 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 '')) table.croak('\033[1m'+scriptName+'\033[0m'+(': '+name if name else ''))

View File

@ -117,7 +117,8 @@ if filenames == []: filenames = [None]
for name in filenames: for name in filenames:
try: try:
table = damask.ASCIItable(name = name, outname = os.path.splitext(name)[0] + '.geom', table = damask.ASCIItable(name = name,
outname = os.path.splitext(name)[0]+'.geom' if name else name,
buffered = False) buffered = False)
except: continue except: continue
table.croak('\033[1m'+scriptName+'\033[0m'+(': '+name if name else '')) table.croak('\033[1m'+scriptName+'\033[0m'+(': '+name if name else ''))

View File

@ -34,10 +34,12 @@ parser.set_defaults(position = 'pos',
if filenames == []: filenames = ['STDIN'] if filenames == []: filenames = ['STDIN']
for name in filenames: for name in filenames:
if not (name == 'STDIN' or os.path.exists(name)): continue try:
table = damask.ASCIItable(name = name, outname = os.path.splitext(name)[0]+'.txt', table = damask.ASCIItable(name = name,
outname = os.path.splitext(name)[0]+'.txt' if name else name,
buffered = False, labeled = False) buffered = False, labeled = False)
table.croak('\033[1m'+scriptName+'\033[0m'+(': '+name if name != 'STDIN' else '')) except: continue
table.croak('\033[1m'+scriptName+'\033[0m'+(': '+name if name else ''))
# --- interpret header ---------------------------------------------------------------------------- # --- interpret header ----------------------------------------------------------------------------

View File

@ -47,7 +47,8 @@ if filenames == []: filenames = [None]
for name in filenames: for name in filenames:
try: try:
table = damask.ASCIItable(name = name, outname = os.path.splitext(name)[0]+'.seeds', table = damask.ASCIItable(name = name,
outname = os.path.splitext(name)[0]+'.seeds' if name else name,
buffered = False, labeled = False) buffered = False, labeled = False)
except: except:
continue continue

View File

@ -59,10 +59,12 @@ if options.blacklist != None: options.blacklist = map(int,options.blacklist)
if filenames == []: filenames = ['STDIN'] if filenames == []: filenames = ['STDIN']
for name in filenames: for name in filenames:
if not (name == 'STDIN' or os.path.exists(name)): continue try:
table = damask.ASCIItable(name = name, outname = os.path.splitext(name)[0]+'.seeds', table = damask.ASCIItable(name = name,
outname = os.path.splitext(name)[0]+'.seeds' if name else name,
buffered = False) buffered = False)
table.croak('\033[1m'+scriptName+'\033[0m'+(': '+name if name != 'STDIN' else '')) except: continue
table.croak('\033[1m'+scriptName+'\033[0m'+(': '+name if name else ''))
table.head_read() # read ASCII header info table.head_read() # read ASCII header info
@ -98,7 +100,6 @@ for name in filenames:
table.data[:,0:3] -= boundingBox[0,:] table.data[:,0:3] -= boundingBox[0,:]
table.data[:,0:3] /= boundingBox[1,:]-boundingBox[0,:] table.data[:,0:3] /= boundingBox[1,:]-boundingBox[0,:]
# --- filtering of grain voxels -------------------------------------------------------------------- # --- filtering of grain voxels --------------------------------------------------------------------
mask = np.logical_and(\ mask = np.logical_and(\
@ -111,8 +112,6 @@ for name in filenames:
) )
table.data = table.data[mask] table.data = table.data[mask]
# ------------------------------------------ output result ---------------------------------------
# ------------------------------------------ assemble header --------------------------------------- # ------------------------------------------ assemble header ---------------------------------------
table.info = [ table.info = [
@ -124,5 +123,7 @@ for name in filenames:
table.labels_append(['1_pos','2_pos','3_pos','microstructure']) # implicitly switching label processing/writing on table.labels_append(['1_pos','2_pos','3_pos','microstructure']) # implicitly switching label processing/writing on
table.head_write() table.head_write()
# ------------------------------------------ output result ---------------------------------------
table.data_writeArray() table.data_writeArray()
table.close() # close ASCII tables table.close() # close ASCII tables