Changeset 2616


Ignore:
Timestamp:
Jan 8, 2017 4:17:15 PM (5 years ago)
Author:
vondreele
Message:

add Durbin-Watson statistic to refinement results for PWDR data
some more spots work

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIgrid.py

    r2614 r2616  
    21192119        self.MaskEdit.Append(help='Load mask from file; ignore threshold',
    21202120            id=wxID_MASKLOADNOT, kind=wx.ITEM_NORMAL,text='Load mask w/o threshold')
    2121         self.MaskEdit.Append(help='Auto search for spot masks',
     2121        self.MaskEdit.Append(help='Auto search for spot masks; NB: will clear old spot masks',
    21222122            id=wxID_FINDSPOTS, kind=wx.ITEM_NORMAL,text='Auto spot masks')
    21232123        submenu.Append(help='Create an arc mask with mouse input',
     
    21292129        submenu.Append(help='Create a ring mask with mouse input',
    21302130            id=wxID_NEWMASKRING, kind=wx.ITEM_NORMAL,text='Ring mask')
    2131         submenu.Append(help='Create spot masks with mouse clicks',
     2131        submenu.Append(help='Create spot masks with mouse input',
    21322132            id=wxID_NEWMASKSPOT, kind=wx.ITEM_NORMAL,text='Spot mask')
    21332133        self.PostfillDataMenu()
     
    42714271        mainSizer.Add(wx.StaticText(G2frame.dataDisplay,-1,
    42724272            ' Data residual wR: %.3f%% on %d observations'%(data[0]['wR'],data[0]['Nobs'])))
     4273        mainSizer.Add(wx.StaticText(G2frame.dataDisplay,-1,
     4274            ' Durbin-Watson statistic: %.3f'%(data[0].get('Durbin-Watson',0.))))
    42734275        for value in data[0]:
    42744276            if 'Nref' in value:
  • trunk/GSASIIimage.py

    r2613 r2616  
    11321132    for roll in rolls:
    11331133        if np.any(roll):        #avoid [0,0]
    1134             spotMask = ma.array(spotMask,mask=(spotMask-rollImage(Image,roll)<=0.))
     1134            spotMask = ma.array(spotMask,mask=(spotMask-rollImage(Image,roll)<=0.10*np.mean(Image)))
    11351135    mags = spotMask[spotMask.nonzero()]
    11361136    indx = np.transpose(spotMask.nonzero())
     
    11461146                jndx.append([ind[1]+.5,ind[0]+.5])
    11471147    print 'Spots found: ',len(jndx)
    1148     if len(jndx) > 100:
    1149         txt = 'Found: %d. Too many spots found; are rings spotty?'%(len(jndx))
    1150         return txt
    11511148    jndx = np.array(jndx)
    11521149    peaks = jndx*pixelSize/1000.
    11531150    tth = GetTth(peaks.T[0],peaks.T[1],Controls)
    11541151    Peakarray = np.vstack((tth,peaks.T)).T
    1155     Peakarray = np.array(G2mth.sortArray(Peakarray,0))  #now in 2theta order
     1152    Peakarray = np.array(G2mth.sortArray(Peakarray,0))  #now in 2theta
     1153    if peaks.shape[0] > 100:
     1154        txt = 'More than 100 spots found: %d. Are rings spotty?'%(len(jndx))
     1155        return txt
     1156    #should be able to filter out spotty Bragg rings here
    11561157    Points = np.ones((peaks.shape[0],3))
    11571158    Points[:,:2] = Peakarray[:,1:]
    1158     Masks['Points'] = Points
     1159    Masks['Points'] = list(Points)
    11591160    return None
    11601161                   
  • trunk/GSASIIimgGUI.py

    r2611 r2616  
    13031303    def OnAutoSpotMask(event):
    13041304        'Do auto search for spot masks'
     1305        wx.MessageDialog(G2frame.dataDisplay,'NB: This will clear any old spot masks','Auto Spot Masks', wx.OK).ShowModal()
    13051306        Controls = copy.deepcopy(G2frame.PatternTree.GetItemPyData(
    1306             G2gd.GetPatternTreeItemId(G2frame,G2frame.PatternId,'Image Controls')))
     1307        G2gd.GetPatternTreeItemId(G2frame,G2frame.PatternId,'Image Controls')))
    13071308        Error = G2img.AutoSpotMasks(G2frame.ImageZ,data,Controls)
    13081309        if not Error is None:
    13091310            G2frame.ErrorDialog('Auto spot search error',Error)
    13101311        wx.CallAfter(UpdateMasks,G2frame,data)
    1311         G2plt.PlotExposedImage(G2frame,event=event)               
     1312        wx.CallAfter(G2plt.PlotExposedImage,G2frame,event=event)               
    13121313           
    13131314    def ToggleSpotMaskMode(event):
     
    16701671    G2frame.dataDisplay.SetSize(Size)
    16711672    G2frame.dataFrame.setSizePosLeft(Size)   
    1672     wx.Yield()
    16731673    if startScroll: # reset scroll to saved position
    16741674        G2frame.dataDisplay.Scroll(0,startScroll) # set to saved scroll position
  • trunk/GSASIIplot.py

    r2615 r2616  
    43494349    def OnImPick(event):
    43504350        'A object has been picked'
     4351       
    43514352        def OnDragIntBound(event):
    43524353            'Respond to the dragging of one of the integration boundaries'
     
    43754376            # compute arcs, etc
    43764377            LRAzim = Data['LRazimuth']                  #NB: integers
    4377             Nazm = Data['outAzimuths']
    4378             delAzm = float(LRAzim[1]-LRAzim[0])/Nazm
    43794378            AzmthOff = Data['azmthOff']
    43804379            IOtth = Data['IOtth']
     
    44154414            Page.figure.gca().draw_artist(pick)
    44164415            Page.canvas.blit(Page.figure.gca().bbox)
     4416           
    44174417        def OnDragMask(event):
    44184418            'Respond to the dragging of a mask'
     
    44234423            Xpos,Ypos = [event.xdata,event.ydata]
    44244424            #if Page.toolbar._active: return # zoom/pan selected
    4425             itemPicked = str(G2frame.itemPicked)
    44264425            Page.canvas.restore_region(savedplot)
    44274426            try:
     
    45784577                print('picktype {} should not happen!'.format(pickType))
    45794578                GSASIIpath.IPyBreak()
    4580             saveLinestyle = [p.get_linestyle() for p in pl]
    4581             for p in pl: p.set_linestyle('dotted') # set line as dotted
    4582             Page.canvas.draw() # refresh without dotted line & save bitmap
    4583             savedplot = Page.canvas.copy_from_bbox(Page.figure.gca().bbox)
    4584             G2frame.cid = Page.canvas.mpl_connect('motion_notify_event', OnDragMask)
    4585             for p,s in zip(pl,saveLinestyle): p.set_linestyle(s) # set back to original
     4579            if event.mouseevent.button == 3:
     4580                if pickType == 'Spot':
     4581                    print 'delete',pick.center
     4582                    del Masks['Points'][pick.itemNumber]
     4583                   
     4584                    Page.canvas.draw() # refresh without dotted line & save bitmap
     4585            else:
     4586                saveLinestyle = [p.get_linestyle() for p in pl]
     4587                for p in pl: p.set_linestyle('dotted') # set line as dotted
     4588                Page.canvas.draw() # refresh without dotted line & save bitmap
     4589                savedplot = Page.canvas.copy_from_bbox(Page.figure.gca().bbox)
     4590                G2frame.cid = Page.canvas.mpl_connect('motion_notify_event', OnDragMask)
     4591                for p,s in zip(pl,saveLinestyle): p.set_linestyle(s) # set back to original
    45864592
    45874593    def OnImRelease(event):
     
    47794785                G2frame.Razim.SetValue(Data['LRazimuth'][1])
    47804786            elif pickType == "Spot" and treeItem == 'Masks':
    4781                 # update the selected circle mask with the last drawn values
    4782                 spotnum = G2frame.itemPicked.itemNumber
    4783                 Masks['Points'][spotnum] = list(G2frame.itemPicked.center) + [
    4784                     2.*G2frame.itemPicked.radius]
     4787                if event.button == 3:
     4788                    # update the selected circle mask with the last drawn values
     4789                    spotnum = G2frame.itemPicked.itemNumber
     4790                    Masks['Points'][spotnum] = list(G2frame.itemPicked.center) + [
     4791                        2.*G2frame.itemPicked.radius]
    47854792                G2imG.UpdateMasks(G2frame,Masks)
    47864793            elif pickType.startswith('Ring') and treeItem == 'Masks':
     
    51925199    atomData = data['Atoms']
    51935200    mapPeaks = []
    5194     vdWRadii = generalData['vdWRadii']
    51955201    if generalData.get('DisAglCtrls',{}):
    51965202        BondRadii = generalData['DisAglCtrls']['BondRadii']
  • trunk/GSASIIstrIO.py

    r2589 r2616  
    27482748                    print >>pFile,' Final refinement RF, RF^2 = %.2f%%, %.2f%% on %d reflections'   \
    27492749                        %(Histogram['Residuals'][pfx+'Rf'],Histogram['Residuals'][pfx+'Rf^2'],Histogram['Residuals'][pfx+'Nref'])
     2750                    print >>pFile,' Durbin-Watson statistic = %.3f'%(Histogram['Residuals']['Durbin-Watson'])
    27502751                    print >>pFile,' Bragg intensity sum = %.3g'%(Histogram['Residuals'][pfx+'sumInt'])
    27512752               
  • trunk/GSASIIstrMath.py

    r2598 r2616  
    37573757            yd[xB:xF] = y[xB:xF]-yc[xB:xF]
    37583758            W = wtFactor*w
    3759             wdy = -ma.sqrt(W[xB:xF])*(yd[xB:xF])
     3759            wdy = -ma.sqrt(w[xB:xF])*(yd[xB:xF])
     3760            Histogram['Residuals']['Durbin-Watson'] = ma.sum(ma.diff(wdy)**2)/ma.sum(wdy**2)
     3761            wdy *= wtFactor
    37603762            Histogram['Residuals']['Nobs'] = ma.count(x[xB:xF])
    37613763            Nobs += Histogram['Residuals']['Nobs']
Note: See TracChangeset for help on using the changeset viewer.