Changeset 335 for trunk/GSASIIplot.py


Ignore:
Timestamp:
Jul 7, 2011 1:53:57 PM (12 years ago)
Author:
vondreele
Message:

Add delete Pawley list; scratch "leBail" from things
mods to texture display stuff
refactor instrument parameters GUI as sizer based - no grid table
some mods to peak fit output

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIplot.py

    r327 r335  
    4949npacosd = lambda x: 180.*np.arccos(x)/np.pi
    5050npasind = lambda x: 180.*np.arcsin(x)/np.pi
     51npatand = lambda x: 180.*np.arctan(x)/np.pi
    5152npatan2d = lambda x,y: 180.*np.arctan2(x,y)/np.pi
    5253   
     
    10211022    instParms = self.PatternTree.GetItemPyData( \
    10221023        G2gd.GetPatternTreeItemId(self,PatternId, 'Instrument Parameters'))
    1023     if instParms[0][0] == 'PXC':
     1024    if instParms[0][0] in ['PXC','PNC']:
    10241025        lam = instParms[1][1]
    10251026        if len(instParms[1]) == 13:
     
    10881089    for peak in peaks:
    10891090        X.append(4.0*math.pi*sind(peak[0]/2.0)/lam)
    1090         s = 1.17741*math.sqrt(peak[4])*math.pi/18000.
     1091        try:
     1092            s = 1.17741*math.sqrt(peak[4])*math.pi/18000.
     1093        except ValueError:
     1094            s = 0.01
    10911095        g = peak[6]*math.pi/18000.
    10921096        G = gamFW(g,s)
     
    12111215    SHCoef = SHData['SH Coeff'][1]
    12121216    cell = generalData['Cell'][1:7]
     1217    Amat,Bmat = G2lat.cell2AB(cell)
     1218    sq2 = 1.0/math.sqrt(2.0)
    12131219   
     1220    def rp2xyz(r,p):
     1221        z = npcosd(r)
     1222        xy = np.sqrt(1.-z**2)
     1223        return xy*npsind(p),xy*npcosd(p),z
     1224           
    12141225    def OnMotion(event):
    1215         Page.canvas.SetToolTipString('')
     1226        SHData = data['General']['SH Texture']
    12161227        if event.xdata and event.ydata:                 #avoid out of frame errors
    1217             if 'Pole figure' in SHData['PlotType']:
    1218                 xpos = event.xdata
    1219                 ypos = event.ydata
    1220                 Int = 0
    1221                 if xpos**2+ypos**2 < 1.0:
    1222                     r,p = 2.*npasind(np.sqrt(xpos**2+ypos**2)*0.707106782),npatan2d(ypos,xpos)
     1228            xpos = event.xdata
     1229            ypos = event.ydata
     1230            if 'Inverse' in SHData['PlotType']:
     1231                r = xpos**2+ypos**2
     1232                if r <= 1.0:
     1233                    if 'equal' in self.Projection:
     1234                        r,p = 2.*npasind(np.sqrt(r)*sq2),npatan2d(ypos,xpos)
     1235                    else:
     1236                        r,p = 2.*npatand(np.sqrt(r)),npatan2d(ypos,xpos)
     1237                    ipf = G2lat.invpolfcal(IODFln,SGData,np.array([r,]),np.array([p,]))
     1238                    xyz = np.inner(Amat.T,np.array([rp2xyz(r,p)]))
     1239                    y,x,z = list(xyz/np.max(np.abs(xyz)))
     1240                   
     1241                    self.G2plotNB.status.SetFields(['',
     1242                        'psi =%9.3f, beta =%9.3f, MRD =%9.3f xyz=%5.2f,%5.2f,%5.2f'%(r,p,ipf,x,y,z)])
     1243                                   
     1244            elif 'Axial' in SHData['PlotType']:
     1245                pass
     1246               
     1247            else:                       #ordinary pole figure
     1248                z = xpos**2+ypos**2
     1249                if z <= 1.0:
     1250                    z = np.sqrt(z)
     1251                    if 'equal' in self.Projection:
     1252                        r,p = 2.*npasind(z*sq2),npatan2d(ypos,xpos)
     1253                    else:
     1254                        r,p = 2.*npatand(z),npatan2d(ypos,xpos)
    12231255                    pf = G2lat.polfcal(ODFln,SamSym[textureData['Model']],np.array([r,]),np.array([p,]))
    12241256                    self.G2plotNB.status.SetFields(['','phi =%9.3f, gam =%9.3f, MRD =%9.3f'%(r,p,pf)])
    1225    
     1257                   
    12261258    try:
    12271259        plotNum = self.G2plotNB.plotList.index('Texture')
     
    12361268        Page = self.G2plotNB.nb.GetPage(plotNum)
    12371269        Page.canvas.mpl_connect('motion_notify_event', OnMotion)
    1238         Page.SetFocus()
    1239    
     1270
     1271    Page.SetFocus()
     1272    self.G2plotNB.status.SetFields(['',''])   
     1273    PH = np.array(SHData['PFhkl'])
     1274    phi,beta = G2lat.CrsAng(PH,cell,SGData)
     1275    ODFln = G2lat.Flnh(Start,SHCoef,phi,beta,SGData)
     1276    PX = np.array(SHData['PFxyz'])
     1277    gam = atan2d(PX[0],PX[1])
     1278    xy = math.sqrt(PX[0]**2+PX[1]**2)
     1279    xyz = math.sqrt(PX[0]**2+PX[1]**2+PX[2]**2)
     1280    psi = asind(xy/xyz)
     1281    IODFln = G2lat.Glnh(Start,SHCoef,psi,gam,SamSym[textureData['Model']])
    12401282    if 'Axial' in SHData['PlotType']:
    1241         PH = np.array(SHData['PFhkl'])
    1242         phi,beta = G2lat.CrsAng(PH,cell,SGData)
    1243         ODFln = G2lat.Flnh(Start,SHCoef,phi,beta,SGData)
    12441283        X = np.linspace(0,90.0,26)
    12451284        Y = G2lat.polfcal(ODFln,SamSym[textureData['Model']],X,0.0)
     
    12511290       
    12521291    else:       
     1292        npts = 201
    12531293        if 'Inverse' in SHData['PlotType']:
    1254             PX = np.array(SHData['PFxyz'])
    1255             gam = atan2d(PX[0],PX[1])
    1256             xy = math.sqrt(PX[0]**2+PX[1]**2)
    1257             xyz = math.sqrt(PX[0]**2+PX[1]**2+PX[2]**2)
    1258             psi = asind(xy/xyz)
    1259             npts = 201
    1260             ODFln = G2lat.Glnh(Start,SHCoef,psi,gam,SamSym[textureData['Model']])
    12611294            X,Y = np.meshgrid(np.linspace(1.,-1.,npts),np.linspace(-1.,1.,npts))
    12621295            R,P = np.sqrt(X**2+Y**2).flatten(),npatan2d(X,Y).flatten()
    1263             R = np.where(R <= 1.,2.*npasind(R*0.70710678),0.0)
     1296            if 'equal' in self.Projection:
     1297                R = np.where(R <= 1.,2.*npasind(R*sq2),0.0)
     1298            else:
     1299                R = np.where(R <= 1.,2.*npatand(R),0.0)
    12641300            Z = np.zeros_like(R)
    1265             Z = G2lat.invpolfcal(ODFln,SGData,R,P)
     1301            Z = G2lat.invpolfcal(IODFln,SGData,R,P)
    12661302            Z = np.reshape(Z,(npts,npts))
    12671303            CS = Plot.contour(Y,X,Z,aspect='equal')
    12681304            Plot.clabel(CS,fontsize=9,inline=1)
    1269             Img = Plot.imshow(Z.T,aspect='equal',cmap='binary',extent=[-1,1,-1,1])
     1305            Img = Plot.imshow(Z.T,aspect='equal',cmap=self.ContourColor,extent=[-1,1,-1,1])
    12701306            if newPlot:
    12711307#                Page.figure.colorbar(Img)    #colorbar fails - crashes gsasii
    12721308                newPlot = False
    12731309            Plot.set_title('Inverse pole figure for XYZ='+str(SHData['PFxyz']))
     1310            Plot.set_xlabel(self.Projection.capitalize()+' projection')
    12741311                       
    12751312        else:
    1276             PH = np.array(SHData['PFhkl'])
    1277             phi,beta = G2lat.CrsAng(PH,cell,SGData)
    1278             npts = 201
    1279             ODFln = G2lat.Flnh(Start,SHCoef,phi,beta,SGData)
    12801313            X,Y = np.meshgrid(np.linspace(1.,-1.,npts),np.linspace(-1.,1.,npts))
    12811314            R,P = np.sqrt(X**2+Y**2).flatten(),npatan2d(X,Y).flatten()
    1282             R = np.where(R <= 1.,2.*npasind(R*0.70710678),0.0)
     1315            if 'equal' in self.Projection:
     1316                R = np.where(R <= 1.,2.*npasind(R*sq2),0.0)
     1317            else:
     1318                R = np.where(R <= 1.,2.*npatand(R),0.0)
    12831319            Z = np.zeros_like(R)
    12841320            Z = G2lat.polfcal(ODFln,SamSym[textureData['Model']],R,P)
     
    12861322            CS = Plot.contour(Y,X,Z,aspect='equal')
    12871323            Plot.clabel(CS,fontsize=9,inline=1)
    1288             Img = Plot.imshow(Z.T,aspect='equal',cmap='binary',extent=[-1,1,-1,1])
     1324            Img = Plot.imshow(Z.T,aspect='equal',cmap=self.ContourColor,extent=[-1,1,-1,1])
    12891325            if newPlot:
    12901326#                Page.figure.colorbar(Img)    #colorbar fails - crashes gsasii
    12911327                newPlot = False
    12921328            Plot.set_title('Pole figure for HKL='+str(SHData['PFhkl']))
     1329            Plot.set_xlabel(self.Projection.capitalize()+' projection')
    12931330    Page.canvas.draw()
    12941331
Note: See TracChangeset for help on using the changeset viewer.