Changeset 513


Ignore:
Timestamp:
Mar 5, 2012 4:33:56 PM (10 years ago)
Author:
vondreele
Message:

cleanup wxID entries
implement powder pattern error analysis
implement I/sig plot option

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIgrid.py

    r503 r513  
    3838htmlFirstUse = True
    3939
     40[ wxID_FOURCALC,
     41] = [wx.NewId() for item in range(1)]
     42
     43[ wxID_PWDRADD, wxID_HKLFADD, wxID_DATADELETE,
     44] = [wx.NewId() for item in range(3)]
     45
    4046[ wxID_ATOMSEDITADD, wxID_ATOMSEDITINSERT, wxID_ATOMSEDITDELETE, wxID_ATOMSREFINE,
    4147    wxID_ATOMSMODIFY, wxID_ATOMSTRANSFORM, wxID_ATOMSTESTADD, wxID_ATONTESTINSERT,
    4248    wxID_RELOADDRAWATOMS,wxID_ATOMSDISAGL,
    43 ] = [wx.NewId() for _init_coll_Atom_Items in range(10)]
    44 
    45 [ wxID_PWDRADD, wxID_HKLFADD, wxID_DATADELETE,
    46 ] = [wx.NewId() for _init_coll_Data_Items in range(3)]
     49] = [wx.NewId() for item in range(10)]
    4750
    4851[ wxID_DRAWATOMSTYLE, wxID_DRAWATOMLABEL, wxID_DRAWATOMCOLOR, wxID_DRAWATOMRESETCOLOR,
    4952    wxID_DRAWVIEWPOINT, wxID_DRAWTRANSFORM, wxID_DRAWDELETE, wxID_DRAWFILLCELL,
    5053    wxID_DRAWADDEQUIV, wxID_DRAWFILLCOORD, wxID_DRAWDISAGLTOR,  wxID_DRAWPLANE,
    51 ] = [wx.NewId() for _init_coll_DrawAtom_Items in range(12)]
     54] = [wx.NewId() for item in range(12)]
     55
     56[ wxID_CLEARTEXTURE,wxID_REFINETEXTURE,
     57] = [wx.NewId() for item in range(2)]
     58
     59[ wxID_PAWLEYLOAD, wxID_PAWLEYIMPORT, wxID_PAWLEYDELETE, wxID_PAWLEYESTIMATE,
     60] = [wx.NewId() for item in range(4)]
    5261
    5362[ wxID_IMCALIBRATE,wxID_IMRECALIBRATE,wxID_IMINTEGRATE, wxID_IMCLEARCALIB, 
    5463    wxID_IMCOPYCONTROLS, wxID_INTEGRATEALL, wxID_IMSAVECONTROLS, wxID_IMLOADCONTROLS,
    55 ] = [wx.NewId() for _init_coll_IMAGE_Items in range(8)]
     64] = [wx.NewId() for item in range(8)]
    5665
    5766[ wxID_MASKCOPY, wxID_MASKSAVE, wxID_MASKLOAD,
    58 ] = [wx.NewId() for _init_coll_MASK_Items in range(3)]
    59 
    60 [ wxID_PAWLEYLOAD, wxID_PAWLEYIMPORT, wxID_PAWLEYDELETE, wxID_PAWLEYESTIMATE,
    61 ] = [wx.NewId() for _init_coll_PAWLEY_Items in range(4)]
     67] = [wx.NewId() for item in range(3)]
     68
     69[ wxID_BACKCOPY,wxID_LIMITCOPY,wxID_SAMPLECOPY,
     70] = [wx.NewId() for item in range(3)]
    6271
    6372[ wxID_INSTPRMRESET,wxID_CHANGEWAVETYPE,wxID_INSTCOPY,
    64 ] = [wx.NewId() for _init_coll_INST_Items in range(3)]
    65 
    66 [ wxID_INDXRELOAD,
    67 ] = [wx.NewId() for _init_coll_IndPeaks_Items in range(1)]
     73] = [wx.NewId() for item in range(3)]
    6874
    6975[ wxID_UNDO,wxID_LSQPEAKFIT,wxID_LSQONECYCLE,wxID_RESETSIGGAM,wxID_CLEARPEAKS,
    70 ] = [wx.NewId() for _init_coll_PEAK_Items in range(5)]
    71 
    72 [  wxID_INDEXPEAKS, wxID_REFINECELL, wxID_COPYCELL, wxID_MAKENEWPHASE,
    73 ] = [wx.NewId() for _init_coll_INDEX_Items in range(4)]
    74 
    75 [ wxID_BACKCOPY,
    76 ] = [wx.NewId() for _init_coll_Back_Items in range(1)]
    77 
    78 [ wxID_LIMITCOPY,
    79 ] = [wx.NewId() for _init_coll_Limit_Items in range(1)]
    80 
    81 [ wxID_SAMPLECOPY,
    82 ] = [wx.NewId() for _init_coll_Sample_Items in range(1)]
     76] = [wx.NewId() for item in range(5)]
     77
     78[  wxID_INDXRELOAD, wxID_INDEXPEAKS, wxID_REFINECELL, wxID_COPYCELL, wxID_MAKENEWPHASE,
     79] = [wx.NewId() for item in range(5)]
    8380
    8481[ wxID_CONSTRAINTADD,wxID_EQUIVADD,wxID_HOLDADD,wxID_FUNCTADD,
    85 ] = [wx.NewId() for _init_coll_Constraint_Items in range(4)]
    86 
    87 [ wxID_RESTRAINTADD,
    88 ] = [wx.NewId() for _init_coll_Restraint_Items in range(1)]
     82] = [wx.NewId() for item in range(4)]
     83
     84[ wxID_RESTRAINTADD,wxID_PWDANALYSIS,
     85] = [wx.NewId() for item in range(2)]
    8986
    9087[ wxID_SAVESEQSEL,
    91 ] = [wx.NewId() for _init_coll_Sequential_Items in range(1)]
     88] = [wx.NewId() for item in range(1)]
    9289
    9390[ wxID_SELECTPHASE,
    94 ] = [wx.NewId() for _init_coll_Refl_Items in range(1)]
    95 
    96 [ wxID_FOURCALC,
    97 ] = [wx.NewId() for _init_coll_Genrl_Items in range(1)]
    98 
    99 [ wxID_CLEARTEXTURE,wxID_REFINETEXTURE,
    100 ] = [wx.NewId() for _init_coll_Texture_Items in range(2)]
     91] = [wx.NewId() for item in range(1)]
    10192
    10293[ wxID_PDFCOPYCONTROLS, wxID_PDFSAVECONTROLS, wxID_PDFLOADCONTROLS,
    10394    wxID_PDFCOMPUTE, wxID_PDFCOMPUTEALL, wxID_PDFADDELEMENT, wxID_PDFDELELEMENT,
    104 ] = [wx.NewId() for _init_coll_PDF_Items in range(7)]
     95] = [wx.NewId() for item in range(7)]
    10596
    10697VERY_LIGHT_GREY = wx.Colour(235,235,235)
     
    283274        self.SequentialFile.Append(id=wxID_SAVESEQSEL, kind=wx.ITEM_NORMAL,text='Save...',
    284275            help='Save selected sequential refinement results')
     276           
     277# PDR
     278        self.ErrorMenu = wx.MenuBar()
     279        self.ErrorAnal = wx.Menu(title='')
     280        self.ErrorMenu.Append(menu=self.ErrorAnal,title='Analysis')
     281        self.ErrorMenu.Append(menu=MyHelp(self,helpType='PWD Analysis'),title='&Help')
     282        self.ErrorAnal.Append(id=wxID_PWDANALYSIS,kind=wx.ITEM_NORMAL,text='Analyze',
     283            help='Error analysis on ppowder pattern')
    285284           
    286285# PDR / Limits
     
    14171416#    AtomRestrData = data['AtomRestr']
    14181417
    1419     G2frame.dataDisplay.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED, OnPageChanged)       
     1418    G2frame.dataDisplay.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED, OnPageChanged)
     1419   
     1420def UpdatePWDPlot(G2frame,item):
     1421
     1422    def OnErrorAnalysis(event):
     1423        G2plt.PlotDeltSig(G2frame)
     1424   
     1425    defWid = [250,150]
     1426    if G2frame.dataDisplay:
     1427        G2frame.dataDisplay.Destroy()
     1428    G2frame.dataFrame.SetMenuBar(G2frame.dataFrame.ErrorMenu)
     1429    G2frame.dataFrame.Bind(wx.EVT_MENU,OnErrorAnalysis, id=wxID_PWDANALYSIS)
     1430    G2frame.dataFrame.setSizePosLeft(defWid)
     1431    wx.TextCtrl(parent=G2frame.dataFrame,size=G2frame.dataFrame.GetClientSize(),
     1432        style=wx.TE_MULTILINE,
     1433        value='See plot window for powder data display\nor select a data item in histogram')
     1434    G2plt.PlotPatterns(G2frame,newPlot=True)
     1435           
    14201436             
    14211437def UpdateHKLControls(G2frame,data):
     
    16081624        elif 'PWDR' in G2frame.PatternTree.GetItemText(item):
    16091625            G2frame.ExportPattern.Enable(True)
    1610             G2frame.dataFrame.setSizePosLeft(defWid)
    1611             wx.TextCtrl(parent=G2frame.dataFrame,size=G2frame.dataFrame.GetClientSize(),
    1612                 style=wx.TE_MULTILINE,
    1613                 value='See plot window for powder data display\nor select a data item in histogram')
    1614             G2plt.PlotPatterns(G2frame,newPlot=True)
     1626            UpdatePWDPlot(G2frame,item)
    16151627        elif 'HKLF' in G2frame.PatternTree.GetItemText(item):
    16161628            G2frame.Sngl = item
  • trunk/GSASIIplot.py

    r505 r513  
    173173        bookmark = bookmark.strip(')').replace('(','_')
    174174        G2gd.ShowHelp(bookmark,self.TopLevelParent)
     175
     176################################################################################
     177##### PlotSngl
     178################################################################################
    175179           
    176180def PlotSngl(self,newPlot=False):
     
    302306        Page.canvas.draw()
    303307       
     308################################################################################
     309##### PlotPatterns
     310################################################################################
     311           
    304312def PlotPatterns(G2frame,newPlot=False):
    305313    '''Powder pattern plotting package - displays single or multiple powder patterns as intensity vs
     
    322330            else:
    323331                G2frame.Weight = True
    324             print 'error analysis:',G2frame.Weight
     332                G2frame.SinglePlot = True
     333            newPlot = True
    325334        elif event.key == 'n':
    326335            if G2frame.Contour:
     
    382391                else:
    383392                    G2frame.SinglePlot = True
     393            newPlot = True
    384394        elif event.key == '+':
    385395            if G2frame.PickId:
     
    572582            Choice = (' key press','l: offset left','r: offset right','d: offset down',
    573583                'u: offset up','o: reset offset','n: log(I) on','c: contour on',
    574                 'q: toggle q plot','s: toggle single plot','w: toggle error analysis','+: no selection')
     584                'q: toggle q plot','s: toggle single plot','w: toggle divide by sig','+: no selection')
    575585    cb = wx.ComboBox(G2frame.G2plotNB.status,style=wx.CB_DROPDOWN|wx.CB_READONLY,
    576586        choices=Choice)
     
    624634    else:       
    625635        Plot.set_xlabel(r'$\mathsf{2\theta}$',fontsize=14)
    626     Plot.set_ylabel('Intensity',fontsize=12)
     636    if G2frame.Weight:
     637        Plot.set_ylabel(r'$\mathsf{I/\sigma(I)}$',fontsize=14)
     638    else:
     639        Plot.set_ylabel('Intensity',fontsize=12)
    627640    if G2frame.Contour:
    628641        ContourZ = []
     
    667680                W = xye[4]+offset*N
    668681                D = xye[5]-Ymax*G2frame.delOffset
    669                 if G2frame.Weight:
    670                     DS = xye[5]*np.sqrt(xye[2])
    671                     PlotDeltSig(G2frame,[X,DS])
    672682                if G2frame.logPlot:
    673683                    Plot.semilogy(X,Y,colors[N%6]+'+',picker=3.,clip_on=False,nonposy='mask')
    674684                    Plot.semilogy(X,Z,colors[(N+1)%6],picker=False,nonposy='mask')
    675685                    Plot.semilogy(X,W,colors[(N+2)%6],picker=False,nonposy='mask')
     686                elif G2frame.Weight:
     687                    DY = xye[1]*np.sqrt(xye[2])
     688                    DYmax = max(DY)
     689                    DZ = xye[3]*np.sqrt(xye[2])
     690                    DS = xye[5]*np.sqrt(xye[2])-DYmax*G2frame.delOffset
     691                    Plot.plot(X,DY,colors[N%6]+'+',picker=3.,clip_on=False)
     692                    Plot.plot(X,DZ,colors[(N+1)%6],picker=False)
     693                    Plot.plot(X,DS,colors[(N+3)%6],picker=False)
     694                    Plot.axhline(0.,color=wx.BLACK)
    676695                else:
    677696                    Plot.plot(X,Y,colors[N%6]+'+',picker=3.,clip_on=False)
     
    749768    G2frame.Pwdr = True
    750769   
    751 def PlotDeltSig(G2frame,XDS):
     770################################################################################
     771##### PlotDeltSig
     772################################################################################
     773           
     774def PlotDeltSig(G2frame):
    752775    try:
    753776        plotNum = G2frame.G2plotNB.plotList.index('Error analysis')
    754777        Page = G2frame.G2plotNB.nb.GetPage(plotNum)
    755         Page.figure.clf()
    756778        Plot = Page.figure.gca()          #get a fresh plot after clf()
    757779    except ValueError:
     
    761783        plotNum = G2frame.G2plotNB.plotList.index('Error analysis')
    762784        Page = G2frame.G2plotNB.nb.GetPage(plotNum)
     785    PatternId = G2frame.PatternId
     786    Pattern = G2frame.PatternTree.GetItemPyData(PatternId)
     787    Pattern.append(G2frame.PatternTree.GetItemText(PatternId))
     788    limits = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,PatternId, 'Limits'))[1]
     789    xye = np.array(Pattern[1])
     790    xmin = np.searchsorted(xye[0],limits[0])
     791    xmax = np.searchsorted(xye[0],limits[1])
     792    X = xye[0][xmin:xmax]
     793    DS = xye[5][xmin:xmax]*np.sqrt(xye[2][xmin:xmax])
    763794    Page.SetFocus()
     795    Page.figure.clf()
     796    Plot1 = Page.figure.add_subplot(211)
     797    Page.figure.subplots_adjust(hspace=0.25)
    764798    G2frame.G2plotNB.status.DestroyChildren()
    765     Plot.set_title('Delta/sigma')
    766     X,DS = XDS
    767     Plot.set_xlabel(r'$\mathsf{2\theta}$',fontsize=14)
    768     Plot.set_ylabel(r'$\mathsf{\Delta/\sigma}$',fontsize=14)
    769     Plot.plot(X,DS,'k',picker=False)
     799    Plot1.set_title(r'$\mathsf{\Delta/\sigma}$ analysis')
     800    Plot1.set_xlabel(r'$\mathsf{2\theta}$',fontsize=14)
     801    Plot1.set_ylabel(r'$\mathsf{\Delta/\sigma}$',fontsize=14)
     802    Plot1.plot(X,DS,'k',picker=False)
     803    DS.sort()
     804    EDS = np.zeros_like(DS)
     805    DX = np.linspace(0.,1.,num=len(DS),endpoint=True)
     806    T = np.where(DX != 0.0,np.sqrt(np.log(1.0/DX**2)),0.0)
     807    top = 2.515517+0.802853*T+0.010328*T**2
     808    bot = 1.0+1.432788*T+0.189269*T**2+0.001308*T**3
     809    EDS = np.where(DX>0,-(T-top/bot),(T-top/bot))
     810    EDS = np.where(DX==0.,0.,EDS)
     811    Plot2 = Page.figure.add_subplot(212)
     812    Plot2.set_xlabel(r'expected $\mathsf{\Delta/\sigma}$',fontsize=14)
     813    Plot2.set_ylabel(r'observed $\mathsf{\Delta/\sigma}$',fontsize=14)
     814    Plot2.plot(EDS,DS,'r+')
    770815    Page.canvas.draw()
    771    
    772    
     816       
     817################################################################################
     818##### PlotISFG
     819################################################################################
     820           
    773821def PlotISFG(G2frame,newPlot=False,type=''):
    774822    ''' PLotting package for PDF analysis; displays I(q), S(q), F(q) and G(r) as single
     
    9851033        Page.canvas.draw()
    9861034       
     1035################################################################################
     1036##### PlotXY
     1037################################################################################
     1038           
    9871039def PlotXY(G2frame,XY,newPlot=False,type=''):
    9881040    '''simple plot of xy data, used for diagnostic purposes
     
    10341086        Page.canvas.draw()
    10351087
     1088################################################################################
     1089##### PlotPowderLines
     1090################################################################################
     1091           
    10361092def PlotPowderLines(G2frame):
    10371093    ''' plotting of powder lines (i.e. no powder pattern) as sticks
     
    10861142    Page.toolbar.push_current()
    10871143
     1144################################################################################
     1145##### PlotPeakWidths
     1146################################################################################
     1147           
    10881148def PlotPeakWidths(G2frame):
    10891149    ''' Plotting of instrument broadening terms as function of 2-theta (future TOF)
     
    11761236    Page.canvas.draw()
    11771237   
     1238################################################################################
     1239##### PlotSizeStrainPO
     1240################################################################################
     1241           
    11781242def PlotSizeStrainPO(G2frame,data,Start=False):
    11791243    '''Plot 3D mustrain/size/preferred orientation figure. In this instance data is for a phase
     
    13301394    Page.canvas.draw()
    13311395   
     1396################################################################################
     1397##### PlotTexture
     1398################################################################################
     1399           
    13321400def PlotTexture(G2frame,data,newPlot=False,Start=False):
    13331401    '''Pole figure, inverse pole figure, 3D pole distribution and 3D inverse pole distribution
     
    14671535    Page.canvas.draw()
    14681536
     1537################################################################################
     1538##### PlotCovariance
     1539################################################################################
     1540           
    14691541def PlotCovariance(G2frame,Data={}):
    14701542    if not Data:
     
    15471619    Page.canvas.draw()
    15481620   
     1621################################################################################
     1622##### PlotSeq
     1623################################################################################
     1624           
    15491625def PlotSeq(G2frame,SeqData,SeqSig,SeqNames,sampleParm):
    15501626   
     
    15881664            Page.canvas.draw()           
    15891665    Draw(True)
     1666           
     1667################################################################################
     1668##### PlotExposedImage & PlotImage
     1669################################################################################
    15901670           
    15911671def PlotExposedImage(G2frame,newPlot=False,event=None):
     
    20272107        wx.EndBusyCursor()
    20282108       
     2109################################################################################
     2110##### PlotIntegration
     2111################################################################################
     2112           
    20292113def PlotIntegration(G2frame,newPlot=False,event=None):
    20302114    '''Plot of 2D image after image integration with 2-theta and azimuth as coordinates
     
    20892173        Page.canvas.draw()
    20902174               
     2175################################################################################
     2176##### PlotTRImage
     2177################################################################################
     2178           
    20912179def PlotTRImage(G2frame,tax,tay,taz,newPlot=False):
    20922180    '''a test plot routine - not normally used
     
    21622250        Page.canvas.draw()
    21632251       
     2252################################################################################
     2253##### PlotStructure
     2254################################################################################
     2255           
    21642256def PlotStructure(G2frame,data):
    21652257    '''Crystal structure plotting package. Can show structures as balls, sticks, lines,
Note: See TracChangeset for help on using the changeset viewer.