Changeset 263
 Timestamp:
 Mar 13, 2011 2:02:45 PM (12 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/GSASIIimage.py
r262 r263 60 60 if delta: 61 61 err,parms = FitEllipse(ring) 62 errc,parmsc = FitCircle(ring)63 errc = errc[0]/(len(ring)*parmsc[2][0]**2)64 # print 'Ellipse?',err,parms,len(ring) 65 # print 'Circle? ',errc,parmsc66 if not parms or errc < .1:67 parms = parmsc62 errc,parmsc = FitCircle(ring) 63 errc = errc[0]/(len(ring)*parmsc[2][0]**2) 64 if not parms or errc < .1: 65 parms = parmsc 66 else: 67 err,parms = FitCircle(ring) 68 68 return parms 69 69 … … 182 182 X = (cphi*xsphi*y+cent[0])*scalex #convert mm to pixels 183 183 Y = (sphi*x+cphi*y+cent[1])*scaley 184 X,Y,I,J = ImageLocalMax(image,pix,X,Y) 184 X,Y,I,J = ImageLocalMax(image,pix,X,Y) 185 185 if I and J and I/J > reject: 186 186 X += .5 #set to center of pixel … … 191 191 amax = max(amax,a) 192 192 ring.append([X,Y,dsp]) 193 delt = amaxamin 193 194 if len(ring) < 20: #want more than 20 deg 194 return [], amaxamin195 return ring, amaxamin> 90195 return [],delt > 90 196 return ring,delt > 90 196 197 197 198 def makeIdealRing(ellipse,azm=None): … … 316 317 else: 317 318 return image[::scale,::scale] 319 320 def checkEllipse(Zsum,distSum,xSum,ySum,dist,x,y): 321 avg = np.array([distSum/Zsum,xSum/Zsum,ySum/Zsum]) 322 curr = np.array([dist,x,y]) 323 return abs(avgcurr)/avg < .02 324 318 325 319 326 def ImageCalibrate(self,data): … … 412 419 dist = calcDist(radii,tth) 413 420 distR = 1.dist/data['distance'] 414 if abs(distR) > 0.01: 415 continue 421 if abs(distR) > 0.1: 422 print dsp,dist,data['distance'],distR,len(Ring),delt 423 break 416 424 if distR > 0.001: 417 425 print 'Wavelength too large?' … … 420 428 else: 421 429 ellipse = newellipse 422 if abs((radii[1]/radii[0]ratio)/ratio) > 0.1:423 print 'Bad fit for ring # %i. Try reducing Pixel search range'%(i)424 return False430 # if abs((radii[1]/radii[0]ratio)/ratio) > 0.1: 431 # print 'Bad fit for ring # %i. Try reducing Pixel search range'%(i) 432 # return False 425 433 zdis,cosB = calcZdisCosB(radius,tth,radii) 426 434 Tilt = acosd(cosB) # 0 <= tilt <= 90 … … 442 450 ySum += numZ*data['center'][1] 443 451 tiltSum += numZ*abs(Tilt) 452 if not np.all(checkEllipse(Zsum,distSum,xSum,ySum,dist,data['center'][0],data['center'][1])): 453 print 'Bad ellipse. Try reducing Pixel search range' 444 454 cent = data['center'] 445 print ('for ring # %2i dist %.3f rotate %6.2f tilt %6.2f Xcent %.3f Ycent %.3f Npts %d'446 %(i,d ist,phi,Tilt,cent[0],cent[1],numZ))455 print ('for ring # %2i @ dspace %.4f: dist %.3f rotate %6.2f tilt %6.2f Xcent %.3f Ycent %.3f Npts %d' 456 %(i,dsp,dist,phi,Tilt,cent[0],cent[1],numZ)) 447 457 data['ellipses'].append(copy.deepcopy(ellipse+('r',))) 448 458 else:
Note: See TracChangeset
for help on using the changeset viewer.