Changeset 262
 Timestamp:
 Mar 11, 2011 4:16:46 PM (12 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/GSASIIimage.py
r261 r262 56 56 return np.roll(np.roll(M,Axis,axis=0),Axis,axis=1) 57 57 58 def FitRing(ring): 59 err,parms = FitEllipse(ring) 58 def FitRing(ring,delta): 59 parms = [] 60 if delta: 61 err,parms = FitEllipse(ring) 60 62 errc,parmsc = FitCircle(ring) 61 63 errc = errc[0]/(len(ring)*parmsc[2][0]**2) 62 # print 'Ellipse?',err,parms 64 # print 'Ellipse?',err,parms,len(ring) 63 65 # print 'Circle? ',errc,parmsc 64 66 if not parms or errc < .1: … … 155 157 def ImageLocalMax(image,w,Xpix,Ypix): 156 158 w2 = w*2 157 size = len(image)159 sizey,sizex = image.shape 158 160 xpix = int(Xpix) #get reference corner of pixel chosen 159 161 ypix = int(Ypix) 160 if (w < xpix < size w) and (w < ypix < sizew) and image[ypix,xpix]:162 if (w < xpix < sizexw) and (w < ypix < sizeyw) and image[ypix,xpix]: 161 163 Z = image[ypixw:ypix+w,xpixw:xpix+w] 162 164 Zmax = np.argmax(Z) … … 173 175 sphi = sind(phi) 174 176 ring = [] 177 amin = 180 178 amax = 180 175 179 for a in range(180,180,1): 176 180 x = radii[0]*cosd(a) … … 184 188 X /= scalex #convert to mm 185 189 Y /= scaley 190 amin = min(amin,a) 191 amax = max(amax,a) 186 192 ring.append([X,Y,dsp]) 187 193 if len(ring) < 20: #want more than 20 deg 188 return [] 189 return ring 194 return [],amaxamin 195 return ring,amaxamin > 90 190 196 191 197 def makeIdealRing(ellipse,azm=None): … … 328 334 #fit start points on inner ring 329 335 data['ellipses'] = [] 330 outE = FitRing(ring )336 outE = FitRing(ring,True) 331 337 if outE: 332 338 print 'start ellipse:',outE … … 336 342 337 343 #setup 360 points on that ring for "good" fit 338 Ring = makeRing(1.0,ellipse,pixLimit,cutoff,scalex,scaley,self.ImageZ)344 Ring,delt = makeRing(1.0,ellipse,pixLimit,cutoff,scalex,scaley,self.ImageZ) 339 345 if Ring: 340 ellipse = FitRing(Ring )341 Ring = makeRing(1.0,ellipse,pixLimit,cutoff,scalex,scaley,self.ImageZ) #do again342 ellipse = FitRing(Ring )346 ellipse = FitRing(Ring,delt) 347 Ring,delt = makeRing(1.0,ellipse,pixLimit,cutoff,scalex,scaley,self.ImageZ) #do again 348 ellipse = FitRing(Ring,delt) 343 349 else: 344 350 print '1st ring not sufficiently complete to proceed' … … 396 402 elcent = [cent[0]+zsinp,cent[1]zcosp] 397 403 ratio = radii[1]/radii[0] 398 Ring = makeRing(dsp,ellipse,pixLimit,cutoff,scalex,scaley,self.ImageZ)404 Ring,delt = makeRing(dsp,ellipse,pixLimit,cutoff,scalex,scaley,self.ImageZ) 399 405 if Ring: 400 406 numZ = len(Ring) 401 407 data['rings'].append(np.array(Ring)) 402 newellipse = FitRing(Ring )408 newellipse = FitRing(Ring,delt) 403 409 elcent,phi,radii = newellipse 404 410 if abs(phi) > 45. and phi < 0.: … … 407 413 distR = 1.dist/data['distance'] 408 414 if abs(distR) > 0.01: 409 # print distR,dist,data['distance']410 # del data['rings'][1]411 415 continue 412 416 if distR > 0.001:
Note: See TracChangeset
for help on using the changeset viewer.