Changeset 4299
- Timestamp:
- Feb 13, 2020 9:56:45 AM (3 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIimage.py
r4181 r4299 1188 1188 1189 1189 t0 = time.time() 1190 Block = image[iBeg:iFin,jBeg:jFin] 1190 Block = image[iBeg:iFin,jBeg:jFin] #apply image spotmask here 1191 1191 tax,tay,taz,tad,tabs = Fill2ThetaAzimuthMap(Masks,TA,tam,Block) #and apply masks 1192 1192 tax = np.where(tax > LRazm[1],tax-360.,tax) #put azm inside limits if possible … … 1518 1518 Masks['Points'] = Peaks 1519 1519 return None 1520 1521 def AutoSpotMasks2(Image,Masks,Controls,dlg=None): 1522 1523 LUtth = np.array(Controls['IOtth']) 1524 numChans = Controls['outChannels'] 1525 dtth = (LUtth[1]-LUtth[0])/numChans 1526 esdMul = Masks['SpotMask']['esdMul'] 1527 mask = ma.make_mask_none(Image.shape) 1528 TA = Make2ThetaAzimuthMap(Controls,(0,Image.shape[0]),(0,Image.shape[1]))[0] #2-theta array 1529 TThs = np.linspace(LUtth[0],LUtth[1],numChans,False) 1530 for it,TTh in enumerate(TThs): 1531 band = ma.array(Image,mask=ma.getmask(ma.masked_outside(TA,TTh,TTh+dtth))) 1532 std = ma.std(band) 1533 anom = band.anom()/std 1534 anom = ma.masked_greater(anom,esdMul,copy=False) 1535 mask ^= (ma.getmask(anom)^ma.getmask(band)) 1536 if not dlg is None: 1537 GoOn = dlg.Update(it,newmsg='Processed 2-theta rings = %d'%(it)) 1538 if not GoOn[0]: 1539 break 1540 Masks['SpotMask']['spotMask'] = mask 1541 return None -
trunk/GSASIIimgGUI.py
r4286 r4299 28 28 import matplotlib as mpl 29 29 import numpy as np 30 import numpy.ma as ma 30 31 import GSASIIpath 31 32 GSASIIpath.SetVersionNumber("$Revision$") … … 1644 1645 Controls = copy.deepcopy(G2frame.GPXtree.GetItemPyData( 1645 1646 G2gd.GetGPXtreeItemId(G2frame,G2frame.Image,'Image Controls'))) 1646 Error = G2img.AutoSpotMasks(G2frame.ImageZ,data,Controls) 1647 nChans = Controls['outChannels'] 1648 dlg = wx.ProgressDialog("Auto spot masking","Processed 2-theta rings = ",nChans+1, 1649 style = wx.PD_ELAPSED_TIME|wx.PD_CAN_ABORT) 1650 Error = G2img.AutoSpotMasks2(G2frame.ImageZ,data,Controls,dlg) 1647 1651 if not Error is None: 1648 1652 G2frame.ErrorDialog('Auto spot search error',Error) … … 1842 1846 maxSizer.Add(autoSizer) 1843 1847 return maxSizer 1844 1848 1849 def OnDelBtn(event): 1850 data['SpotMask'] = {'esdMul':2,'spotMask':None} 1851 wx.CallAfter(UpdateMasks,G2frame,data) 1852 1853 1845 1854 G2frame.dataWindow.ClearData() 1846 1855 startScroll = None … … 1891 1900 if 'Frames' not in data: 1892 1901 data['Frames'] = [] 1902 if 'SpotMask' not in data: 1903 data['SpotMask'] = {'esdMul':2,'spotMask':None} 1893 1904 frame = data['Frames'] #3+ x,y pairs 1894 1905 Arcs = data['Arcs'] #radius, start/end azimuth, thickness … … 1917 1928 littleSizer.Add(upperThreshold,0,WACV) 1918 1929 mainSizer.Add(littleSizer,0,) 1930 spotSizer = wx.BoxSizer(wx.HORIZONTAL) 1931 spotSizer.Add(wx.StaticText(G2frame.dataWindow,label=' Select spot range factor (1-10): '),0,WACV) 1932 spotSizer.Add(G2G.ValidatedTxtCtrl(G2frame.dataWindow,loc=data['SpotMask'], 1933 key='esdMul',min=1,max=10,size=(40,25)),0,WACV) 1934 numPix = 0 1935 if data['SpotMask']['spotMask'] is not None: 1936 numPix = np.count_nonzero(data['SpotMask']['spotMask']) 1937 spotSizer.Add(wx.StaticText(G2frame.dataWindow,label=' Number of pixels in spot mask: %d '%numPix),0,WACV) 1938 delbtn = wx.Button(G2frame.dataWindow,label='Clear spot mask') 1939 delbtn.Bind(wx.EVT_BUTTON,OnDelBtn) 1940 spotSizer.Add(delbtn,0,WACV) 1941 mainSizer.Add(spotSizer,0,WACV) 1919 1942 if len(Spots): 1920 1943 lbl = wx.StaticText(parent=G2frame.dataWindow,label=' Spot masks(on plot LB drag to move, shift-LB drag to resize, RB to delete)') -
trunk/GSASIIplot.py
r4298 r4299 7674 7674 if newImage: 7675 7675 Imin,Imax = Data['range'][1] 7676 MA = ma.masked_greater(ma.masked_less(G2frame.ImageZ,Zlim[0]),Zlim[1]) 7677 MaskA = ma.getmaskarray(MA) 7676 MA = ma.masked_outside(G2frame.ImageZ,Zlim[0],Zlim[1]) 7677 MaskA = ma.getmaskarray(MA)^Masks['SpotMask']['spotMask'] 7678 MA = ma.array(MA,mask=MaskA) 7678 7679 for xline in Masks.get('Xlines',[]): 7679 7680 MaskA[xline,:] = True
Note: See TracChangeset
for help on using the changeset viewer.