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:
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)
except: continue
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:
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)
except: continue
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']
for name in filenames:
if not (name == 'STDIN' or os.path.exists(name)): continue
table = damask.ASCIItable(name = name, outname = os.path.splitext(name)[0]+'.txt',
try:
table = damask.ASCIItable(name = name,
outname = os.path.splitext(name)[0]+'.txt' if name else name,
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 ----------------------------------------------------------------------------

View File

@ -47,7 +47,8 @@ if filenames == []: filenames = [None]
for name in filenames:
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)
except:
continue

View File

@ -59,10 +59,12 @@ if options.blacklist != None: options.blacklist = map(int,options.blacklist)
if filenames == []: filenames = ['STDIN']
for name in filenames:
if not (name == 'STDIN' or os.path.exists(name)): continue
table = damask.ASCIItable(name = name, outname = os.path.splitext(name)[0]+'.seeds',
try:
table = damask.ASCIItable(name = name,
outname = os.path.splitext(name)[0]+'.seeds' if name else name,
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
@ -98,7 +100,6 @@ for name in filenames:
table.data[:,0:3] -= boundingBox[0,:]
table.data[:,0:3] /= boundingBox[1,:]-boundingBox[0,:]
# --- filtering of grain voxels --------------------------------------------------------------------
mask = np.logical_and(\
@ -111,8 +112,6 @@ for name in filenames:
)
table.data = table.data[mask]
# ------------------------------------------ output result ---------------------------------------
# ------------------------------------------ assemble header ---------------------------------------
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.head_write()
# ------------------------------------------ output result ---------------------------------------
table.data_writeArray()
table.close() # close ASCII tables