Changeset 326 for trunk/GSASIIplot.py


Ignore:
Timestamp:
Jun 30, 2011 11:38:20 AM (12 years ago)
Author:
vondreele
Message:

remove cf2py
add inverse polefigure

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIplot.py

    r313 r326  
    11141114    Vol = cell[6]
    11151115    useList = data['Histograms']
     1116    for item in useList:
     1117        if useList[item]['Show']:
     1118            break
     1119    else:
     1120        self.G2plotNB.Delete('Microstrain')
     1121        return            #nothing to show!!
     1122   
    11161123    numPlots = len(useList)
    11171124   
     
    11211128        Page.figure.clf()
    11221129        Plot = mp3d.Axes3D(Page.figure)
     1130        if not Page.IsShown():
     1131            Page.Show()
    11231132    except ValueError:
    11241133        Plot = mp3d.Axes3D(self.G2plotNB.add3D('Microstrain'))
     
    11891198    dict generalData contains all phase info needed which is in data
    11901199    '''
     1200
    11911201    shModels = ['cylindrical','none','shear - 2/m','rolling - mmm']
    11921202    SamSym = dict(zip(shModels,['0','-1','2/m','mmm']))
     
    11951205    SGData = generalData['SGData']
    11961206    textureData = generalData['SH Texture']
     1207    if not textureData['Order']:
     1208        self.G2plotNB.Delete('Texture')
     1209        return                  #no plot!!
    11971210    SHData = generalData['SH Texture']
    11981211    SHCoef = SHData['SH Coeff'][1]
    11991212    cell = generalData['Cell'][1:7]
    12001213    Start = True
    1201                
     1214   
     1215    def OnMotion(event):
     1216        Page.canvas.SetToolTipString('')
     1217        if event.xdata and event.ydata:                 #avoid out of frame errors
     1218            if 'Pole figure' in SHData['PlotType']:
     1219                xpos = event.xdata
     1220                ypos = event.ydata
     1221                Int = 0
     1222                if xpos**2+ypos**2 < 1.0:
     1223                    r,p = 2.*npasind(np.sqrt(xpos**2+ypos**2)*0.707106782),npatan2d(ypos,xpos)
     1224                    pf = G2lat.polfcal(ODFln,SamSym[textureData['Model']],np.array([r,]),np.array([p,]))
     1225                    self.G2plotNB.status.SetFields(['','phi =%9.3f, gam =%9.3f, MRD =%9.3f'%(r,p,pf)])
     1226   
    12021227    try:
    12031228        plotNum = self.G2plotNB.plotList.index('Texture')
     
    12111236        plotNum = self.G2plotNB.plotList.index('Texture')
    12121237        Page = self.G2plotNB.nb.GetPage(plotNum)
     1238        Page.canvas.mpl_connect('motion_notify_event', OnMotion)
    12131239        Page.SetFocus()
    12141240   
     
    12181244        ODFln = G2lat.Flnh(Start,SHCoef,phi,beta,SGData)
    12191245        X = np.linspace(0,90.0,26)
    1220         Y = np.zeros_like(X)
    1221         for i,a in enumerate(X):
    1222             Y[i] = G2lat.polfcal(ODFln,SamSym[textureData['Model']],a,0.0)
     1246        Y = G2lat.polfcal(ODFln,SamSym[textureData['Model']],X,0.0)
    12231247        Plot.plot(X,Y,color='k',label=str(SHData['PFhkl']))
    12241248        Plot.legend(loc='best')
     
    12271251        Plot.set_ylabel('MRD',fontsize=14)
    12281252       
    1229        
    12301253    else:       
    1231 #        self.G2plotNB.status.SetStatusText('Adjust frame size to get desired aspect ratio',1)
    1232         if 'inverse' in SHData['PlotType']:
     1254        if 'Inverse' in SHData['PlotType']:
    12331255            PX = np.array(SHData['PFxyz'])
    1234            
     1256            gam = atan2d(PX[0],PX[1])
     1257            xy = math.sqrt(PX[0]**2+PX[1]**2)
     1258            xyz = math.sqrt(PX[0]**2+PX[1]**2+PX[2]**2)
     1259            psi = asind(xy/xyz)
     1260            npts = 201
     1261            ODFln = G2lat.Glnh(Start,SHCoef,psi,gam,SamSym[textureData['Model']])
     1262            X,Y = np.meshgrid(np.linspace(1.,-1.,npts),np.linspace(-1.,1.,npts))
     1263            R,P = np.sqrt(X**2+Y**2).flatten(),npatan2d(X,Y).flatten()
     1264            R = np.where(R <= 1.,2.*npasind(R*0.70710678),0.0)
     1265            Z = np.zeros_like(R)
     1266            time0 = time.time()
     1267            Z = G2lat.invpolfcal(ODFln,SGData,R,P)
     1268            print 'inverse time:',time.time()-time0
     1269            Z = np.reshape(Z,(npts,npts))
     1270            CS = Plot.contour(Y,X,Z,aspect='equal')
     1271            Plot.clabel(CS,fontsize=9,inline=1)
     1272            Img = Plot.imshow(Z.T,aspect='equal',cmap='binary',extent=[-1,1,-1,1])
     1273            if newPlot:
     1274                Page.figure.colorbar(Img)
     1275                newPlot = False
     1276            Plot.set_title('Inverse pole figure for XYZ='+str(SHData['PFxyz']))
     1277            print 'inverse pole figure',Img
     1278                       
    12351279        else:
    12361280            PH = np.array(SHData['PFhkl'])
     
    12421286            R = np.where(R <= 1.,2.*npasind(R*0.70710678),0.0)
    12431287            Z = np.zeros_like(R)
     1288            time0 = time.time()
    12441289            Z = G2lat.polfcal(ODFln,SamSym[textureData['Model']],R,P)
     1290            print 'polfig time:',time.time()-time0
    12451291            Z = np.reshape(Z,(npts,npts))
    1246             Img = Plot.imshow(Z.T,aspect='equal',cmap='binary')
     1292            CS = Plot.contour(Y,X,Z,aspect='equal')
     1293            Plot.clabel(CS,fontsize=9,inline=1)
     1294            Img = Plot.imshow(Z.T,aspect='equal',cmap='binary',extent=[-1,1,-1,1])
    12471295            if newPlot:
    12481296                Page.figure.colorbar(Img)
    12491297                newPlot = False
    12501298            Plot.set_title('Pole figure for HKL='+str(SHData['PFhkl']))
     1299            print 'pole figure',Img
    12511300    Page.canvas.draw()
    1252     return
    1253 
    12541301           
    12551302def PlotExposedImage(self,newPlot=False,event=None):
Note: See TracChangeset for help on using the changeset viewer.