Changeset 4032


Ignore:
Timestamp:
Jun 19, 2019 4:13:00 PM (2 years ago)
Author:
vondreele
Message:

fix 'Resolution' in old gpx to 'GridStep?'
fix to bad logical operator in MakeFrameMask?
apply polarization pixel by pixel in integration; then put back on for azm=0 for powder diffraction
remove a wasted busycursor
add Xlines & Ylines to masks to mask whole row/columns of pixels (not quite complete)
make picktype = None for unknown picks ('?' causes crash)

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIIO.py

    r3999 r4032  
    825825        X = 4.*np.pi*npsind(X/2.)/data['wavelength']    #convert to q
    826826    Xminmax = [X[0],X[-1]]
    827     Azms = []
     827    Azms = np.zeros(data['outAzimuths'])
    828828    dazm = 0.
    829     if data['fullIntegrate'] and data['outAzimuths'] == 1:
    830         Azms = [45.0,]                              #a poor man's average?
    831     else:
    832         for i,azm in enumerate(azms[:-1]):
    833             if azm > 360. and azms[i+1] > 360.:
    834                 Azms.append(G2img.meanAzm(azm%360.,azms[i+1]%360.))
    835             else:   
    836                 Azms.append(G2img.meanAzm(azm,azms[i+1]))
     829#    if data['fullIntegrate'] and data['outAzimuths'] == 1:
     830#        Azms = [0.0,]                              #a poor man's average?
     831#    else:
     832##        for i,azm in enumerate(azms[:-1]):
     833##            if azm > 360. and azms[i+1] > 360.:
     834##                Azms.append(G2img.meanAzm(azm%360.,azms[i+1]%360.))
     835##            else:   
     836##                Azms.append(G2img.meanAzm(azm,azms[i+1]))
     837    if data['outAzimuths'] > 1:
    837838        dazm = np.min(np.abs(np.diff(azms)))/2.
    838839    G2frame.IntgOutList = []
  • trunk/GSASIIdataGUI.py

    r4031 r4032  
    54545454        # IMG / Masks
    54555455        G2G.Define_wxId('wxID_MASKCOPY', 'wxID_MASKSAVE', 'wxID_MASKLOAD', 'wxID_NEWMASKSPOT', 'wxID_NEWMASKARC', 'wxID_NEWMASKRING',
    5456             'wxID_NEWMASKFRAME', 'wxID_NEWMASKPOLY', 'wxID_MASKLOADNOT', 'wxID_FINDSPOTS', 'wxID_DELETESPOTS',)
     5456            'wxID_NEWMASKFRAME', 'wxID_NEWMASKPOLY','wxID_NEWMASKXLINE','wxID_NEWMASKYLINE','wxID_MASKLOADNOT', 'wxID_FINDSPOTS', 'wxID_DELETESPOTS',)
    54575457        self.MaskMenu = wx.MenuBar()
    54585458        self.PrefillDataMenu(self.MaskMenu)
     
    54725472        submenu.Append(G2G.wxID_NEWMASKRING,'Ring mask','Create a ring mask with mouse input')
    54735473        submenu.Append(G2G.wxID_NEWMASKSPOT,'Spot mask','Create spot masks with mouse input')
     5474        submenu.Append(G2G.wxID_NEWMASKXLINE,'X line mask','Create line masks with mouse input')
     5475        submenu.Append(G2G.wxID_NEWMASKYLINE,'Y line mask','Create line masks with mouse input')
    54745476        self.PostfillDataMenu()
    54755477           
  • trunk/GSASIIimage.py

    r4026 r4032  
    548548            tamp = ma.make_mask_none((1024*1024))
    549549            tamp = ma.make_mask(pm.polymask(nI*nJ,tax.flatten(),
    550                 tay.flatten(),len(frame),frame,tamp)[:nI*nJ])-True  #switch to exclude around frame
     550                tay.flatten(),len(frame),frame,tamp)[:nI*nJ])^True  #switch to exclude around frame
    551551            if tamp.shape:
    552552                tamp = np.reshape(tamp[:nI*nJ],(nI,nJ))
     
    10241024            Block = image[iBeg:iFin,jBeg:jFin]
    10251025            tax,tay,taz,tad,tabs = Fill2ThetaAzimuthMap(Masks,TA,tam,Block)    #and apply masks
     1026            pol = G2pwd.Polarization(data['PolaVal'][0],tay,tax-90.)[0]         #for pixel pola correction
    10261027            times[0] += time.time()-t0
    10271028            t0 = time.time()
     
    10401041            times[2] += time.time()-t0
    10411042            t0 = time.time()
    1042             taz = np.array((taz*tad/tabs),dtype='float32')
     1043            taz = np.array((taz*tad/tabs),dtype='float32')/pol
    10431044            if any([tax.shape[0],tay.shape[0],taz.shape[0]]):
    10441045                NST,H0 = h2d.histogram2d(len(tax),tax,tay,taz,
    10451046                    numAzms,numChans,LRazm,lutth,Dazm,dtth,NST,H0)
    10461047            times[3] += time.time()-t0
    1047 #            print('done block %d %d %d %d %d %d %d %d'%(iBlk,iBeg,iFin,jBlk,jBeg,jFin,np.min(Block),np.max(Block)))
    10481048    G2fil.G2Print('End integration loops')
    10491049    t0 = time.time()
    1050 #    H2 = np.array([tth for tth in np.linspace(lutth[0],lutth[1],numChans+1)])
    1051 #    NST = np.array(NST,dtype=np.float32)
    10521050    #prepare masked arrays of bins with pixels for interpolation setup
    10531051    H2msk = [ma.array(H2[:-1],mask=np.logical_not(nst)) for nst in NST]
     
    10661064    else:
    10671065        H1 = LRazm
     1066    if 'SASD' not in data['type']:
     1067        H0 *= np.array(G2pwd.Polarization(data['PolaVal'][0],H2[:-1],0.)[0])
    10681068    H0 /= npcosd(H2[:-1])           #**2? I don't think so, **1 is right for powders
    10691069    if 'SASD' in data['type']:
     
    10711071    if data['Oblique'][1]:
    10721072        H0 /= G2pwd.Oblique(data['Oblique'][0],H2[:-1])
    1073     if 'SASD' in data['type'] and data['PolaVal'][1]:
    1074         #NB: in G2pwd.Polarization azm is defined from plane of polarization, not image x axis!
    1075         H0 /= np.array([G2pwd.Polarization(data['PolaVal'][0],H2[:-1],Azm=azm-90.)[0] for azm in (H1[:-1]+np.diff(H1)/2.)])
    10761073    times[4] += time.time()-t0
    10771074    G2fil.G2Print ('Step times: \n apply masks  %8.3fs xy->th,azm   %8.3fs fill map     %8.3fs \
  • trunk/GSASIIimgGUI.py

    r4031 r4032  
    269269        CleanupMasks(masks)
    270270        sumImg = GetImageZ(G2frame,data)
    271         wx.BeginBusyCursor()
    272         try:
    273             G2frame.Integrate = G2img.ImageIntegrate(sumImg,data,masks,blkSize,useTA=useTA,useMask=useMask)           
    274         finally:
    275             wx.EndBusyCursor()   
     271        G2frame.Integrate = G2img.ImageIntegrate(sumImg,data,masks,blkSize,useTA=useTA,useMask=useMask)           
    276272        G2frame.PauseIntegration = G2frame.Integrate[-1]
    277273        del sumImg  #force cleanup
     
    13631359    before they are used for integration.
    13641360    '''
    1365     for key in ['Points','Rings','Arcs','Polygons']:
     1361    for key in ['Points','Rings','Arcs','Polygons','Xlines','Ylines',]:
    13661362        data[key] = data.get(key,[])
    13671363        l1 = len(data[key])
     
    14441440                filename = os.path.splitext(filename)[0]+'.immask'
    14451441                File = open(filename,'w')
    1446                 keys = ['Points','Rings','Arcs','Polygons','Frames','Thresholds']
     1442                keys = ['Points','Rings','Arcs','Polygons','Xlines','Ylines','Frames','Thresholds']
    14471443                for key in keys:
    14481444                    File.write(key+':'+str(data[key])+'\n')
     
    14971493        'Start a new ring mask'
    14981494        G2frame.MaskKey = 'r'
     1495        G2plt.OnStartMask(G2frame)
     1496       
     1497    def OnNewXlineMask(event):
     1498        'Start a new x-line mask'
     1499        print('x')
     1500        G2frame.MaskKey = 'x'
     1501        G2plt.OnStartMask(G2frame)
     1502       
     1503    def OnNewYlineMask(event):
     1504        'Start a new y-line mask'
     1505        G2frame.MaskKey = 'y'
    14991506        G2plt.OnStartMask(G2frame)
    15001507       
     
    16791686    G2frame.Bind(wx.EVT_MENU, OnNewArcMask, id=G2G.wxID_NEWMASKARC)
    16801687    G2frame.Bind(wx.EVT_MENU, OnNewRingMask, id=G2G.wxID_NEWMASKRING)
     1688    G2frame.Bind(wx.EVT_MENU, OnNewXlineMask, id=G2G.wxID_NEWMASKXLINE)
     1689    G2frame.Bind(wx.EVT_MENU, OnNewYlineMask, id=G2G.wxID_NEWMASKYLINE)
    16811690    G2frame.Bind(wx.EVT_MENU, OnNewPolyMask, id=G2G.wxID_NEWMASKPOLY)
    16821691    G2frame.Bind(wx.EVT_MENU, OnNewFrameMask, id=G2G.wxID_NEWMASKFRAME)
     
    16891698    elif G2frame.MaskKey == 'r':
    16901699        G2frame.GetStatusBar().SetStatusText('Ring mask active - LB pick ring location',1)
     1700    elif G2frame.MaskKey == 'x':
     1701        G2frame.GetStatusBar().SetStatusText('X-line mask active - LB pick x line of pixels',1)
     1702    elif G2frame.MaskKey == 'y':
     1703        G2frame.GetStatusBar().SetStatusText('Y-line mask active - LB pick y line of pixels',1)
    16911704    else:
    1692         G2frame.GetStatusBar().SetStatusText("To add mask: press a,r,s,p or f on 2D image for arc/ring/spot/polygon/frame",1)
     1705        G2frame.GetStatusBar().SetStatusText("To add mask: press a,r,s,x,y,p or f on 2D image for arc/ring/spot/xline/yline/polygon/frame",1)
    16931706    mainSizer = G2frame.dataWindow.GetSizer()
    16941707    mainSizer.Add((5,10),0)
     
    16981711    Rings = data['Rings']               #radius, thickness
    16991712    Polygons = data['Polygons']         #3+ x,y pairs
     1713    if 'Xlines' not in data:            #single rows/columns of bad pixels
     1714        data['Xlines'] = []
     1715        data['Ylines'] = []
     1716    Xlines = data['Xlines']
     1717    Ylines = data['Ylines']
    17001718    if 'Frames' not in data:
    17011719        data['Frames'] = []
     
    17971815                littleSizer.Add(arcDelete,0,WACV)
    17981816        mainSizer.Add(littleSizer,0,)
     1817       
     1818    if Xlines:
     1819        lbl = wx.StaticText(parent=G2frame.dataWindow,label=' X line masks')
     1820        lbl.SetBackgroundColour(wx.Colour(200,200,210))
     1821        mainSizer.Add(lbl,0,wx.EXPAND|wx.ALIGN_CENTER,0)
     1822        littleSizer = wx.FlexGridSizer(0,2,0,5)
     1823        for i in range(len(Xlines)):
     1824            if Xlines[i]:
     1825                littleSizer.Add(wx.StaticText(G2frame.dataWindow,label='at Y-pixel: %d'%(Xlines[i])),0,WACV)
     1826                xlineDelete = G2G.G2LoggedButton(G2frame.dataWindow,label='delete?',
     1827                    locationcode='Delete+Xlines+'+str(i),handler=onDeleteMask)
     1828                littleSizer.Add(xlineDelete,0,WACV)
     1829        mainSizer.Add(littleSizer,0,)
     1830       
     1831    if Ylines:
     1832        lbl = wx.StaticText(parent=G2frame.dataWindow,label=' Y line masks')
     1833        lbl.SetBackgroundColour(wx.Colour(200,200,210))
     1834        mainSizer.Add(lbl,0,wx.EXPAND|wx.ALIGN_CENTER,0)
     1835        littleSizer = wx.FlexGridSizer(0,2,0,5)
     1836        for i in range(len(Ylines)):
     1837            if Ylines[i]:
     1838                littleSizer.Add(wx.StaticText(G2frame.dataWindow,label='at X-pixel: %d'%(Ylines[i])),0,WACV)
     1839                ylineDelete = G2G.G2LoggedButton(G2frame.dataWindow,label='delete?',
     1840                    locationcode='Delete+Ylines+'+str(i),handler=onDeleteMask)
     1841                littleSizer.Add(ylineDelete,0,WACV)
     1842        mainSizer.Add(littleSizer,0,)
     1843       
    17991844    if Polygons:
    18001845        lbl = wx.StaticText(parent=G2frame.dataWindow,
  • trunk/GSASIIphsGUI.py

    r4013 r4032  
    22092209            if 'cutOff' not in Map:
    22102210                Map['cutOff'] = 100.0
     2211            if 'Resolution' in Map:
     2212                Map['GridStep'] = Map['Resolution']
    22112213            mapTypes = ['Fobs','Fcalc','delt-F','2*Fo-Fc','Omit','2Fo-Fc Omit','Patterson']
    22122214            refsList = [item for item in G2gd.GetGPXtreeDataNames(G2frame,['HKLF','PWDR']) if item in data['Histograms'].keys()]
     
    22462248               
    22472249        def FlipSizer():
     2250            #patches
    22482251            if 'k-Max' not in Flip: Flip['k-Max'] = 20.
     2252            if 'Resolution' in Flip:
     2253                Flip['GridStep'] = Flip['Resolution']
    22492254           
    22502255            def OnRefList(event):
  • trunk/GSASIIplot.py

    r4021 r4032  
    65316531        Page.figure.suptitle('Left-click to create an arc mask',color='r',fontweight='bold')
    65326532        Page.canvas.draw()
     6533    elif G2frame.MaskKey == 'x':
     6534        new,plotNum,Page,Plot,lim = G2frame.G2plotNB.FindPlotTab('2D Powder Image','mpl',newImage=False)
     6535        Page.figure.suptitle('Left-click to create an x-line mask',color='r',fontweight='bold')
     6536        Page.canvas.draw()
     6537    elif G2frame.MaskKey == 'y':
     6538        new,plotNum,Page,Plot,lim = G2frame.G2plotNB.FindPlotTab('2D Powder Image','mpl',newImage=False)
     6539        Page.figure.suptitle('Left-click to create an y-line mask',color='r',fontweight='bold')
     6540        Page.canvas.draw()
    65336541    elif G2frame.MaskKey == 'r':
    65346542        new,plotNum,Page,Plot,lim = G2frame.G2plotNB.FindPlotTab('2D Powder Image','mpl',newImage=False)
     
    67466754                Page.canvas.draw()
    67476755                return
    6748             elif event.key in ['l','p','f','a','r']:
     6756            elif event.key in ['l','p','f','a','r','x','y']:
    67496757                G2frame.MaskKey = event.key
    67506758                OnStartMask(G2frame)
     
    69226930                pickType = pick.itemType
    69236931            except:
    6924                 pickType = '?'
     6932                pickType = None
    69256933            if pickType == "Spot":
    69266934                itemNum = G2frame.itemPicked.itemNumber
     
    70597067                pickType = pick.itemType
    70607068            except: # should not happen anymore
    7061                 pickType = '?'
     7069                pickType = None
    70627070            if pickType == 'Spot':
    70637071                pl = [pick,]
     
    71987206                wx.CallAfter(PlotImage,G2frame,newImage=True)
    71997207                return
    7200             elif G2frame.MaskKey =='p' or G2frame.MaskKey =='f':
     7208            elif G2frame.MaskKey in ['p','f']:
    72017209                if G2frame.MaskKey =='p':
    72027210                    polygon = Masks['Polygons'][-1]
     
    72327240                    #G2imG.UpdateMasks(G2frame,Masks)
    72337241                    return
     7242            elif G2frame.MaskKey in ['x','y']:
     7243                Xpix,Ypix = int(Xpos*scalex),int(Ypos*scaley)
     7244                if G2frame.MaskKey == 'y':
     7245                    Masks['Ylines'].append(Xpix)
     7246                else:
     7247                    Masks['Xlines'].append(Ypix)
     7248                G2imG.UpdateMasks(G2frame,Masks)
     7249                wx.CallAfter(PlotImage,G2frame,newImage=True)
     7250                return
    72347251            G2imG.UpdateMasks(G2frame,Masks)
    72357252            wx.CallAfter(PlotImage,G2frame,newImage=False)
     
    73787395        elif G2frame.GPXtree.GetItemText(G2frame.PickId) in ['Masks',]:
    73797396            Page.Choice = [' key press','a: arc mask','r: ring mask',
     7397                'x: x line mask','y: y line mask',
    73807398                'p: polygon mask','f: frame mask',
    73817399                't: add spot mask at mouse position',
     
    74147432            Imin,Imax = Data['range'][1]
    74157433            MA = ma.masked_greater(ma.masked_less(G2frame.ImageZ,Zlim[0]),Zlim[1])
     7434           
    74167435            MaskA = ma.getmaskarray(MA)
    74177436            A = G2img.ImageCompress(MA,imScale)
Note: See TracChangeset for help on using the changeset viewer.