Changeset 4333


Ignore:
Timestamp:
Feb 28, 2020 4:19:30 AM (20 months ago)
Author:
vondreele
Message:

work on spot masking; change some text, menu names, etc.
Add menu item for Auto search for selected images.

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIdataGUI.py

    r4317 r4333  
    55585558        # IMG / Masks
    55595559        G2G.Define_wxId('wxID_MASKCOPY', 'wxID_MASKSAVE', 'wxID_MASKLOAD', 'wxID_NEWMASKSPOT', 'wxID_NEWMASKARC', 'wxID_NEWMASKRING',
    5560             'wxID_NEWMASKFRAME', 'wxID_NEWMASKPOLY','wxID_NEWMASKXLINE','wxID_NEWMASKYLINE','wxID_MASKLOADNOT', 'wxID_FINDSPOTS', 'wxID_DELETESPOTS',)
     5560            'wxID_NEWMASKFRAME', 'wxID_NEWMASKPOLY','wxID_NEWMASKXLINE','wxID_NEWMASKYLINE','wxID_MASKLOADNOT',
     5561            'wxID_FINDSPOTS', 'wxID_AUTOFINDSPOTS', 'wxID_DELETESPOTS',)
    55615562        self.MaskMenu = wx.MenuBar()
    55625563        self.PrefillDataMenu(self.MaskMenu)
     
    55695570        self.MaskEdit.Append(G2G.wxID_MASKLOADNOT,'Load mask','Load mask from file; ignoring threshold')
    55705571        self.MaskEdit.Append(G2G.wxID_MASKLOAD,'Load mask w/threshold','Load mask from file keeping the threshold value')
    5571         self.MaskEdit.Append(G2G.wxID_FINDSPOTS,'Auto spot masks','Auto search for spot masks; NB: will clear old spot masks')
     5572        self.MaskEdit.Append(G2G.wxID_FINDSPOTS,'Spot mask search','Search for spot mask; NB: slow')
     5573        self.MaskEdit.Append(G2G.wxID_AUTOFINDSPOTS,'Auto spot mask search','Auto spot mask ssearch; NB: slow')
    55725574        self.MaskEdit.Append(G2G.wxID_DELETESPOTS,'Delete spot masks','Delete all spot masks')
    55735575        submenu.Append(G2G.wxID_NEWMASKARC,'Arc mask','Create an arc mask with mouse input')
  • trunk/GSASIIimgGUI.py

    r4332 r4333  
    16491649            dlg.Destroy()
    16501650           
    1651     def OnAutoSpotMask(event):
     1651    def OnFindSpotMask(event):
    16521652        'Do auto search for spot masks'
    1653         if wx.MessageDialog(G2frame.dataWindow,'NB: This will clear any old spot masks',
    1654             'Auto Spot Masks', wx.OK|wx.CANCEL).ShowModal() == wx.ID_OK:
    1655             Controls = copy.deepcopy(G2frame.GPXtree.GetItemPyData(
    1656                 G2gd.GetGPXtreeItemId(G2frame,G2frame.Image,'Image Controls')))
     1653        if wx.MessageDialog(G2frame.dataWindow,'NB: This is slow (5-10min)',
     1654            'Spot mask search', wx.OK|wx.CANCEL).ShowModal() == wx.ID_OK:
     1655            Controls = G2frame.GPXtree.GetItemPyData(
     1656                G2gd.GetGPXtreeItemId(G2frame,G2frame.Image,'Image Controls'))
    16571657            wave = Controls['wavelength']
    16581658            LUtth = np.array(Controls['IOtth'])
     
    16661666            time0 = time.time()
    16671667            data['SpotMask']['spotMask'] = G2img.AutoSpotMask(G2frame.ImageZ,data,Controls,nChans,dlg)
    1668             print(' Autospot processing time: %.2f m'%((time.time()-time0)/60.))
     1668            print(' Spot masksearch time: %.2f m'%((time.time()-time0)/60.))
    16691669            wx.CallAfter(UpdateMasks,G2frame,data)
    16701670            wx.CallAfter(G2plt.PlotExposedImage,G2frame,event=event)
     1671        else:
     1672            print(' Spot mask search not done')
     1673           
     1674    def OnAutoFindSpotMask(event):
     1675        Names = G2gd.GetGPXtreeDataNames(G2frame,['IMG ',])
     1676        dlg = G2G.G2MultiChoiceDialog(G2frame,'Automatic spot mask search','Select images to spot mask:',Names)
     1677        try:
     1678            if dlg.ShowModal() == wx.ID_OK:
     1679                items = dlg.GetSelections()
     1680                G2frame.EnablePlot = False
     1681                for item in items:
     1682                    name = Names[item]
     1683                    print ('Spot search for'+name)
     1684                    G2frame.Image = G2gd.GetGPXtreeItemId(G2frame,G2frame.root,name)
     1685                    Controls = G2frame.GPXtree.GetItemPyData(G2gd.GetGPXtreeItemId(G2frame,G2frame.Image,'Image Controls'))
     1686                    Mask = G2frame.GPXtree.GetItemPyData(G2gd.GetGPXtreeItemId(G2frame,G2frame.Image,'Masks'))
     1687                    G2frame.ImageZ = GetImageZ(G2frame,Controls)
     1688                    wave = Controls['wavelength']
     1689                    LUtth = np.array(Controls['IOtth'])
     1690                    dsp0 = wave/(2.0*sind(LUtth[0]/2.0))
     1691                    dsp1 = wave/(2.0*sind(LUtth[1]/2.0))
     1692                    x0 = G2img.GetDetectorXY(dsp0,0.0,Controls)[0]
     1693                    x1 = G2img.GetDetectorXY(dsp1,0.0,Controls)[0]   
     1694                    nChans = int(1000*(x1-x0)/Controls['pixelSize'][0])//2
     1695                    dlg = wx.ProgressDialog("Spot mask search for %d bins"%nChans,"Processed 2-theta rings = ",nChans+3,
     1696                        style = wx.PD_ELAPSED_TIME|wx.PD_CAN_ABORT)
     1697                    time0 = time.time()
     1698                    Mask['SpotMask']['spotMask'] = G2img.AutoSpotMask(G2frame.ImageZ,Mask,Controls,nChans,dlg)
     1699                    print(' Spot mask search time: %.2f m'%((time.time()-time0)/60.))
     1700        finally:
     1701            dlg.Destroy()
     1702        G2plt.PlotExposedImage(G2frame,event=None)
     1703       
    16711704
    16721705    def OnDeleteSpotMask(event):
     
    18791912    G2frame.Bind(wx.EVT_MENU, OnLoadMask, id=G2G.wxID_MASKLOADNOT)
    18801913    G2frame.Bind(wx.EVT_MENU, OnSaveMask, id=G2G.wxID_MASKSAVE)
    1881     G2frame.Bind(wx.EVT_MENU, OnAutoSpotMask, id=G2G.wxID_FINDSPOTS)
     1914    G2frame.Bind(wx.EVT_MENU, OnFindSpotMask, id=G2G.wxID_FINDSPOTS)
     1915    G2frame.Bind(wx.EVT_MENU, OnAutoFindSpotMask, id=G2G.wxID_AUTOFINDSPOTS)
    18821916    G2frame.Bind(wx.EVT_MENU, OnDeleteSpotMask, id=G2G.wxID_DELETESPOTS)
    18831917    G2frame.Bind(wx.EVT_MENU, ToggleSpotMaskMode, id=G2G.wxID_NEWMASKSPOT)
  • trunk/GSASIIpwd.py

    r4328 r4333  
    388388    if 'XC' in inst['Type'][0]:
    389389        ruland = Ruland(data['Ruland'],wave,Q,CF)
    390 #    auxPlot.append([Q,ruland,'Ruland'])     
     390#        auxPlot.append([Q,ruland,'Ruland'])     
    391391        CF *= ruland
    392392#    auxPlot.append([Q,CF,'CF-Corr'])
     
    407407    mul = int(round(2.*np.pi*nR/(Rmax*qLimits[1])))
    408408#    mul = int(round(2.*np.pi*nR/(data.get('Rmax',100.)*qLimits[1])))
    409     xydata['GofR'][1][0] = 2.*np.pi*np.linspace(0,nR,nR,endpoint=True)/(mul*qLimits[1])
    410     xydata['GofR'][1][1] = -dq*np.imag(fft.fft(xydata['FofQ'][1][1],mul*nR)[:nR])
     409    R = 2.*np.pi*np.linspace(0,nR,nR,endpoint=True)/(mul*qLimits[1])
     410    xydata['GofR'][1][0] = R
     411    GR = -dq*np.imag(fft.fft(xydata['FofQ'][1][1],mul*nR)[:nR])
     412    xydata['GofR'][1][1] = GR
     413#    gr = GR/(4.*np.pi*R)
     414#    auxPlot.append([R,gr,'g(r)'])
    411415    if data.get('noRing',True):
    412416        xydata['GofR'][1][1] = np.where(xydata['GofR'][1][0]<0.5,0.,xydata['GofR'][1][1])
Note: See TracChangeset for help on using the changeset viewer.