switch to new ASCII table class was buggy, using damask.util.emph

This commit is contained in:
Martin Diehl 2015-08-31 11:00:45 +00:00
parent eb5ad7528f
commit 6100185855
5 changed files with 24 additions and 37 deletions

View File

@ -42,7 +42,7 @@ for name in filenames:
table = damask.ASCIItable(name = name, buffered = False)
except:
continue
table.croak('\033[1m'+scriptName+'\033[0m'+(': '+name if name else ''))
table.croak(damask.util.emph(scriptName)+(': '+name if name else ''))
# ------------------------------------------ read header ------------------------------------------

View File

@ -53,7 +53,7 @@ for name in filenames:
table = damask.ASCIItable(name = name,
buffered = False)
except: continue
table.croak('\033[1m'+scriptName+'\033[0m'+(': '+name if name else ''))
table.croak(damask.util.emph(scriptName)+(': '+name if name else ''))
# ------------------------------------------ read header ------------------------------------------
@ -98,14 +98,17 @@ for name in filenames:
# ------------------------------------------ process deformation gradient --------------------------
F = table.data[:,colF:colF+9].transpose().reshape([3,3]+list(options.dimension),order='F')
F = table.data[:,colF:colF+9].transpose().reshape([3,3]+grid.tolist(),order='F')
Favg = damask.core.math.tensorAvg(F)
centres = damask.core.mesh.deformedCoordsFFT(size,F,Favg,[1.0,1.0,1.0])
nodes = damask.core.mesh.nodesAroundCentres(size,Favg,centres)
stack = [table.data]
if options.shape: stack.append(damask.core.mesh.shapeMismatch( size,F,nodes,centres))
if options.volume: stack.append(damask.core.mesh.volumeMismatch(size,F,nodes))
stack =[table.data]
if options.shape: stack.append(damask.core.mesh.shapeMismatch( size,F,nodes,centres).reshape([grid.prod(),1]))
if options.volume: stack.append(damask.core.mesh.volumeMismatch(size,F,nodes).reshape([grid.prod(),1]))
for i in stack:
print i.shape
# ------------------------------------------ output result -----------------------------------------

View File

@ -97,7 +97,7 @@ for name in filenames:
table = damask.ASCIItable(name = name,buffered = False)
except:
continue
table.croak('\033[1m'+scriptName+'\033[0m'+(': '+name if name else ''))
table.croak(damask.util.emph(scriptName)+(': '+name if name else ''))
# ------------------------------------------ read header ------------------------------------------

View File

@ -129,7 +129,7 @@ for name in filenames:
table = damask.ASCIItable(name = name, buffered = False)
except:
continue
table.croak('\033[1m'+scriptName+'\033[0m'+(': '+name if name else ''))
table.croak(damask.util.emph(scriptName)+(': '+name if name else ''))
# ------------------------------------------ read header ------------------------------------------
@ -208,7 +208,7 @@ for name in filenames:
distance[i,:,:,:] = np.where(uniques >= features[feature_id]['aliens'],0.0,1.0) # seed with 0.0 when enough unique neighbor IDs are present
distance[i,:,:,:] = ndimage.morphology.distance_transform_edt(distance[i,:,:,:])*[options.scale]*3
distance.shape = (len(feature_list),grid.prod())
distance.shape = ([len(feature_list),grid.prod(),1])
for i in xrange(len(feature_list)):
stack.append(distance[i,:])

View File

@ -230,14 +230,6 @@ def normalize(x):
return [x[i]/norm for i in range(len(x))]
def crossproduct(x,y):
return [
x[1]*y[2]-y[1]*x[2],
x[2]*y[0]-y[2]*x[0],
x[0]*y[1]-y[0]*x[1],
]
# --------------------------------------------------------------------
# MAIN
# --------------------------------------------------------------------
@ -307,21 +299,17 @@ if options.lattice=='hex':
slipnormal[options.lattice][i]=normalize(slipnormal[options.lattice][i])
slipdirection[options.lattice][i]=normalize(slipdirection[options.lattice][i])
# ------------------------------------------ setup file handles ------------------------------------
files = []
if filenames == []:
files.append({'name':'STDIN', 'input':sys.stdin, 'output':sys.stdout, 'croak':sys.stderr})
else:
for name in filenames:
if os.path.exists(name):
files.append({'name':name, 'input':open(name), 'output':open(name+'_tmp','w'), 'croak':sys.stderr})
# --- loop over input files -------------------------------------------------------------------------
# ------------------------------------------ loop over input files ---------------------------------
for file in files:
if file['name'] != 'STDIN': file['croak'].write('\033[1m'+scriptName+'\033[0m: '+file['name']+'\n')
else: file['croak'].write('\033[1m'+scriptName+'\033[0m\n')
if filenames == []: filenames = [None]
for name in filenames:
try:
table = damask.ASCIItable(name = name,buffered = False)
except:
continue
table.croak(damask.util.emph(scriptName)+(': '+name if name else ''))
table = damask.ASCIItable(file['input'],file['output'],False) # make unbuffered ASCII_table
table.head_read() # read ASCII header info
table.info_append(scriptID + '\t' + ' '.join(sys.argv[1:]))
@ -362,7 +350,7 @@ for file in files:
for slipsystem in range(Nslipsystems[options.lattice]) ]
table.data_append(S)
if options.traceplane:
trace = [crossproduct(options.traceplane,applyEulers(phi1,Phi,phi2,normalize(slipnormal[options.lattice][slipsystem]))) \
trace = [np.cross(options.traceplane,applyEulers(phi1,Phi,phi2,normalize(slipnormal[options.lattice][slipsystem]))) \
for slipsystem in range(Nslipsystems[options.lattice]) ]
if options.rank == 0:
table.data_append('\t'.join(map(lambda x:'%f\t%f\t%f'%(x[0],x[1],x[2]),trace)))
@ -371,10 +359,6 @@ for file in files:
table.data_append('\t'.join(map(str,trace[SabsSorted[-options.rank][1]])) + '\t%i'%(1+SabsSorted[-options.rank][1]))
outputAlive = table.data_write() # output processed line
# ------------------------------------------ output result -----------------------------------------
outputAlive and table.output_flush() # just in case of buffered ASCII table
# ------------------------------------------ output finalization -----------------------------------
table.input_close() # close input ASCII table (works for stdin)
table.output_close() # close output ASCII table (works for stdout)
if file['name'] != 'STDIN':
os.rename(file['name']+'_tmp',file['name']) # overwrite old one with tmp new
table.close() # close input ASCII table (works for stdin)