Changeset 3761


Ignore:
Timestamp:
Dec 12, 2018 2:38:33 PM (5 years ago)
Author:
vondreele
Message:

avoid replotting structure if atom refine flags are changed
add new plot for structure factors as 1D stick diagram - work in progress

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIdataGUI.py

    r3757 r3761  
    49914991        # PWDR & SASD
    49924992        G2G.Define_wxId('wxID_PWDANALYSIS','wxID_PWDCOPY','wxID_PLOTCTRLCOPY','wxID_MERGEHKL',
    4993             'wxID_PWDHKLPLOT', 'wxID_PWD3DHKLPLOT','wxID_3DALLHKLPLOT',)           
     4993            'wxID_PWDHKLPLOT', 'wxID_PWD3DHKLPLOT','wxID_3DALLHKLPLOT','wxID_1DHKLSTICKPLOT',)           
    49944994        self.PWDRMenu = wx.MenuBar()
    49954995        self.PrefillDataMenu(self.PWDRMenu)
     
    50125012        self.ErrorAnal.Append(G2G.wxID_PWDANALYSIS,'Error Analysis','Error analysis on single crystal data')
    50135013        self.ErrorAnal.Append(G2G.wxID_MERGEHKL,'Merge HKLs','Transform & merge HKLF data to new histogram')
     5014        self.ErrorAnal.Append(G2G.wxID_1DHKLSTICKPLOT,'Plot 1D HKLs','Plot of HKLs from single crystal data in 1D')
    50145015        self.ErrorAnal.Append(G2G.wxID_PWD3DHKLPLOT,'Plot 3D HKLs','Plot HKLs from single crystal data in 3D')
    50155016        self.ErrorAnal.Append(G2G.wxID_3DALLHKLPLOT,'Plot all 3D HKLs','Plot HKLs from all single crystal data in 3D')
     
    51745175        self.ReflMenu.Append(menu=self.ReflEdit, title='Reflection List')
    51755176        self.SelectPhase = self.ReflEdit.Append(G2G.wxID_SELECTPHASE,'Select phase','Select phase for reflection list')
    5176         self.ReflEdit.Append(G2G.wxID_PWDHKLPLOT,'Plot HKLs','Plot HKLs from powder pattern')
    5177         self.ReflEdit.Append(G2G.wxID_PWD3DHKLPLOT,'Plot 3D HKLs','Plot HKLs from powder pattern in 3D')
     5177        self.ReflEdit.Append(G2G.wxID_1DHKLSTICKPLOT,'Plot 1D HKLs','Plot of HKLs in 1D')
     5178        self.ReflEdit.Append(G2G.wxID_PWDHKLPLOT,'Plot HKLs','Plot HKLs in 2D')
     5179        self.ReflEdit.Append(G2G.wxID_PWD3DHKLPLOT,'Plot 3D HKLs','Plot HKLs in 3D')
    51785180        self.PostfillDataMenu()
    51795181       
     
    73187320            [(Tmin,Tmax),[Tmin,Tmax]])
    73197321        wx.CallAfter(UpdatePWHKPlot,G2frame,kind,item) # redisplay data screen
     7322       
     7323    def OnPlot1DHKL(event):
     7324        refList = data[1]['RefList']
     7325        G2plt.Plot1DSngl(G2frame,newPlot=True,hklRef=refList,Super=Super,Title=phaseName)
    73207326
    73217327    def OnPlot3DHKL(event):
     
    75137519        G2frame.Bind(wx.EVT_MENU, OnErrorAnalysis, id=G2G.wxID_PWDANALYSIS)
    75147520        G2frame.Bind(wx.EVT_MENU, OnMergeHKL, id=G2G.wxID_MERGEHKL)
     7521        G2frame.Bind(wx.EVT_MENU, OnPlot1DHKL, id=G2G.wxID_1DHKLSTICKPLOT)
    75157522        G2frame.Bind(wx.EVT_MENU, OnPlot3DHKL, id=G2G.wxID_PWD3DHKLPLOT)
    75167523        G2frame.Bind(wx.EVT_MENU, OnPlotAll3DHKL, id=G2G.wxID_3DALLHKLPLOT)
  • trunk/GSASIIphsGUI.py

    r3759 r3761  
    28202820
    28212821            r,c =  event.GetRow(),event.GetCol()
     2822            replot = True
    28222823            if r >= 0 and c >= 0:
    28232824                ci = colLabels.index('I/A')
     
    28802881                    ci = colLabels.index('I/A')
    28812882                    atomData[r][c] = atomData[r][c].replace(rbAtmDict.get(atomData[r][ci+8],''),'')
     2883                    replot = False
    28822884                elif Atoms.GetColLabelValue(c) in ['Mx','My','Mz']:
    28832885                    value = atomData[r][c]
     
    28902892                        if iM == CSI[0][i]:
    28912893                            atomData[r][i+colLabels.index('Mx')] = value*CSI[1][i]
    2892                 if 'Atoms' in data['Drawing']:
     2894                if 'Atoms' in data['Drawing'] and replot:
    28932895                    ci = colLabels.index('I/A')
    28942896                    DrawAtomsReplaceByID(data['Drawing'],ci+8,atomData[r],ID)
  • trunk/GSASIIplot.py

    r3759 r3761  
    2424:func:`PlotStructure`         Crystal structure plotting with balls, sticks, lines,
    2525                              ellipsoids, polyhedra and magnetic moments
     26:func:'Plot1DSngl'            1D stick plots of structure factors                             
    2627:func:`PlotSngl`              Structure factor plotting
    2728:func:`Plot3DSngl`            3D Structure factor plotting
     
    10681069        Plot.set_ylim((HKLmin[pzone[izone][1]],HKLmax[pzone[izone][1]]))
    10691070        Page.canvas.draw()
     1071       
     1072################################################################################
     1073##### Plot1DSngl
     1074################################################################################
     1075def Plot1DSngl(G2frame,newPlot=False,hklRef=None,Super=0,Title=False):
     1076    '''1D Structure factor plotting package - displays reflections as sticks proportional
     1077        to F, F**2, etc. as requested
     1078    '''
     1079    from matplotlib.collections import LineCollection
     1080    print('1D stick plot - TBD')
     1081    global xylim
     1082    def OnKeyPress(event):
     1083#        if event.key == 'u':
     1084#            if Page.Offset[1] < 100.:
     1085#                Page.Offset[1] += 1.
     1086#        elif event.key == 'd':
     1087#            if Page.Offset[1] > 0.:
     1088#                Page.Offset[1] -= 1.
     1089#        elif event.key == 'l':
     1090#            Page.Offset[0] -= 1.
     1091#        elif event.key == 'r':
     1092#            Page.Offset[0] += 1.
     1093#        elif event.key == 'o':
     1094#            Page.Offset = [0,0]
     1095#        elif event.key == 's':
     1096#            if len(XY):
     1097#                G2IO.XYsave(G2frame,XY,labelX,labelY,names)
     1098#            if len(XY2):
     1099#                G2IO.XYsave(G2frame,XY2,labelX,labelY,names2)
     1100##        else:
     1101##            return
     1102        Draw()
     1103
     1104    def OnMotion(event):
     1105        xpos = event.xdata
     1106        if xpos:                                        #avoid out of frame mouse position
     1107            ypos = event.ydata
     1108            Page.canvas.SetCursor(wx.CROSS_CURSOR)
     1109            try:
     1110                G2frame.G2plotNB.status.SetStatusText('X =%9.3f %s =%9.3f'%(xpos,Title,ypos),1)                   
     1111            except TypeError:
     1112                G2frame.G2plotNB.status.SetStatusText('Select '+Title+' pattern first',1)
     1113               
     1114    def Draw():
     1115        global xylim
     1116        Plot.clear()
     1117        Plot.set_title(Title)
     1118        Plot.set_xlabel(r'd-spacing',fontsize=14)
     1119        Plot.set_ylabel(r'Fsq',fontsize=14)
     1120        colors=['b','r','g','c','m','k']
     1121        Page.keyPress = OnKeyPress
     1122       
     1123        X = hklRef.T[4+Super]
     1124        Y = hklRef.T[8+Super]
     1125        Z = hklRef.T[9+Super]
     1126        Plot.plot([X,X],[np.zeros_like(X),Y],color=colors[0])
     1127        Plot.plot([X,X],[np.zeros_like(X),Z],color=colors[1])
     1128        Plot.plot([X,X],[np.zeros_like(X),Y-Z],color=colors[2])
     1129       
     1130        if not newPlot:
     1131            Page.toolbar.push_current()
     1132            Plot.set_xlim(xylim[0])
     1133            Plot.set_ylim(xylim[1])
     1134            xylim = []
     1135            Page.toolbar.push_current()
     1136            Page.toolbar.draw()
     1137            Page.canvas.draw()
     1138        else:
     1139            Page.canvas.draw()
     1140
     1141    new,plotNum,Page,Plot,lim = G2frame.G2plotNB.FindPlotTab(Title,'mpl')
     1142    Page.Offset = [0,0]
     1143    if not new:
     1144        if not newPlot:
     1145            xylim = lim
     1146    else:
     1147        newPlot = True
     1148        Page.canvas.mpl_connect('key_press_event', OnKeyPress)
     1149        Page.canvas.mpl_connect('motion_notify_event', OnMotion)
     1150        Page.Offset = [0,0]
     1151   
     1152    Page.Choice = (' key press','f: plot Fhkl','s: plot F^2hkl','d: d-spacing plot','q: q plot')
     1153    Draw()
     1154   
    10701155       
    10711156################################################################################
     
    23642449        Page.canvas.mpl_disconnect(b)
    23652450    Page.bindings = []
    2366     Page.bindings.append(
    2367         Page.canvas.mpl_connect('key_press_event', OnPlotKeyPress)
    2368     )
     2451    Page.bindings.append(Page.canvas.mpl_connect('key_press_event', OnPlotKeyPress))
    23692452    if 'PWDR' in G2frame.GPXtree.GetItemText(G2frame.PickId):
    23702453        Histograms,Phases = G2frame.GetUsedHistogramsAndPhasesfromTree()
  • trunk/GSASIIpwdGUI.py

    r3753 r3761  
    44044404    if 'UsrReject' in Controls:
    44054405        dMin = Controls['UsrReject'].get('MinD',0.05)
     4406
     4407    def OnPlot1DHKL(event):
     4408        phaseName = G2frame.RefList
     4409        if phaseName not in ['Unknown',]:
     4410            pId = G2gd.GetGPXtreeItemId(G2frame,G2frame.root,'Phases')
     4411            phaseId =  G2gd.GetGPXtreeItemId(G2frame,pId,phaseName)
     4412            General = G2frame.GPXtree.GetItemPyData(phaseId)['General']
     4413            Super = General.get('Super',0)
     4414        else:
     4415            Super = 0
     4416        if 'list' in str(type(data)):   #single crystal data is 2 dict in list
     4417            refList = data[1]['RefList']
     4418        else:                           #powder data is a dict of dicts; each same structure as SC 2nd dict
     4419            if 'RefList' in data[phaseName]:
     4420                refList = np.array(data[phaseName]['RefList'])
     4421            else:
     4422                wx.MessageBox('No reflection list - do Refine first',caption='Reflection plotting')
     4423                return
     4424        G2plt.Plot1DSngl(G2frame,newPlot=True,hklRef=refList,Super=Super,Title=phaseName)
     4425
    44064426    def OnPlotHKL(event):
    44074427        '''Plots a layer of reflections
     
    46224642    if HKLF:
    46234643        G2frame.Bind(wx.EVT_MENU, OnPlotHKL, id=G2G.wxID_PWDHKLPLOT)
     4644        G2frame.Bind(wx.EVT_MENU, OnPlot1DHKL, id=G2G.wxID_1DHKLSTICKPLOT)
    46244645        G2frame.Bind(wx.EVT_MENU, OnPlot3DHKL, id=G2G.wxID_PWD3DHKLPLOT)
    46254646        G2frame.dataWindow.SelectPhase.Enable(False)
    46264647    else:
    46274648        G2frame.Bind(wx.EVT_MENU, OnSelectPhase, id=G2G.wxID_SELECTPHASE)
     4649        G2frame.Bind(wx.EVT_MENU, OnPlot1DHKL, id=G2G.wxID_1DHKLSTICKPLOT)
    46284650        G2frame.Bind(wx.EVT_MENU, OnPlotHKL, id=G2G.wxID_PWDHKLPLOT)
    46294651        G2frame.Bind(wx.EVT_MENU, OnPlot3DHKL, id=G2G.wxID_PWD3DHKLPLOT)
Note: See TracChangeset for help on using the changeset viewer.