Changeset 2604


Ignore:
Timestamp:
Dec 27, 2016 3:00:54 PM (5 years ago)
Author:
vondreele
Message:

a working auto spot mask finder - works if diffraction rings are smooth

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIimage.py

    r2563 r2604  
    11261126    print 'auto spot search'
    11271127    pixelSize = Controls['pixelSize']
    1128     spotMask = ma.array(Image,mask=(Image<3.*np.mean(Image)))
     1128    spotMask = ma.array(Image,mask=(Image<np.mean(Image)))
    11291129    indices = (-1,0,1)
    11301130    rolls = np.array([[ix,iy] for ix in indices for iy in indices])
     
    11321132        if np.any(roll):        #avoid [0,0]
    11331133            spotMask = ma.array(spotMask,mask=(spotMask-rollImage(Image,roll)<=0.))
     1134    mags = spotMask[spotMask.nonzero()]
    11341135    indx = np.transpose(spotMask.nonzero())
    1135     peaks = indx*pixelSize/1000.
    1136     mags = spotMask[spotMask.nonzero()]
     1136    nx,ny = Image.shape
     1137    jndx = []
     1138    for [ind,mag] in zip(indx,mags):
     1139        if (0 < ind[0] < nx-1) and (0 < ind[1] < ny-1):
     1140            cent = np.zeros((3,3))
     1141            cent[1,1] = mag
     1142            msk = np.array(Image[ind[0]-1:ind[0]+2,ind[1]-1:ind[1]+2])
     1143            msk = msk-cent
     1144            if mag > 1.5*np.mean(msk):
     1145                jndx.append([ind[1]+.5,ind[0]+.5])
     1146    if len(jndx) > 100:
     1147        txt = 'Found: %d. Too many spots found; are rings spotty?'%(len(jndx))
     1148        return txt
     1149    jndx = np.array(jndx)
     1150    peaks = jndx*pixelSize/1000.
     1151    tth = GetTth(peaks.T[0],peaks.T[1],Controls)
     1152    histo = np.histogram(tth,2500)
     1153    Points = np.ones((peaks.shape[0],3))
     1154    Points[:,:2] = peaks
     1155    Masks['Points'] = Points
     1156    return None
    11371157                   
    11381158   
  • trunk/GSASIIimgGUI.py

    r2602 r2604  
    11961196        data[key] = data.get(key,[])
    11971197        l1 = len(data[key])
    1198         data[key] = [i for i in data[key] if i]
     1198        data[key] = [i for i in data[key] if len(i)]
    11991199        l2 = len(data[key])
    12001200        if GSASIIpath.GetConfigValue('debug') and l1 != l2:
     
    13081308        Controls = copy.deepcopy(G2frame.PatternTree.GetItemPyData(
    13091309            G2gd.GetPatternTreeItemId(G2frame,G2frame.PatternId,'Image Controls')))
    1310         G2img.AutoSpotMasks(G2frame.ImageZ,data,Controls)
    1311         event.Skip()
     1310        Error = G2img.AutoSpotMasks(G2frame.ImageZ,data,Controls)
     1311        if not Error is None:
     1312            G2frame.ErrorDialog('Auto spot search error',Error)
     1313        wx.CallAfter(UpdateMasks,G2frame,data)
     1314        G2plt.PlotExposedImage(G2frame,event=event)               
    13121315           
    13131316    def ToggleSpotMaskMode(event):
     
    15631566    littleSizer.Add(upperThreshold,0,WACV)
    15641567    mainSizer.Add(littleSizer,0,)
    1565     if Spots:
     1568    if len(Spots):
    15661569        lbl = wx.StaticText(parent=G2frame.dataDisplay,label=' Spot masks')
    15671570        lbl.SetBackgroundColour(wx.Colour(200,200,210))
     
    15721575        littleSizer.Add((5,0),0)
    15731576        for i in range(len(Spots)):
    1574             if Spots[i]:
     1577            if len(Spots[i]):
    15751578                x,y,d = Spots[i]
    15761579                spotText = wx.TextCtrl(parent=G2frame.dataDisplay,value=("%.2f,%.2f" % (x,y)),
  • trunk/GSASIIplot.py

    r2603 r2604  
    49384938        if 'Frames' not in Masks: Masks['Frames'] = []  # patch
    49394939        for i,spot in enumerate(Masks['Points']):   # drawing spot masks
    4940             if spot:
     4940            if len(spot):
    49414941                x,y,d = spot
    49424942                artist = Circle((x,y),radius=d/2,fc='none',ec='r',picker=3)
Note: See TracChangeset for help on using the changeset viewer.