Changeset 2604
- Timestamp:
- Dec 27, 2016 3:00:54 PM (6 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIimage.py
r2563 r2604 1126 1126 print 'auto spot search' 1127 1127 pixelSize = Controls['pixelSize'] 1128 spotMask = ma.array(Image,mask=(Image< 3.*np.mean(Image)))1128 spotMask = ma.array(Image,mask=(Image<np.mean(Image))) 1129 1129 indices = (-1,0,1) 1130 1130 rolls = np.array([[ix,iy] for ix in indices for iy in indices]) … … 1132 1132 if np.any(roll): #avoid [0,0] 1133 1133 spotMask = ma.array(spotMask,mask=(spotMask-rollImage(Image,roll)<=0.)) 1134 mags = spotMask[spotMask.nonzero()] 1134 1135 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 1137 1157 1138 1158 -
trunk/GSASIIimgGUI.py
r2602 r2604 1196 1196 data[key] = data.get(key,[]) 1197 1197 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)] 1199 1199 l2 = len(data[key]) 1200 1200 if GSASIIpath.GetConfigValue('debug') and l1 != l2: … … 1308 1308 Controls = copy.deepcopy(G2frame.PatternTree.GetItemPyData( 1309 1309 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) 1312 1315 1313 1316 def ToggleSpotMaskMode(event): … … 1563 1566 littleSizer.Add(upperThreshold,0,WACV) 1564 1567 mainSizer.Add(littleSizer,0,) 1565 if Spots:1568 if len(Spots): 1566 1569 lbl = wx.StaticText(parent=G2frame.dataDisplay,label=' Spot masks') 1567 1570 lbl.SetBackgroundColour(wx.Colour(200,200,210)) … … 1572 1575 littleSizer.Add((5,0),0) 1573 1576 for i in range(len(Spots)): 1574 if Spots[i]:1577 if len(Spots[i]): 1575 1578 x,y,d = Spots[i] 1576 1579 spotText = wx.TextCtrl(parent=G2frame.dataDisplay,value=("%.2f,%.2f" % (x,y)), -
trunk/GSASIIplot.py
r2603 r2604 4938 4938 if 'Frames' not in Masks: Masks['Frames'] = [] # patch 4939 4939 for i,spot in enumerate(Masks['Points']): # drawing spot masks 4940 if spot:4940 if len(spot): 4941 4941 x,y,d = spot 4942 4942 artist = Circle((x,y),radius=d/2,fc='none',ec='r',picker=3)
Note: See TracChangeset
for help on using the changeset viewer.