Changeset 1731
- Timestamp:
- Mar 17, 2015 3:32:23 PM (9 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIddataGUI.py
r1727 r1731 80 80 Obj = event.GetEventObject() 81 81 generalData['Data plot type'] = Obj.GetStringSelection() 82 G2plt.PlotSizeStrainPO(G2frame,data,hist) 82 83 wx.CallLater(100,UpdateDData,G2frame,DData,data) 83 G2plt.PlotSizeStrainPO(G2frame,data)84 84 85 85 def OnPOhkl(event): … … 95 95 h,k,l = hkl 96 96 Obj.SetValue('%3d %3d %3d'%(h,k,l)) 97 G2plt.PlotSizeStrainPO(G2frame,data )97 G2plt.PlotSizeStrainPO(G2frame,data,hist) 98 98 99 99 plotSizer = wx.BoxSizer(wx.VERTICAL) … … 268 268 hist = Indx[Obj.GetId()] 269 269 UseList[hist]['Size'][0] = Obj.GetValue() 270 G2plt.PlotSizeStrainPO(G2frame,data )270 G2plt.PlotSizeStrainPO(G2frame,data,hist) 271 271 wx.CallLater(100,UpdateDData,G2frame,DData,data) 272 272 … … 300 300 pass 301 301 Obj.SetValue("%.5f"%(UseList[hist]['Size'][1][pid])) #reset in case of error 302 G2plt.PlotSizeStrainPO(G2frame,data )302 G2plt.PlotSizeStrainPO(G2frame,data,hist) 303 303 304 304 def OnSizeAxis(event): … … 329 329 UseList[item]['Size'][4][i] = 1.0 330 330 UseList[item]['Size'][4][i+3] = 0.0 331 G2plt.PlotSizeStrainPO(G2frame,data )331 G2plt.PlotSizeStrainPO(G2frame,data,item) 332 332 wx.CallLater(100,UpdateDData,G2frame,DData,data) 333 333 … … 337 337 UseList[hist]['Mustrain'][0] = Obj.GetValue() 338 338 wx.CallLater(100,UpdateDData,G2frame,DData,data) 339 G2plt.PlotSizeStrainPO(G2frame,data )339 G2plt.PlotSizeStrainPO(G2frame,data,hist) 340 340 341 341 def OnStrainRef(event): … … 367 367 else: 368 368 Obj.SetValue("%.1f"%(UseList[hist]['Mustrain'][1][pid])) #reset in case of error 369 G2plt.PlotSizeStrainPO(G2frame,data )369 G2plt.PlotSizeStrainPO(G2frame,data,hist) 370 370 371 371 def OnStrainAxis(event): … … 382 382 h,k,l = hkl 383 383 Obj.SetValue('%3d %3d %3d'%(h,k,l)) 384 G2plt.PlotSizeStrainPO(G2frame,data )384 G2plt.PlotSizeStrainPO(G2frame,data,hist) 385 385 386 386 def OnResetStrain(event): … … 400 400 for i in range(nTerm): 401 401 UseList[item]['Mustrain'][4][i] = vals[i] 402 G2plt.PlotSizeStrainPO(G2frame,data )402 G2plt.PlotSizeStrainPO(G2frame,data,item) 403 403 wx.CallLater(100,UpdateDData,G2frame,DData,data) 404 404 … … 853 853 def OnSelect(event): 854 854 hist = keyList[select.GetSelection()] 855 G2plt.PlotSizeStrainPO(G2frame,data )855 G2plt.PlotSizeStrainPO(G2frame,data,hist) 856 856 wx.CallLater(100,UpdateDData,G2frame,DData,data,hist) 857 857 … … 859 859 hist = keyList[selSpin.GetValue()] 860 860 selSpin.Destroy() # remove button to discourage pressing too fast 861 G2plt.PlotSizeStrainPO(G2frame,data )861 G2plt.PlotSizeStrainPO(G2frame,data,hist) 862 862 wx.CallLater(100,UpdateDData,G2frame,DData,data,hist) 863 863 -
trunk/GSASIIphsGUI.py
r1699 r1731 5824 5824 G2gd.SetDataMenuBar(G2frame,G2frame.dataFrame.DataMenu) 5825 5825 G2ddG.UpdateDData(G2frame,DData,data) 5826 G2plt.PlotSizeStrainPO(G2frame,data, Start=True)5826 G2plt.PlotSizeStrainPO(G2frame,data,hist='',Start=True) 5827 5827 elif text == 'Atoms': 5828 5828 G2gd.SetDataMenuBar(G2frame,G2frame.dataFrame.AtomsMenu) -
trunk/GSASIIplot.py
r1715 r1731 2492 2492 ################################################################################ 2493 2493 2494 def PlotSizeStrainPO(G2frame,data, Start=False):2494 def PlotSizeStrainPO(G2frame,data,hist='',Start=False): 2495 2495 '''Plot 3D mustrain/size/preferred orientation figure. In this instance data is for a phase 2496 2496 ''' … … 2515 2515 if plotType in ['None']: 2516 2516 return 2517 2518 for item in useList: 2519 if useList[item]['Show']: 2520 break 2521 else: 2522 return #nothing to show!! 2523 2517 if hist == '': 2518 hist = useList.keys()[0] 2524 2519 numPlots = len(useList) 2525 2520 … … 2536 2531 Page.Show() 2537 2532 2538 for item in useList: 2539 if useList[item]['Show']: 2540 PHI = np.linspace(0.,360.,30,True) 2541 PSI = np.linspace(0.,180.,30,True) 2542 X = np.outer(npsind(PHI),npsind(PSI)) 2543 Y = np.outer(npcosd(PHI),npsind(PSI)) 2544 Z = np.outer(np.ones(np.size(PHI)),npcosd(PSI)) 2545 try: #temp patch instead of 'mustrain' for old files with 'microstrain' 2546 coeff = useList[item][plotDict[plotType]] 2547 except KeyError: 2548 break 2549 if plotType in ['Mustrain','Size']: 2550 if coeff[0] == 'isotropic': 2551 X *= coeff[1][0] 2552 Y *= coeff[1][0] 2553 Z *= coeff[1][0] 2554 elif coeff[0] == 'uniaxial': 2533 PHI = np.linspace(0.,360.,30,True) 2534 PSI = np.linspace(0.,180.,30,True) 2535 X = np.outer(npsind(PHI),npsind(PSI)) 2536 Y = np.outer(npcosd(PHI),npsind(PSI)) 2537 Z = np.outer(np.ones(np.size(PHI)),npcosd(PSI)) 2538 try: #temp patch instead of 'mustrain' for old files with 'microstrain' 2539 coeff = useList[hist][plotDict[plotType]] 2540 except KeyError: 2541 return 2542 if plotType in ['Mustrain','Size']: 2543 if coeff[0] == 'isotropic': 2544 X *= coeff[1][0] 2545 Y *= coeff[1][0] 2546 Z *= coeff[1][0] 2547 elif coeff[0] == 'uniaxial': 2548 2549 def uniaxCalc(xyz,iso,aniso,axes): 2550 Z = np.array(axes) 2551 cp = abs(np.dot(xyz,Z)) 2552 sp = np.sqrt(1.-cp**2) 2553 R = iso*aniso/np.sqrt((iso*cp)**2+(aniso*sp)**2) 2554 return R*xyz 2555 2556 iso,aniso = coeff[1][:2] 2557 axes = np.inner(A,np.array(coeff[3])) 2558 axes /= nl.norm(axes) 2559 Shkl = np.array(coeff[1]) 2560 XYZ = np.dstack((X,Y,Z)) 2561 XYZ = np.nan_to_num(np.apply_along_axis(uniaxCalc,2,XYZ,iso,aniso,axes)) 2562 X,Y,Z = np.dsplit(XYZ,3) 2563 X = X[:,:,0] 2564 Y = Y[:,:,0] 2565 Z = Z[:,:,0] 2566 2567 elif coeff[0] == 'ellipsoidal': 2568 2569 def ellipseCalc(xyz,E,R): 2570 XYZ = xyz*E.T 2571 return np.inner(XYZ.T,R) 2572 2573 S6 = coeff[4] 2574 Sij = G2lat.U6toUij(S6) 2575 E,R = nl.eigh(Sij) 2576 XYZ = np.dstack((X,Y,Z)) 2577 XYZ = np.nan_to_num(np.apply_along_axis(ellipseCalc,2,XYZ,E,R)) 2578 X,Y,Z = np.dsplit(XYZ,3) 2579 X = X[:,:,0] 2580 Y = Y[:,:,0] 2581 Z = Z[:,:,0] 2582 2583 elif coeff[0] == 'generalized': 2584 2585 def genMustrain(xyz,SGData,A,Shkl): 2586 uvw = np.inner(A.T,xyz) 2587 Strm = np.array(G2spc.MustrainCoeff(uvw,SGData)) 2588 Sum = np.sum(np.multiply(Shkl,Strm)) 2589 Sum = np.where(Sum > 0.01,Sum,0.01) 2590 Sum = np.sqrt(Sum) 2591 return Sum*xyz 2592 2593 Shkl = np.array(coeff[4]) 2594 if np.any(Shkl): 2595 XYZ = np.dstack((X,Y,Z)) 2596 XYZ = np.nan_to_num(np.apply_along_axis(genMustrain,2,XYZ,SGData,A,Shkl)) 2597 X,Y,Z = np.dsplit(XYZ,3) 2598 X = X[:,:,0] 2599 Y = Y[:,:,0] 2600 Z = Z[:,:,0] 2555 2601 2556 def uniaxCalc(xyz,iso,aniso,axes): 2557 Z = np.array(axes) 2558 cp = abs(np.dot(xyz,Z)) 2559 sp = np.sqrt(1.-cp**2) 2560 R = iso*aniso/np.sqrt((iso*cp)**2+(aniso*sp)**2) 2561 return R*xyz 2562 2563 iso,aniso = coeff[1][:2] 2564 axes = np.inner(A,np.array(coeff[3])) 2565 axes /= nl.norm(axes) 2566 Shkl = np.array(coeff[1]) 2567 XYZ = np.dstack((X,Y,Z)) 2568 XYZ = np.nan_to_num(np.apply_along_axis(uniaxCalc,2,XYZ,iso,aniso,axes)) 2569 X,Y,Z = np.dsplit(XYZ,3) 2570 X = X[:,:,0] 2571 Y = Y[:,:,0] 2572 Z = Z[:,:,0] 2573 2574 elif coeff[0] == 'ellipsoidal': 2575 2576 def ellipseCalc(xyz,E,R): 2577 XYZ = xyz*E.T 2578 return np.inner(XYZ.T,R) 2579 2580 S6 = coeff[4] 2581 Sij = G2lat.U6toUij(S6) 2582 E,R = nl.eigh(Sij) 2583 XYZ = np.dstack((X,Y,Z)) 2584 XYZ = np.nan_to_num(np.apply_along_axis(ellipseCalc,2,XYZ,E,R)) 2585 X,Y,Z = np.dsplit(XYZ,3) 2586 X = X[:,:,0] 2587 Y = Y[:,:,0] 2588 Z = Z[:,:,0] 2589 2590 elif coeff[0] == 'generalized': 2591 2592 def genMustrain(xyz,SGData,A,Shkl): 2593 uvw = np.inner(A.T,xyz) 2594 Strm = np.array(G2spc.MustrainCoeff(uvw,SGData)) 2595 Sum = np.sum(np.multiply(Shkl,Strm)) 2596 Sum = np.where(Sum > 0.01,Sum,0.01) 2597 Sum = np.sqrt(Sum) 2598 return Sum*xyz 2599 2600 Shkl = np.array(coeff[4]) 2601 if np.any(Shkl): 2602 XYZ = np.dstack((X,Y,Z)) 2603 XYZ = np.nan_to_num(np.apply_along_axis(genMustrain,2,XYZ,SGData,A,Shkl)) 2604 X,Y,Z = np.dsplit(XYZ,3) 2605 X = X[:,:,0] 2606 Y = Y[:,:,0] 2607 Z = Z[:,:,0] 2608 2609 if np.any(X) and np.any(Y) and np.any(Z): 2610 errFlags = np.seterr(all='ignore') 2611 Plot.plot_surface(X,Y,Z,rstride=1,cstride=1,color='g',linewidth=1) 2612 np.seterr(all='ignore') 2613 xyzlim = np.array([Plot.get_xlim3d(),Plot.get_ylim3d(),Plot.get_zlim3d()]).T 2614 XYZlim = [min(xyzlim[0]),max(xyzlim[1])] 2615 Plot.set_xlim3d(XYZlim) 2616 Plot.set_ylim3d(XYZlim) 2617 Plot.set_zlim3d(XYZlim) 2618 Plot.set_aspect('equal') 2619 if plotType == 'Size': 2620 Plot.set_title('Crystallite size for '+phase+'\n'+coeff[0]+' model') 2621 Plot.set_xlabel(r'X, $\mu$m') 2622 Plot.set_ylabel(r'Y, $\mu$m') 2623 Plot.set_zlabel(r'Z, $\mu$m') 2624 else: 2625 Plot.set_title(r'$\mu$strain for '+phase+'\n'+coeff[0]+' model') 2626 Plot.set_xlabel(r'X, $\mu$strain') 2627 Plot.set_ylabel(r'Y, $\mu$strain') 2628 Plot.set_zlabel(r'Z, $\mu$strain') 2629 else: 2630 h,k,l = generalData['POhkl'] 2631 if coeff[0] == 'MD': 2632 print 'March-Dollase preferred orientation plot' 2633 2634 else: 2635 PH = np.array(generalData['POhkl']) 2636 phi,beta = G2lat.CrsAng(PH,cell[:6],SGData) 2637 SHCoef = {} 2638 for item in coeff[5]: 2639 L,N = eval(item.strip('C')) 2640 SHCoef['C%d,0,%d'%(L,N)] = coeff[5][item] 2641 ODFln = G2lat.Flnh(Start,SHCoef,phi,beta,SGData) 2642 X = np.linspace(0,90.0,26) 2643 Y = G2lat.polfcal(ODFln,'0',X,0.0) 2644 Plot.plot(X,Y,color='k',label=str(PH)) 2645 Plot.legend(loc='best') 2646 Plot.set_title('Axial distribution for HKL='+str(PH)+' in '+phase) 2647 Plot.set_xlabel(r'$\psi$',fontsize=16) 2648 Plot.set_ylabel('MRD',fontsize=14) 2602 if np.any(X) and np.any(Y) and np.any(Z): 2603 errFlags = np.seterr(all='ignore') 2604 Plot.plot_surface(X,Y,Z,rstride=1,cstride=1,color='g',linewidth=1) 2605 np.seterr(all='ignore') 2606 xyzlim = np.array([Plot.get_xlim3d(),Plot.get_ylim3d(),Plot.get_zlim3d()]).T 2607 XYZlim = [min(xyzlim[0]),max(xyzlim[1])] 2608 Plot.set_xlim3d(XYZlim) 2609 Plot.set_ylim3d(XYZlim) 2610 Plot.set_zlim3d(XYZlim) 2611 Plot.set_aspect('equal') 2612 if plotType == 'Size': 2613 Plot.set_title('Crystallite size for '+phase+'\n'+coeff[0]+' model') 2614 Plot.set_xlabel(r'X, $\mu$m') 2615 Plot.set_ylabel(r'Y, $\mu$m') 2616 Plot.set_zlabel(r'Z, $\mu$m') 2617 else: 2618 Plot.set_title(r'$\mu$strain for '+phase+'\n'+coeff[0]+' model') 2619 Plot.set_xlabel(r'X, $\mu$strain') 2620 Plot.set_ylabel(r'Y, $\mu$strain') 2621 Plot.set_zlabel(r'Z, $\mu$strain') 2622 else: 2623 h,k,l = generalData['POhkl'] 2624 if coeff[0] == 'MD': 2625 print 'March-Dollase preferred orientation plot' 2626 2627 else: 2628 PH = np.array(generalData['POhkl']) 2629 phi,beta = G2lat.CrsAng(PH,cell[:6],SGData) 2630 SHCoef = {} 2631 for item in coeff[5]: 2632 L,N = eval(item.strip('C')) 2633 SHCoef['C%d,0,%d'%(L,N)] = coeff[5][item] 2634 ODFln = G2lat.Flnh(Start,SHCoef,phi,beta,SGData) 2635 X = np.linspace(0,90.0,26) 2636 Y = G2lat.polfcal(ODFln,'0',X,0.0) 2637 Plot.plot(X,Y,color='k',label=str(PH)) 2638 Plot.legend(loc='best') 2639 Plot.set_title('Axial distribution for HKL='+str(PH)+' in '+phase) 2640 Plot.set_xlabel(r'$\psi$',fontsize=16) 2641 Plot.set_ylabel('MRD',fontsize=14) 2649 2642 Page.canvas.draw() 2650 2643
Note: See TracChangeset
for help on using the changeset viewer.