Changeset 1180
- Timestamp:
- Jan 2, 2014 11:38:59 AM (9 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIimage.py
r1179 r1180 872 872 for ring in StrSta['d-zero']: #get observed x,y,d points for the d-zeros 873 873 ellipse = GetEllipse(ring['Dset'],StaControls) 874 Ring = makeRing(ring['Dset'],ellipse,ring['pixLimit'],ring['cutoff'],scalex,scaley,Image) 875 Ring = np.array(Ring).T 874 Ring = np.array(makeRing(ring['Dset'],ellipse,ring['pixLimit'],ring['cutoff'],scalex,scaley,Image)).T 876 875 ring['ImxyObs'] = np.array(Ring[:2]) #need to apply masks to this to eliminate bad points 877 Ring[:2] = GetTthAzm(Ring[0],Ring[1],StaControls) #convert x,y to tth,azm 876 ring['ImtaObs'] = GetTthAzm(Ring[0],Ring[1],StaControls) #convert x,y to tth,azm 877 ring['ImtaCalc'] = np.zeros_like(ring['ImtaObs']) 878 878 Ring[0] /= 2. #convert to theta 879 879 if len(rings): … … 883 883 E = StrSta['strain'] 884 884 p0 = [E[0][0],E[1][1],E[2][2],E[0][1],E[0][2],E[1][2]] 885 E = FitStrain(rings,p0,wave,phi) 885 E,dth = FitStrain(rings,p0,wave,phi) 886 for ring in StrSta['d-zero']: 887 th,azm = ring['ImtaObs'] 888 th0 = npasind(wave/(2.*ring['Dset'])) 889 V = np.sum(np.sum(E*calcFij(90.,phi,azm,th0).T,axis=2),axis=1) 890 dth = 180.*V/(np.pi*10e6) #in degrees & microstrain units 891 ring['ImtaCalc'] = np.array([(th0-dth)/2,azm]) 886 892 StrSta['strain'] = E 887 893 … … 891 897 Uses parameters as defined by Bob He & Kingsley Smith, Adv. in X-Ray Anal. 41, 501 (1997) 892 898 893 :param omg: his omega = sample omega rotation; 0 when incident beam || sample surface, 90 when perp. to sample surface 899 :param omg: his omega = sample omega rotation; 0 when incident beam || sample surface, 900 90 when perp. to sample surface 894 901 :param phi: his phi = sample phi rotation; usually = 0, axis rotates with omg. 895 902 :param azm: his chi = azimuth around incident beam … … 930 937 th,azm,dsp = xyd 931 938 th0 = npasind(wave/(2.*dsp)) 932 dth = 180.*np.sum(E*calcFij(phi,0.,azm,th).T)/(np.pi*1.e6) #in degrees & microstrain units 939 V = np.sum(np.sum(E*calcFij(90.,phi,azm,th).T,axis=2),axis=1) 940 dth = 180.*V/(np.pi*10e6) #in degrees & microstrain units 933 941 th0 += dth 934 return (th-th0)**2942 return th-th0 935 943 936 944 names = ['e11','e22','e33','e12','e13','e23'] 937 945 fmt = ['%12.2f','%12.2f','%12.2f','%12.2f','%12.2f','%12.5f'] 938 p1 = [ p0[0],p0[1]]946 p1 = [1,-1] 939 947 result = leastsq(strainCalc,p1,args=(rings,wave,phi),full_output=True) 940 948 vals = list(result[0]) … … 944 952 StrainPrint(ValSig) 945 953 # return np.array([[vals[0],vals[3],vals[4]],[vals[3],vals[1],vals[5]],[vals[4],vals[5],vals[2]]]) 946 return np.array([[vals[0],0,0],[0,vals[1],0],[0,0,0]]) 947 948 954 return np.array([[vals[0],0,0],[0,vals[1],0],[0,0,0]]),result[2]['fvec'] 955 956 -
trunk/GSASIIimgGUI.py
r1174 r1180 1395 1395 G2gd.GetPatternTreeItemId(G2frame,G2frame.Image, 'Image Controls')) 1396 1396 G2img.FitStrSta(G2frame.ImageZ,data,Controls,Masks) 1397 UpdateStressStrain(G2frame,data) 1397 1398 G2plt.PlotExposedImage(G2frame,event=event) 1399 G2plt.PlotStrain(G2frame,data,newPlot=False,type='Strain') 1398 1400 1399 1401 def SamSizer(): -
trunk/GSASIIplot.py
r1163 r1180 1193 1193 ################################################################################ 1194 1194 1195 def PlotXY(G2frame,XY, newPlot=False,type=''):1195 def PlotXY(G2frame,XY,XY2=None,labelX=None,labelY=None,newPlot=False,type=''): 1196 1196 '''simple plot of xy data, used for diagnostic purposes 1197 1197 ''' … … 1225 1225 G2frame.G2plotNB.status.DestroyChildren() 1226 1226 Plot.set_title(type) 1227 Plot.set_xlabel(r'X',fontsize=14) 1228 Plot.set_ylabel(r''+type,fontsize=14) 1227 if xLabel: 1228 Plot.set_xlabel(r''+xLabel,fontsize=14) 1229 else: 1230 Plot.set_xlabel(r'X',fontsize=14) 1231 if yLabel: 1232 Plot.set_ylabel(r''+yLabel,fontsize=14) 1233 else: 1234 Plot.set_ylabel(r'Y',fontsize=14) 1229 1235 colors=['b','g','r','c','m','k'] 1230 Ymax = 1.0 1231 lenX = 0 1232 X,Y = XY[:2] 1233 Ymax = max(Ymax,max(Y)) 1234 Plot.plot(X,Y,'k',picker=False) 1236 for ixy,xy in enumerate(XY): 1237 X,Y = xy 1238 Plot.plot(X,Y,color(ixy%6)+'+',picker=False) 1239 if len(XY2): 1240 for ixy,xy in enumerate(XY2): 1241 X,Y = xy 1242 Plot.plot(X,Y,color(ixy%6),picker=False) 1243 if not newPlot: 1244 Page.toolbar.push_current() 1245 Plot.set_xlim(xylim[0]) 1246 Plot.set_ylim(xylim[1]) 1247 xylim = [] 1248 Page.toolbar.push_current() 1249 Page.toolbar.draw() 1250 else: 1251 Page.canvas.draw() 1252 1253 ################################################################################ 1254 ##### PlotStrain 1255 ################################################################################ 1256 1257 def PlotStrain(G2frame,data,newPlot=False,type=''): 1258 '''plot of strain data, used for diagnostic purposes 1259 ''' 1260 def OnMotion(event): 1261 xpos = event.xdata 1262 if xpos: #avoid out of frame mouse position 1263 ypos = event.ydata 1264 Page.canvas.SetCursor(wx.CROSS_CURSOR) 1265 try: 1266 G2frame.G2plotNB.status.SetStatusText('X =%9.3f %s =%9.3f'%(xpos,type,ypos),1) 1267 except TypeError: 1268 G2frame.G2plotNB.status.SetStatusText('Select '+type+' pattern first',1) 1269 1270 try: 1271 plotNum = G2frame.G2plotNB.plotList.index(type) 1272 Page = G2frame.G2plotNB.nb.GetPage(plotNum) 1273 if not newPlot: 1274 Plot = Page.figure.gca() 1275 xylim = Plot.get_xlim(),Plot.get_ylim() 1276 Page.figure.clf() 1277 Plot = Page.figure.gca() 1278 except ValueError: 1279 newPlot = True 1280 Plot = G2frame.G2plotNB.addMpl(type).gca() 1281 plotNum = G2frame.G2plotNB.plotList.index(type) 1282 Page = G2frame.G2plotNB.nb.GetPage(plotNum) 1283 Page.canvas.mpl_connect('motion_notify_event', OnMotion) 1284 1285 Page.Choice = None 1286 Page.SetFocus() 1287 G2frame.G2plotNB.status.DestroyChildren() 1288 Plot.set_title(type) 1289 Plot.set_xlabel(r'$\mathsf{2\theta}$',fontsize=14) 1290 Plot.set_ylabel(r'Azimuth',fontsize=14) 1291 colors=['b','g','r','c','m','k'] 1292 for N,item in enumerate(data['d-zero']): 1293 X,Y = np.array(item['ImtaObs']) 1294 Plot.plot(X,Y,colors[N%6]+'+',picker=False) 1295 X,Y = np.array(item['ImtaCalc']) 1296 Plot.plot(X,Y,colors[N%6],picker=False) 1235 1297 if not newPlot: 1236 1298 Page.toolbar.push_current() … … 2534 2596 if G2frame.PatternTree.GetItemText(G2frame.PickId) in 'Stress/Strain': 2535 2597 print 'plot stress/strain stuff' 2536 for ring in StrSta['d-zero']:2598 for N,ring in enumerate(StrSta['d-zero']): 2537 2599 xring,yring = ring['ImxyObs'] 2538 Plot.plot(xring,yring, 'r+')2539 # for xring,yring in ring['ImxyCalc'].T:2540 #Plot.add_artist(Polygon(ring['ImxyCalc'].T,ec='b',fc='none'))2541 #Plot.plot(xring,yring)2600 Plot.plot(xring,yring,colors[N%6]+'+') 2601 for xring,yring in np.array(ring['ImxyCalc']).T: 2602 Plot.add_artist(Polygon(ring['ImxyCalc'].T,ec='b',fc='none')) 2603 Plot.plot(xring,yring) 2542 2604 #masks - mask lines numbered after integration limit lines 2543 2605 spots = Masks['Points']
Note: See TracChangeset
for help on using the changeset viewer.