some comments
This commit is contained in:
parent
bf108ee09f
commit
643f7fe934
|
@ -120,7 +120,7 @@ class myThread (threading.Thread):
|
||||||
currentHist.append(np.histogram(currentData,bins=target[i]['bins'])[0])
|
currentHist.append(np.histogram(currentData,bins=target[i]['bins'])[0])
|
||||||
currentError.append(np.sqrt(np.square(np.array(target[i]['histogram']-currentHist[i])).sum()))
|
currentError.append(np.sqrt(np.square(np.array(target[i]['histogram']-currentHist[i])).sum()))
|
||||||
|
|
||||||
s.acquire()
|
s.acquire() # do the evaluation serially
|
||||||
bestMatch = match
|
bestMatch = match
|
||||||
#--- count bin classes with no mismatch ----------------------------------------------------------------------
|
#--- count bin classes with no mismatch ----------------------------------------------------------------------
|
||||||
myMatch=0
|
myMatch=0
|
||||||
|
@ -130,26 +130,26 @@ class myThread (threading.Thread):
|
||||||
|
|
||||||
if myNmicrostructures == nMicrostructures:
|
if myNmicrostructures == nMicrostructures:
|
||||||
for i in xrange(min(nMicrostructures,myMatch+options.bins)):
|
for i in xrange(min(nMicrostructures,myMatch+options.bins)):
|
||||||
if currentError[i] > target[i]['error']:
|
if currentError[i] > target[i]['error']: # worse fitting, next try
|
||||||
randReset = True
|
randReset = True
|
||||||
break
|
break
|
||||||
elif currentError[i] < target[i]['error']:
|
elif currentError[i] < target[i]['error']: # better fit
|
||||||
bestSeedsUpdate = time.time()
|
bestSeedsUpdate = time.time() # save time of better fit
|
||||||
print 'Thread %i: Better match (%i bins, %6.4f --> %6.4f)'%(self.threadID,i+1,target[i]['error'],currentError[i])
|
print 'Thread %i: Better match (%i bins, %6.4f --> %6.4f)'%(self.threadID,i+1,target[i]['error'],currentError[i])
|
||||||
print ' target: ',target[i]['histogram']
|
print ' target: ',target[i]['histogram']
|
||||||
print ' best: ',currentHist[i]
|
print ' best: ',currentHist[i]
|
||||||
currentSeedsName = baseFile+'_'+str(bestSeedsUpdate).replace('.','-')
|
currentSeedsName = baseFile+'_'+str(bestSeedsUpdate).replace('.','-') # name of new seed file (use time as unique identifier)
|
||||||
perturbedSeedsVFile.reset()
|
perturbedSeedsVFile.reset()
|
||||||
bestSeedsVFile.close()
|
bestSeedsVFile.close()
|
||||||
bestSeedsVFile = StringIO()
|
bestSeedsVFile = StringIO()
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
with open(currentSeedsName+'.seeds','w') as currentSeedsFile:
|
with open(currentSeedsName+'.seeds','w') as currentSeedsFile: # write to new file
|
||||||
for line in perturbedSeedsVFile:
|
for line in perturbedSeedsVFile:
|
||||||
currentSeedsFile.write(line)
|
currentSeedsFile.write(line)
|
||||||
bestSeedsVFile.write(line)
|
bestSeedsVFile.write(line)
|
||||||
for j in xrange(nMicrostructures):
|
for j in xrange(nMicrostructures): # save new errors for all bins
|
||||||
target[j]['error'] = currentError[j]
|
target[j]['error'] = currentError[j]
|
||||||
if myMatch > match:
|
if myMatch > match: # one or more bins have no deviation
|
||||||
print 'Stage %i cleared'%(myMatch)
|
print 'Stage %i cleared'%(myMatch)
|
||||||
match=myMatch
|
match=myMatch
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
|
|
Loading…
Reference in New Issue