Changeset 47
 Timestamp:
 Apr 5, 2010 11:17:25 AM (14 years ago)
 Location:
 trunk
 Files:

 1 deleted
 2 edited
Legend:
 Unmodified
 Added
 Removed

trunk/GSASIIcomp.py
r46 r47 31 31 # this error is nonrecoverable, so just quit 32 32 exit() 33 import fitellipse as fte34 33 import GSASIIplot as G2plt 35 34 … … 1208 1207 1209 1208 def FitEllipse(ring): 1210 N = len(ring)1211 A = np.zeros(shape=(N,5),order='F',dtype=np.float32)1212 B = np.zeros(shape=N,dtype=np.float32)1213 X = np.zeros(shape=N,dtype=np.float32)1214 Y = np.zeros(shape=N,dtype=np.float32)1215 for i,(x,y) in enumerate(ring):1216 X[i] = x1217 Y[i] = y1218 B ,Krank,Rnorm = fte.fitqdr(N,A,B,X,Y)1209 from scipy.optimize import leastsq 1210 def ellipseCalc(A,xy): 1211 x = xy[0] 1212 y = xy[1] 1213 return (1.+A[0])*x**2+(1.A[0])*y**2+A[1]*x*y+A[2]*x+A[3]*y+A[4] 1214 ring = np.array(ring) 1215 p0 = np.zeros(shape=5) 1216 result = leastsq(ellipseCalc,p0,args=(ring.T,)) 1217 B = result[0] 1219 1218 1220 1219 ell = [1.+B[0],B[1],1.B[0],B[2],B[3],B[4]] … … 1244 1243 phi += 180. 1245 1244 return cent,phi,[sr1,sr2] 1246 1247 def FitCircle(ring): 1248 N = len(ring) 1249 A = np.zeros(shape=(N,3),order='F',dtype=np.float32) 1250 B = np.zeros(shape=N,dtype=np.float32) 1251 X = np.zeros(shape=N,dtype=np.float32) 1252 Y = np.zeros(shape=N,dtype=np.float32) 1253 for i,(x,y) in enumerate(ring): 1254 X[i] = x 1255 Y[i] = y 1256 B,Krank,Rnorm = fte.fitcrc(N,A,B,X,Y) 1257 cent = (0.5*B[0],0.5*B[1]) 1258 R2 = cent[0]**2+cent[1]**2B[2] 1259 if R2 > 0.0: 1260 radius = math.sqrt(R2) 1261 else: 1262 return 0 1263 return cent,radius 1264 1245 1265 1246 def ImageLocalMax(image,w,Xpix,Ypix): 1266 1247 w2 = w*2 … … 1357 1338 return GetTthDspAzm(x,y,data)[1] 1358 1339 1359 def GetDetector(data):1360 return1361 1362 1340 def ImageCompress(image,scale): 1363 1341 if scale == 1: … … 1453 1431 if Ring: 1454 1432 numZ = len(Ring) 1455 data['rings'].append(np. array(Ring))1433 data['rings'].append(np.column_stack((np.array(Ring),dsp*np.ones(numZ)))) 1456 1434 elcent,phi,radii = ellipse = FitEllipse(Ring) 1457 1435 if abs(phi) > 45. and phi < 0.: … … 1512 1490 t2 = d2/len2 1513 1491 if len2 > len1: 1514 print 'len2 > len1'1515 1492 if 135. < atan2d(t2[1],t2[0]) < 45.: 1516 1493 Zsign = 1 1517 1494 else: 1518 print 'len2 < len1'1519 1495 if 135. < atan2d(t1[1],t1[0]) < 45.: 1520 1496 Zsign = 1 … … 1522 1498 tilt = data['tilt'] = Zsign*tiltSum/Zsum 1523 1499 phi = data['rotation'] = phiSum/Zsum 1500 rings = np.concatenate((data['rings']),axis=0) 1501 print wave,dist,cent,phi,tilt 1502 1503 1524 1504 N = len(data['ellipses']) 1525 1505 for H in HKL[:N]: 
trunk/GSASIIplot.py
r40 r47 363 363 imgPlot.text(xring,yring,'+',color='b',ha='center',va='center',picker=3) 364 364 if Data['setRings']: 365 for ring in Data['rings']:366 for xring,yring in ring:367 365 rings = Data['rings'] 366 for xring,yring,tth in rings: 367 imgPlot.text(xring,yring,'+',ha='center',va='center') 368 368 for ellipse in Data['ellipses']: 369 369 cent,phi,[width,height],col = ellipse
Note: See TracChangeset
for help on using the changeset viewer.