Changeset 2372 for trunk/GSASIIplot.py


Ignore:
Timestamp:
Jul 12, 2016 3:50:52 PM (7 years ago)
Author:
vondreele
Message:

Add reflection positions & cursor report to IPF. Still more fixes to IPF plots.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIplot.py

    r2369 r2372  
    30123012    '''
    30133013   
     3014    def OnPick(event):
     3015        if plotType not in ['Inv. pole figure',]:
     3016            return
     3017        ind = event.ind[0]
     3018        h,k,l = RefSets[ind]
     3019        msg = '%d,%d,%d=%.2f'%(h,k,l,Rmd[ind])
     3020        Page.canvas.SetToolTipString(msg)
     3021
     3022    def rp2xyz(r,p):
     3023        z = npcosd(r)
     3024        xy = np.sqrt(1.-z**2)
     3025        return xy*npcosd(p),xy*npsind(p),z
     3026       
     3027    def OnMotion(event):
     3028        if plotType not in ['Inv. pole figure',]:
     3029            return
     3030        if event.xdata and event.ydata:                 #avoid out of frame errors
     3031            xpos = event.xdata
     3032            ypos = event.ydata
     3033            r = xpos**2+ypos**2
     3034            if r <= 1.0:
     3035                r,p = 2.*npatand(np.sqrt(r)),npatan2d(ypos,xpos)    #stereoproj.
     3036                if p<0.:
     3037                    p += 360.
     3038                ipf = lut(r*np.pi/180.,p*np.pi/180.)
     3039                xyz = np.inner(Bmat.T,np.array([rp2xyz(r,p)]))
     3040                x,y,z = list(xyz/np.max(np.abs(xyz)))
     3041                G2frame.G2plotNB.status.SetStatusText(
     3042                    'psi =%9.3f, beta =%9.3f, MRD =%9.3f hkl=%5.2f,%5.2f,%5.2f'%(r,p,ipf,x,y,z),1)
     3043   
    30143044    import scipy.interpolate as si
    30153045    generalData = data['General']
     
    30203050        Start = False
    30213051    cell = generalData['Cell'][1:]
    3022     A,B = G2lat.cell2AB(cell[:6])
     3052    Amat,Bmat = G2lat.cell2AB(cell[:6])
    30233053    Vol = cell[6]
    30243054    useList = data['Histograms']
     
    30483078        plotNum = G2frame.G2plotNB.plotList.index(plotType)
    30493079        Page = G2frame.G2plotNB.nb.GetPage(plotNum)
     3080        Page.canvas.mpl_connect('pick_event', OnPick)
     3081        Page.canvas.mpl_connect('motion_notify_event', OnMotion)
    30503082    Page.Choice = None
    30513083    G2frame.G2plotNB.RaisePageNoRefresh(Page)
     
    30783110               
    30793111            iso,aniso = coeff[1][:2]
    3080             axes = np.inner(A,np.array(coeff[3]))
     3112            axes = np.inner(Amat,np.array(coeff[3]))
    30813113            axes /= nl.norm(axes)
    30823114            Shkl = np.array(coeff[1])
     
    31073139           
    31083140            def genMustrain(xyz,SGData,A,Shkl):
    3109                 uvw = np.inner(A.T,xyz)
     3141                uvw = np.inner(Amat.T,xyz)
    31103142                Strm = np.array(G2spc.MustrainCoeff(uvw,SGData))
    31113143                Sum = np.sum(np.multiply(Shkl,Strm))
     
    31173149            if np.any(Shkl):
    31183150                XYZ = np.dstack((X,Y,Z))
    3119                 XYZ = np.nan_to_num(np.apply_along_axis(genMustrain,2,XYZ,SGData,A,Shkl))
     3151                XYZ = np.nan_to_num(np.apply_along_axis(genMustrain,2,XYZ,SGData,Amat,Shkl))
    31203152                X,Y,Z = np.dsplit(XYZ,3)
    31213153                X = X[:,:,0]
     
    31853217            refSet = np.vstack((refSet,-refSet))    #add Friedel pairs
    31863218            refSet = [np.where(ref[2]<0,-1.*ref,ref) for ref in refSet] #take +l of each pair then remove duplicates
    3187             refSet = set([str(ref).strip('[]').replace('-0',' 0') for ref in refSet])
    3188             refSet = [np.fromstring(item,sep=' ') for item in refSet]
     3219            refSet = [str(ref).strip('[]').replace('-0',' 0') for ref in refSet]
     3220            refSet = [np.fromstring(item,sep=' ') for item in set(refSet)]
    31893221            refSets[ir] = refSet
     3222        RefSets = []
    31903223        for ir,refSet in enumerate(refSets):
    31913224            r,beta,phi = G2lat.HKL2SpAng(refSet,cell[:6],SGData)    #radius, inclination, azimuth
     
    31953228            Beta += list(beta)
    31963229            Rmd += len(phi)*[obsRMD[ir],]
     3230            RefSets += refSet
     3231        RefSets = np.array(RefSets)
    31973232        Beta = np.abs(np.array(Beta))
    31983233        Phi = np.array(Phi)
     
    32003235        Rmd = np.array(Rmd)
    32013236        Rmd = np.where(Rmd<0.,0.,Rmd)
    3202         y,x = np.sin(Beta)*np.cos(Phi),np.sin(Beta)*np.sin(Phi)       
     3237        x,y = np.tan(Beta/2.)*np.cos(Phi),np.tan(Beta/2.)*np.sin(Phi)       
    32033238        sq2 = 1.0/math.sqrt(2.0)
    32043239        npts = 201
     
    32103245#        GSASIIpath.IPyBreak()
    32113246        try:
    3212             sfac = 1
     3247            sfac = 0.5
    32133248            while True:
    32143249                try:
     
    32283263            pass
    32293264        Img = Plot.imshow(Z.T,aspect='equal',cmap=G2frame.ContourColor,extent=[-1,1,-1,1])
    3230         Plot.plot(x,y,'+')
     3265        Plot.plot(-x,y,'+',picker=3)
    32313266        Page.figure.colorbar(Img)
    32323267        Plot.axis('off')
    3233         Plot.set_title('0 0 1 Inverse pole figure for %s'%(phase))
    3234         Plot.set_xlabel(G2frame.Projection.capitalize()+' projection')
     3268        Plot.set_title('0 0 1 Inverse pole figure for %s\n%s'%(phase,hist))
    32353269       
    32363270    Page.canvas.draw()
     
    34143448            Plot.axis('off')
    34153449            Plot.set_title('%d %d %d Pole figure for %s'%(h,k,l,pName))
    3416             Plot.set_xlabel(G2frame.Projection.capitalize()+' projection')
    34173450    Page.canvas.draw()
    34183451
Note: See TracChangeset for help on using the changeset viewer.