Changeset 2127
- Timestamp:
- Jan 20, 2016 9:21:45 AM (7 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASII.py
r2113 r2127 2223 2223 self.Projection = 'equal area' 2224 2224 self.logPlot = False 2225 self.plusPlot = True 2225 2226 self.sqPlot = False 2226 2227 self.ErrorBars = False -
trunk/GSASIIgrid.py
r2118 r2127 140 140 ] = [wx.NewId() for item in range(12)] 141 141 142 [ wxID_SELECTPHASE,wxID_PWDHKLPLOT,wxID_PWD3DHKLPLOT,wxID_3DALLHKLPLOT, 143 ] = [wx.NewId() for item in range( 4)]142 [ wxID_SELECTPHASE,wxID_PWDHKLPLOT,wxID_PWD3DHKLPLOT,wxID_3DALLHKLPLOT,wxID_MERGEHKL, 143 ] = [wx.NewId() for item in range(5)] 144 144 145 145 [ wxID_PDFCOPYCONTROLS, wxID_PDFSAVECONTROLS, wxID_PDFLOADCONTROLS, … … 317 317 parent.Raise() 318 318 self.EndModal(wx.ID_CANCEL) 319 320 ################################################################################ 321 class MergeDialog(wx.Dialog): 322 ''' HKL transformation & merge dialog 323 324 :param wx.Frame parent: reference to parent frame (or None) 325 :param data: HKLF data 326 327 ''' 328 def __init__(self,parent,data): 329 wx.Dialog.__init__(self,parent,wx.ID_ANY,'Setup HKLF merge', 330 pos=wx.DefaultPosition,style=wx.DEFAULT_DIALOG_STYLE) 331 self.panel = wx.Panel(self) #just a dummy - gets destroyed in Draw! 332 self.data = data 333 self.Super = data[1]['Super'] 334 if self.Super: 335 self.Trans = np.eye(4) 336 else: 337 self.Trans = np.eye(3) 338 self.Cent = 'noncentrosymmetric' 339 self.Laue = '1' 340 self.Draw() 341 342 def Draw(self): 343 344 def OnMatValue(event): 345 Obj = event.GetEventObject() 346 ix,iy = Ind[Obj.GetId()] 347 self.Trans[ix,iy] = float(Obj.GetValue()) 348 349 def OnCent(event): 350 Obj = event.GetEventObject() 351 self.Cent = Obj.GetValue() 352 self.Laue = '-1' 353 if 'non' in self.Cent: 354 self.Laue = '1' 355 self.Draw() 356 357 def OnLaue(event): 358 Obj = event.GetEventObject() 359 self.Laue = Obj.GetValue() 360 self.Draw() 361 362 self.panel.Destroy() 363 self.panel = wx.Panel(self) 364 Ind = {} 365 mainSizer = wx.BoxSizer(wx.VERTICAL) 366 MatSizer = wx.BoxSizer(wx.HORIZONTAL) 367 transSizer = wx.BoxSizer(wx.VERTICAL) 368 transSizer.Add(wx.StaticText(self.panel,label=' HKL Transformation matrix:')) 369 if self.Super: 370 Trmat = wx.FlexGridSizer(4,4,5,5) 371 else: 372 Trmat = wx.FlexGridSizer(3,3,5,5) 373 for iy,line in enumerate(self.Trans): 374 for ix,val in enumerate(line): 375 item = wx.TextCtrl(self.panel,value='%d'%(val), 376 size=(50,25),style=wx.TE_PROCESS_ENTER) 377 Ind[item.GetId()] = [ix,iy] 378 item.Bind(wx.EVT_TEXT_ENTER,OnMatValue) 379 item.Bind(wx.EVT_KILL_FOCUS,OnMatValue) 380 Trmat.Add(item) 381 transSizer.Add(Trmat) 382 MatSizer.Add((10,0),0) 383 MatSizer.Add(transSizer) 384 mainSizer.Add(MatSizer) 385 centroLaue = ['-1','2/m','2/m(c)','2/m(a)','mmm','-3','3/m', \ 386 '4/m','4/mmm','6/m','6/mmm','m3','m3m'] 387 noncentroLaue = ['1','2','2(a)','2(c)','m','m(a)','m(c)','222','mm2','m2m','2mm', \ 388 '3','32','3m','4','-4','422','-42m','42m','6','-6','622','-62m','62m','23','432','-432'] 389 centChoice = ['noncentrosymmetric','centrosymmetric'] 390 mainSizer.Add(wx.StaticText(self.panel,label=' Target Laue symmetry:'),0,WACV) 391 Cent = wx.ComboBox(self.panel,value=self.Cent,choices=centChoice, 392 style=wx.CB_READONLY|wx.CB_DROPDOWN) 393 Cent.Bind(wx.EVT_COMBOBOX,OnCent) 394 mergeSizer = wx.BoxSizer(wx.HORIZONTAL) 395 mergeSizer.Add(Cent,0,WACV) 396 mergeSizer.Add((10,0),0) 397 Choice = centroLaue 398 if 'non' in self.Cent: 399 Choice = noncentroLaue 400 Laue = wx.ComboBox(self.panel,value=self.Laue,choices=Choice, 401 style=wx.CB_READONLY|wx.CB_DROPDOWN) 402 Laue.Bind(wx.EVT_COMBOBOX,OnLaue) 403 mergeSizer.Add(Laue,0,WACV) 404 mainSizer.Add(mergeSizer) 405 406 OkBtn = wx.Button(self.panel,-1,"Ok") 407 OkBtn.Bind(wx.EVT_BUTTON, self.OnOk) 408 cancelBtn = wx.Button(self.panel,-1,"Cancel") 409 cancelBtn.Bind(wx.EVT_BUTTON, self.OnCancel) 410 btnSizer = wx.BoxSizer(wx.HORIZONTAL) 411 btnSizer.Add((20,20),1) 412 btnSizer.Add(OkBtn) 413 btnSizer.Add((20,20),1) 414 btnSizer.Add(cancelBtn) 415 btnSizer.Add((20,20),1) 416 417 mainSizer.Add(btnSizer,0,wx.EXPAND|wx.BOTTOM|wx.TOP, 10) 418 self.panel.SetSizer(mainSizer) 419 self.panel.Fit() 420 self.Fit() 421 422 def GetSelection(self): 423 return self.Trans,self.Cent,self.Laue 424 425 def OnOk(self,event): 426 parent = self.GetParent() 427 parent.Raise() 428 self.EndModal(wx.ID_OK) 429 430 def OnCancel(self,event): 431 parent = self.GetParent() 432 parent.Raise() 433 self.EndModal(wx.ID_CANCEL) 434 319 435 320 436 ################################################################################ … … 870 986 self.ErrorAnal.Append(id=wxID_PWDANALYSIS,kind=wx.ITEM_NORMAL,text='Error Analysis', 871 987 help='Error analysis on single crystal data') 988 self.ErrorAnal.Append(id=wxID_MERGEHKL,kind=wx.ITEM_NORMAL,text='Merge HKLs', 989 help='Transform & merge HKLF data to new histogram') 872 990 self.ErrorAnal.Append(id=wxID_PWD3DHKLPLOT,kind=wx.ITEM_NORMAL,text='Plot 3D HKLs', 873 991 help='Plot HKLs from single crystal data in 3D') … … 2874 2992 G2plt.Plot3DSngl(G2frame,newPlot=True,Data=controls,hklRef=refList,Title=phaseName) 2875 2993 2876 2994 # def OnMerge(self,event): 2995 # if not len(self.HKL): 2996 # print 'No data' 2997 # return 2998 # self.newHKL = np.copy(self.HKL) 2999 # for H in self.newHKL: 3000 # H[:4] = np.rint(np.inner(self.Trans,H[:4])) 3001 # self.newHKL = np.asarray(self.newHKL) 3002 # self.newHKL = G2lat.LaueUnique(self.Laue,self.newHKL) 3003 # dlg = wx.ProgressDialog('Build HKL dictonary','',len(self.newHKL)+1, 3004 # style = wx.PD_ELAPSED_TIME|wx.PD_AUTO_HIDE) 3005 # HKLdict = {} 3006 # for ih,hkl in enumerate(self.newHKL): 3007 # if str(hkl[:4]) not in HKLdict: 3008 # HKLdict[str(hkl[:4])] = [hkl[:4],[hkl[4:],]] 3009 # else: 3010 # HKLdict[str(hkl[:4])][1].append(hkl[4:]) 3011 # dlg.Update(ih) 3012 # dlg.Destroy() 3013 # self.newHKL = [] 3014 # dlg = wx.ProgressDialog('Processing merge','',len(HKLdict)+1, 3015 # style = wx.PD_ELAPSED_TIME|wx.PD_AUTO_HIDE) 3016 # sumDf = 0. 3017 # sumFo = 0. 3018 # for ih,hkl in enumerate(HKLdict): 3019 # HKL = HKLdict[hkl] 3020 # newHKL = list(HKL[0]) 3021 # if len(HKL[1]) > 1: 3022 # fos = np.array(HKL[1]) 3023 # wFo = 1/fos[:,1]**2 3024 # Fo = np.average(fos[:,0],weights=wFo) 3025 # std = np.std(fos[:,0]) 3026 # sig = np.sqrt(np.mean(fos[:,1])**2+std**2) 3027 # sumFo += np.sum(fos[:,0]) 3028 # sumDf += np.sum(np.abs(fos[:,0]-Fo)) 3029 # dlg.Update(ih) 3030 # else: 3031 # Fo = HKL[1][0][0] 3032 # sig = HKL[1][0][1] 3033 # newHKL += [Fo,sig] 3034 # if Fo > 0.: 3035 # self.newHKL.append(list(newHKL)) 3036 # dlg.Destroy() 3037 # self.newHKL = np.array(self.newHKL) 3038 # print 'merge R = %6.2f%s for %d reflections'%(100.*sumDf/sumFo,'%',self.newHKL.shape[0]) 3039 # self.newHKL = G2mth.sortArray(G2mth.sortArray(G2mth.sortArray(G2mth.sortArray(self.newHKL,3),2),1),0) 3040 3041 def OnMergeHKL(event): 3042 dlg = MergeDialog(G2frame,data) 3043 try: 3044 if dlg.ShowModal() == wx.ID_OK: 3045 Trans,Cent,Laue = dlg.GetSelection() 3046 print "do merge here: ",Cent,Laue 3047 else: 3048 return 3049 finally: 3050 dlg.Destroy() 3051 3052 print 'merge HKLF' 3053 2877 3054 def OnErrorAnalysis(event): 2878 3055 G2plt.PlotDeltSig(G2frame,kind) … … 2926 3103 SetDataMenuBar(G2frame,G2frame.dataFrame.HKLFMenu) 2927 3104 G2frame.dataFrame.Bind(wx.EVT_MENU, OnErrorAnalysis, id=wxID_PWDANALYSIS) 3105 G2frame.dataFrame.Bind(wx.EVT_MENU, OnMergeHKL, id=wxID_MERGEHKL) 2928 3106 G2frame.dataFrame.Bind(wx.EVT_MENU, OnPlot3DHKL, id=wxID_PWD3DHKLPLOT) 2929 3107 G2frame.dataFrame.Bind(wx.EVT_MENU, OnPlotAll3DHKL, id=wxID_3DALLHKLPLOT) -
trunk/GSASIIplot.py
r2120 r2127 1145 1145 newPlot = True 1146 1146 elif event.key in ['+','=']: 1147 if G2frame.PickId: 1148 G2frame.PickId = False 1147 G2frame.plusPlot = not G2frame.plusPlot 1149 1148 elif event.key == 'i' and G2frame.Contour: #for smoothing contour plot 1150 1149 choice = ['nearest','bilinear','bicubic','spline16','spline36','hanning', … … 1527 1526 Page.Choice = (' key press','n: log(I) off', 1528 1527 'c: contour on','q: toggle q plot','t: toggle d-spacing plot', 1529 'm: toggle multidata plot','w: toggle divide by sig','+: noselection')1528 'm: toggle multidata plot','w: toggle divide by sig','+: toggle selection') 1530 1529 else: 1531 1530 Page.Choice = (' key press','n: log(I) off', 1532 1531 'd: offset down','l: offset left','r: offset right','u: offset up','o: reset offset', 1533 1532 'c: contour on','q: toggle q plot','t: toggle d-spacing plot', 1534 'm: toggle multidata plot','w: toggle divide by sig','+: noselection')1533 'm: toggle multidata plot','w: toggle divide by sig','+: toggle selection') 1535 1534 elif 'SASD' in plottype: 1536 1535 if G2frame.SinglePlot: 1537 1536 Page.Choice = (' key press','b: toggle subtract background file','n: semilog on', 1538 'q: toggle S(q) plot','m: toggle multidata plot','w: toggle (Io-Ic)/sig plot','+: noselection')1537 'q: toggle S(q) plot','m: toggle multidata plot','w: toggle (Io-Ic)/sig plot','+: toggle selection') 1539 1538 else: 1540 1539 Page.Choice = (' key press','b: toggle subtract background file','n: semilog on', 1541 1540 'd: offset down','l: offset left','r: offset right','u: offset up','o: reset offset', 1542 'q: toggle S(q) plot','m: toggle multidata plot','w: toggle (Io-Ic)/sig plot','+: noselection')1541 'q: toggle S(q) plot','m: toggle multidata plot','w: toggle (Io-Ic)/sig plot','+: toggle selection') 1543 1542 else: 1544 1543 if 'PWDR' in plottype: … … 1714 1713 Plot.set_ylabel('Data sequence',fontsize=12) 1715 1714 else: 1715 if G2frame.plusPlot: 1716 pP = '+' 1717 else: 1718 pP = '' 1716 1719 if 'SASD' in plottype and G2frame.logPlot: 1717 1720 X *= (1.01)**(offsetX*N) … … 1757 1760 if 'PWDR' in plottype: 1758 1761 Plot.set_yscale("log",nonposy='mask') 1759 Plot.plot(X,Y,colors[N%6]+ '+',picker=3.,clip_on=False)1762 Plot.plot(X,Y,colors[N%6]+pP,picker=3.,clip_on=False) 1760 1763 Plot.plot(X,Z,colors[(N+1)%6],picker=False) 1761 1764 Plot.plot(X,W,colors[(N+2)%6],picker=False) #background … … 1780 1783 ecolor=colors[N%6],picker=3.,clip_on=False) 1781 1784 else: 1782 Plot.plot(X,YB,colors[N%6]+ '+',picker=3.,clip_on=False)1785 Plot.plot(X,YB,colors[N%6]+pP,picker=3.,clip_on=False) 1783 1786 Plot.plot(X,W,colors[(N+2)%6],picker=False) #const. background 1784 1787 Plot.plot(X,ZB,colors[(N+1)%6],picker=False) … … 1788 1791 DZ = xye[3]*np.sqrt(xye[2]) 1789 1792 DS = xye[5]*np.sqrt(xye[2])-Ymax*Pattern[0]['delOffset'] 1790 ObsLine = Plot.plot(X,DY,colors[N%6]+ '+',picker=3.,clip_on=False) #Io/sig(Io)1793 ObsLine = Plot.plot(X,DY,colors[N%6]+pP,picker=3.,clip_on=False) #Io/sig(Io) 1791 1794 Plot.plot(X,DZ,colors[(N+1)%6],picker=False) #Ic/sig(Io) 1792 1795 DifLine = Plot.plot(X,DS,colors[(N+3)%6],picker=1.) #(Io-Ic)/sig(Io) … … 1795 1798 if G2frame.SubBack: 1796 1799 if 'PWDR' in plottype: 1797 Plot.plot(Xum,Y-W,colors[N%6]+ '+',picker=False,clip_on=False) #Io-Ib1800 Plot.plot(Xum,Y-W,colors[N%6]+pP,picker=False,clip_on=False) #Io-Ib 1798 1801 Plot.plot(X,Z-W,colors[(N+1)%6],picker=False) #Ic-Ib 1799 1802 else: 1800 Plot.plot(X,YB,colors[N%6]+ '+',picker=3.,clip_on=False)1803 Plot.plot(X,YB,colors[N%6]+pP,picker=3.,clip_on=False) 1801 1804 Plot.plot(X,ZB,colors[(N+1)%6],picker=False) 1802 1805 else: 1803 1806 if 'PWDR' in plottype: 1804 ObsLine = Plot.plot(Xum,Y,colors[N%6]+ '+',picker=3.,clip_on=False) #Io1807 ObsLine = Plot.plot(Xum,Y,colors[N%6]+pP,picker=3.,clip_on=False) #Io 1805 1808 Plot.plot(X,Z,colors[(N+1)%6],picker=False) #Ic 1806 1809 else: 1807 Plot.plot(X,YB,colors[N%6]+ '+',picker=3.,clip_on=False)1810 Plot.plot(X,YB,colors[N%6]+pP,picker=3.,clip_on=False) 1808 1811 Plot.plot(X,ZB,colors[(N+1)%6],picker=False) 1809 1812 if 'PWDR' in plottype: … … 2661 2664 data = G2mth.setPeakparms(Parms,Parms2,X,Z) 2662 2665 s = 1.17741*np.sqrt(data[4])*np.pi/18000. 2663 g = data[6]*np.pi/ 18000.2666 g = data[6]*np.pi/36000. 2664 2667 G = G2pwd.getgamFW(g,s) 2665 2668 Y = s/nptand(X/2.) … … 2672 2675 fit = G2mth.setPeakparms(Parms,Parms2,X,Z,useFit=True) 2673 2676 sf = 1.17741*np.sqrt(fit[4])*np.pi/18000. 2674 gf = fit[6]*np.pi/ 18000.2677 gf = fit[6]*np.pi/36000. 2675 2678 Gf = G2pwd.getgamFW(gf,sf) 2676 2679 Yf = sf/nptand(X/2.) … … 2692 2695 except ValueError: 2693 2696 s = 0.01 2694 g = peak[6]*math.pi/ 18000.2697 g = peak[6]*math.pi/36000. 2695 2698 G = G2pwd.getgamFW(g,s) 2696 2699 Y.append(s/tand(peak[0]/2.))
Note: See TracChangeset
for help on using the changeset viewer.