switch to new ASCII table class was buggy, using damask.util.emph
This commit is contained in:
parent
eb5ad7528f
commit
6100185855
|
@ -42,7 +42,7 @@ for name in filenames:
|
||||||
table = damask.ASCIItable(name = name, buffered = False)
|
table = damask.ASCIItable(name = name, buffered = False)
|
||||||
except:
|
except:
|
||||||
continue
|
continue
|
||||||
table.croak('\033[1m'+scriptName+'\033[0m'+(': '+name if name else ''))
|
table.croak(damask.util.emph(scriptName)+(': '+name if name else ''))
|
||||||
|
|
||||||
# ------------------------------------------ read header ------------------------------------------
|
# ------------------------------------------ read header ------------------------------------------
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,7 @@ for name in filenames:
|
||||||
table = damask.ASCIItable(name = name,
|
table = damask.ASCIItable(name = name,
|
||||||
buffered = False)
|
buffered = False)
|
||||||
except: continue
|
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 ------------------------------------------
|
# ------------------------------------------ read header ------------------------------------------
|
||||||
|
|
||||||
|
@ -98,14 +98,17 @@ for name in filenames:
|
||||||
|
|
||||||
# ------------------------------------------ process deformation gradient --------------------------
|
# ------------------------------------------ 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)
|
Favg = damask.core.math.tensorAvg(F)
|
||||||
centres = damask.core.mesh.deformedCoordsFFT(size,F,Favg,[1.0,1.0,1.0])
|
centres = damask.core.mesh.deformedCoordsFFT(size,F,Favg,[1.0,1.0,1.0])
|
||||||
nodes = damask.core.mesh.nodesAroundCentres(size,Favg,centres)
|
nodes = damask.core.mesh.nodesAroundCentres(size,Favg,centres)
|
||||||
|
|
||||||
stack = [table.data]
|
stack =[table.data]
|
||||||
if options.shape: stack.append(damask.core.mesh.shapeMismatch( size,F,nodes,centres))
|
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))
|
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 -----------------------------------------
|
# ------------------------------------------ output result -----------------------------------------
|
||||||
|
|
||||||
|
|
|
@ -97,7 +97,7 @@ for name in filenames:
|
||||||
table = damask.ASCIItable(name = name,buffered = False)
|
table = damask.ASCIItable(name = name,buffered = False)
|
||||||
except:
|
except:
|
||||||
continue
|
continue
|
||||||
table.croak('\033[1m'+scriptName+'\033[0m'+(': '+name if name else ''))
|
table.croak(damask.util.emph(scriptName)+(': '+name if name else ''))
|
||||||
|
|
||||||
# ------------------------------------------ read header ------------------------------------------
|
# ------------------------------------------ read header ------------------------------------------
|
||||||
|
|
||||||
|
|
|
@ -129,7 +129,7 @@ for name in filenames:
|
||||||
table = damask.ASCIItable(name = name, buffered = False)
|
table = damask.ASCIItable(name = name, buffered = False)
|
||||||
except:
|
except:
|
||||||
continue
|
continue
|
||||||
table.croak('\033[1m'+scriptName+'\033[0m'+(': '+name if name else ''))
|
table.croak(damask.util.emph(scriptName)+(': '+name if name else ''))
|
||||||
|
|
||||||
# ------------------------------------------ read header ------------------------------------------
|
# ------------------------------------------ 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,:,:,:] = 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[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)):
|
for i in xrange(len(feature_list)):
|
||||||
stack.append(distance[i,:])
|
stack.append(distance[i,:])
|
||||||
|
|
||||||
|
|
|
@ -230,14 +230,6 @@ def normalize(x):
|
||||||
|
|
||||||
return [x[i]/norm for i in range(len(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
|
# MAIN
|
||||||
# --------------------------------------------------------------------
|
# --------------------------------------------------------------------
|
||||||
|
@ -307,21 +299,17 @@ if options.lattice=='hex':
|
||||||
slipnormal[options.lattice][i]=normalize(slipnormal[options.lattice][i])
|
slipnormal[options.lattice][i]=normalize(slipnormal[options.lattice][i])
|
||||||
slipdirection[options.lattice][i]=normalize(slipdirection[options.lattice][i])
|
slipdirection[options.lattice][i]=normalize(slipdirection[options.lattice][i])
|
||||||
|
|
||||||
# ------------------------------------------ setup file handles ------------------------------------
|
# --- loop over input files -------------------------------------------------------------------------
|
||||||
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 ---------------------------------
|
if filenames == []: filenames = [None]
|
||||||
for file in files:
|
|
||||||
if file['name'] != 'STDIN': file['croak'].write('\033[1m'+scriptName+'\033[0m: '+file['name']+'\n')
|
for name in filenames:
|
||||||
else: file['croak'].write('\033[1m'+scriptName+'\033[0m\n')
|
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.head_read() # read ASCII header info
|
||||||
table.info_append(scriptID + '\t' + ' '.join(sys.argv[1:]))
|
table.info_append(scriptID + '\t' + ' '.join(sys.argv[1:]))
|
||||||
|
|
||||||
|
@ -362,7 +350,7 @@ for file in files:
|
||||||
for slipsystem in range(Nslipsystems[options.lattice]) ]
|
for slipsystem in range(Nslipsystems[options.lattice]) ]
|
||||||
table.data_append(S)
|
table.data_append(S)
|
||||||
if options.traceplane:
|
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]) ]
|
for slipsystem in range(Nslipsystems[options.lattice]) ]
|
||||||
if options.rank == 0:
|
if options.rank == 0:
|
||||||
table.data_append('\t'.join(map(lambda x:'%f\t%f\t%f'%(x[0],x[1],x[2]),trace)))
|
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]))
|
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
|
outputAlive = table.data_write() # output processed line
|
||||||
|
|
||||||
# ------------------------------------------ output result -----------------------------------------
|
# ------------------------------------------ output finalization -----------------------------------
|
||||||
outputAlive and table.output_flush() # just in case of buffered ASCII table
|
|
||||||
|
|
||||||
table.input_close() # close input ASCII table (works for stdin)
|
table.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
|
|
||||||
|
|
Loading…
Reference in New Issue