Changeset 132 for trunk/GSASIIplot.py


Ignore:
Timestamp:
Jul 27, 2010 5:59:50 PM (13 years ago)
Author:
vondreel
Message:

implement tool tips giving hkl of generated reflections & give fo, fc, etc. of single crystal hkl from plot

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIplot.py

    r125 r132  
    6363        return page.figure
    6464       
     65    def clear(self):
     66        while self.nb.GetPageCount():
     67            self.nb.DeletePage(0)
     68        self.plotList = []
     69        self.status.DestroyChildren()
     70       
    6571    def OnPageChanged(self,event):
    6672        self.status.DestroyChildren()                           #get rid of special stuff on status bar
     
    6874def PlotSngl(self,newPlot=False):
    6975    from matplotlib.patches import Circle
     76    global HKL,HKLF
    7077
    7178    def OnSCMotion(event):
     
    8996        if '100' in Data['Zone']:
    9097            Page.canvas.SetToolTipString('(picked:(%3d,%3d,%3d))'%(zpos,pos[0],pos[1]))
    91             hkl = [zpos,pos[0],pos[1]]
     98            hkl = np.array([zpos,pos[0],pos[1]])
    9299        elif '010' in Data['Zone']:
    93100            Page.canvas.SetToolTipString('(picked:(%3d,%3d,%3d))'%(pos[0],zpos,pos[1]))
    94             hkl = [pos[0],zpos,pos[1]]
     101            hkl = np.array([pos[0],zpos,pos[1]])
    95102        elif '001' in Data['Zone']:
    96103            Page.canvas.SetToolTipString('(picked:(%3d,%3d,%3d))'%(pos[0],pos[1],zpos))
    97             hkl = [pos[0],pos[1],zpos]
     104            hkl = np.array([pos[0],pos[1],zpos])
    98105        h,k,l = hkl
    99         i = HKL.all(hkl)
    100         print i
    101         HKLtxt = '(%3d,%3d,%3d %10.2f %6.3f %10.2f)'%(h,k,l,Fosq,sig,Fcsq)
    102         self.G2plotNB.status.SetFields(['','HKL, Fosq, sig, Fcsq = '+HKLtxt])
    103                          
    104        
     106        hklf = HKLF[np.where(np.all(HKL-hkl == [0,0,0],axis=1))]
     107        if len(hklf):
     108            Fosq,sig,Fcsq = hklf[0]
     109            HKLtxt = '(%3d,%3d,%3d %.2f %.3f %.2f %.2f)'%(h,k,l,Fosq,sig,Fcsq,(Fosq-Fcsq)/(scale*sig))
     110            self.G2plotNB.status.SetFields(['','HKL, Fosq, sig, Fcsq, delFsq/sig = '+HKLtxt])
     111                                 
    105112    def OnSCKeyPress(event):
    106113        print event.key
     
    118125        plotNum = self.G2plotNB.plotList.index('Structure Factors')
    119126        Page = self.G2plotNB.nb.GetPage(plotNum)
    120         Page.canvas.mpl_connect('key_press_event', OnSCKeyPress)
     127#        Page.canvas.mpl_connect('key_press_event', OnSCKeyPress)
    121128        Page.canvas.mpl_connect('pick_event', OnSCPick)
    122129        Page.canvas.mpl_connect('motion_notify_event', OnSCMotion)
     
    141148    Plot.set_title(self.PatternTree.GetItemText(self.Sngl)[5:])
    142149    HKL = []
     150    HKLF = []
    143151    for H,Fosq,sig,Fcsq,x,x,x in HKLref:
    144152        HKL.append(H)
     153        HKLF.append([Fosq,sig,Fcsq])
    145154        if H[izone] == Data['Layer']:
    146155            B = 0
     
    169178                if radius > 0:
    170179                    if A > B:
     180                        Plot.add_artist(Circle(xy,radius=radius,ec='g',fc='g'))
     181                    else:                   
    171182                        Plot.add_artist(Circle(xy,radius=radius,ec='r',fc='r'))
    172                     else:                   
    173                         Plot.add_artist(Circle(xy,radius=radius,ec='g',fc='g'))
    174     HKL = np.array(HKL)
     183    HKL = np.array(HKL,dtype=np.int)
     184    HKLF = np.array(HKLF)
    175185    Plot.set_xlabel(xlabel[izone]+str(Data['Layer']),fontsize=12)
    176186    Plot.set_ylabel(ylabel[izone],fontsize=12)
     
    188198       
    189199def PlotPatterns(self,newPlot=False):
     200    global HKL
    190201   
    191202    def OnPick(event):
     
    276287                if self.itemPicked:
    277288                    Page.canvas.SetToolTipString('%9.3f'%(xpos))
     289                if self.PickId and self.PatternTree.GetItemText(self.PickId) in ['Index Peak List','Unit Cells List']:
     290                    found = []
     291                    if len(HKL):
     292                        found = HKL[np.where(np.fabs(HKL.T[5]-xpos) < 0.05)]
     293                    if len(found):
     294                        h,k,l = found[0][:3]
     295                        Page.canvas.SetToolTipString('%d,%d,%d'%(int(h),int(k),int(l)))
     296                    else:
     297                        Page.canvas.SetToolTipString('')
     298
    278299            except TypeError:
    279300                self.G2plotNB.status.SetStatusText('Select PWDR powder pattern first',1)
    280                                    
     301                                                  
    281302    def OnRelease(event):
    282303        if self.itemPicked is None: return
     
    346367            item, cookie = self.PatternTree.GetNextChild(self.root, cookie)               
    347368    Ymax = 1.0
     369    HKL = np.array(self.HKL)
    348370    for Pattern in PlotList:
    349371        xye = Pattern[1]
     
    403425                Plot.plot(X,Y,colors[N%6],picker=False)
    404426    if PickId and self.PatternTree.GetItemText(PickId) in ['Index Peak List','Unit Cells List']:
    405         peaks = self.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(self,PatternId, 'Index Peak List'))
     427        peaks = np.array((self.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(self,PatternId, 'Index Peak List'))))
    406428        for peak in peaks:
    407429            Plot.axvline(peak[0],color='b')
     
    427449
    428450def PlotPowderLines(self):
     451    global HKL
    429452
    430453    def OnMotion(event):
     
    433456            Page.canvas.SetCursor(wx.CROSS_CURSOR)
    434457            self.G2plotNB.status.SetFields(['','2-theta =%9.3f '%(xpos,)])
     458            if self.PickId and self.PatternTree.GetItemText(self.PickId) in ['Index Peak List','Unit Cells List']:
     459                found = []
     460                if len(HKL):
     461                    found = HKL[np.where(np.fabs(HKL.T[5]-xpos) < 0.05)]
     462                if len(found):
     463                    h,k,l = found[0][:3]
     464                    Page.canvas.SetToolTipString('%d,%d,%d'%(int(h),int(k),int(l)))
     465                else:
     466                    Page.canvas.SetToolTipString('')
    435467
    436468    try:
     
    453485    for peak in peaks:
    454486        Plot.axvline(peak[0],color='b')
     487    HKL = np.array(self.HKL)
    455488    for hkl in self.HKL:
    456489        Plot.axvline(hkl[5],color='r',dashes=(5,5))
Note: See TracChangeset for help on using the changeset viewer.