bug fixes

This commit is contained in:
Pratheek Shanthraj 2012-12-07 17:41:50 +00:00
parent eaf7072bc1
commit c4ef2e5925
1 changed files with 13 additions and 8 deletions

View File

@ -1,6 +1,6 @@
#!/usr/bin/env python #!/usr/bin/env python
import os,re,sys,math,numpy,skfmm,string,damask import os,re,sys,math,numpy,skfmm,string,damask,time
from scipy import ndimage from scipy import ndimage
from optparse import OptionParser, Option from optparse import OptionParser, Option
@ -164,6 +164,8 @@ for file in files:
# ------------------------------------------ process data --------------------------------------- # ------------------------------------------ process data ---------------------------------------
cputime = time.clock()
structure = table.data_asArray(['ip.x','ip.y','ip.z',options.id]) structure = table.data_asArray(['ip.x','ip.y','ip.z',options.id])
grid = [{},{},{}] grid = [{},{},{}]
@ -180,9 +182,6 @@ for file in files:
convoluted = numpy.empty([len(neighborhood)]+list(resolution+2),'i') convoluted = numpy.empty([len(neighborhood)]+list(resolution+2),'i')
microstructure = periodic_3Dpad(numpy.array(structure[:,3].reshape(resolution),'i')) microstructure = periodic_3Dpad(numpy.array(structure[:,3].reshape(resolution),'i'))
print 'setup | time = '+repr(time.clock()-cputime)
cputime = time.clock()
for i,p in enumerate(neighborhood): for i,p in enumerate(neighborhood):
stencil = numpy.zeros((3,3,3),'i') stencil = numpy.zeros((3,3,3),'i')
stencil[1,1,1] = -1 stencil[1,1,1] = -1
@ -194,10 +193,13 @@ for file in files:
distance = numpy.ones((len(feature_list),resolution[0],resolution[1],resolution[2]),'d') distance = numpy.ones((len(feature_list),resolution[0],resolution[1],resolution[2]),'d')
uniques = numpy.ones(resolution) convoluted = numpy.sort(convoluted,axis=0)
uniques = numpy.zeros(resolution)
counter = numpy.empty(resolution)
counter[:,:,:] = numpy.nan
for i in xrange(len(neighborhood)): for i in xrange(len(neighborhood)):
for j in xrange(len(neighborhood)): uniques += numpy.where(convoluted[i,1:-1,1:-1,1:-1] == counter,0,1)
uniques += numpy.where(convoluted[i,1:-1,1:-1,1:-1] == convoluted[j,1:-1,1:-1,1:-1],1,0) counter = convoluted[i,1:-1,1:-1,1:-1]
for i,feature_id in enumerate(feature_list): for i,feature_id in enumerate(feature_list):
distance[i,:,:,:] = numpy.where(uniques > features[feature_id]['aliens'],0.0,1.0) distance[i,:,:,:] = numpy.where(uniques > features[feature_id]['aliens'],0.0,1.0)
@ -221,3 +223,6 @@ for file in files:
file['input'].close() # close input ASCII table file['input'].close() # close input ASCII table
file['output'].close() # close output ASCII table file['output'].close() # close output ASCII table
os.rename(file['name']+'_tmp',file['name']) # overwrite old one with tmp new os.rename(file['name']+'_tmp',file['name']) # overwrite old one with tmp new
print 'write | time = '+repr(time.clock()-cputime)
cputime = time.clock()