Changeset 2187
- Timestamp:
- Mar 31, 2016 3:17:43 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIctrls.py
r2151 r2187 3085 3085 3086 3086 Please cite as: 3087 B.H. Toby & R.B. Von Dreele, J. Appl. Cryst. 46, 544-549 (2013) ''' 3087 B.H. Toby & R.B. Von Dreele, J. Appl. Cryst. 46, 544-549 (2013) 3088 For small angle use cite: 3089 R.B. Von Dreele, J. Appl. Cryst. 47, 1748-9 (2014) 3090 For DIFFaX use cite: 3091 M.M.J. Treacy, J.M. Newsam & M.W. Deem, 3092 Proc. Roy. Soc. Lond. A 433, 499-520 (1991) 3093 ''' 3088 3094 3089 3095 info.WebSite = ("https://subversion.xray.aps.anl.gov/trac/pyGSAS","GSAS-II home page") -
trunk/GSASIIgrid.py
r2183 r2187 621 621 return '0\n0\n4\n1\n%d\n%d\n16\n1\n%d\n0\nend\n'% \ 622 622 (self.planeChoice.index(self.plane)+1,self.lmaxChoice.index(self.lmax)+1, \ 623 self.multChoice.index(self.mult)+1),self.plane,self.lmax, \623 self.multChoice.index(self.mult)+1),self.plane,self.lmax,self.mult, \ 624 624 self.Parm,self.parmRange,self.parmStep 625 625 -
trunk/GSASIIphsGUI.py
r2184 r2187 2402 2402 2403 2403 laueChoice = ['-1','2/m(ab)','2/m(c)','mmm','-3','-3m','4/m','4/mmm', 2404 '6/m','6/mmm',' axial','unknown']2404 '6/m','6/mmm','unknown'] 2405 2405 colLabels = ['Name','Type','x','y','z','frac','Uiso'] 2406 2406 transLabels = ['Prob','Dx','Dy','Dz','refine','plot'] … … 2428 2428 def OnSadpPlot(event): 2429 2429 sadpPlot.SetValue(False) 2430 import pylab as pl2431 2430 labels = Layers['Sadp']['Plane'] 2432 2431 lmax = float(Layers['Sadp']['Lmax']) 2433 pl.imshow(Layers['Sadp']['Img'],aspect='auto',extent=[-lmax,lmax,-lmax,lmax]) 2434 pl.ylabel(labels[-1]) 2435 pl.xlabel(labels[:-1]) 2436 pl.title(Layers['Sadp']['Plane']) 2437 pl.show() 2432 XY = 2*lmax*np.mgrid[0:256:256j,0:256:256j]/256.-lmax 2433 G2plt.PlotXYZ(G2frame,XY,Layers['Sadp']['Img'].T,labelX=labels[:-1], 2434 labelY=labels[-1],newPlot=False,Title=Layers['Sadp']['Plane']) 2438 2435 2439 2436 def CellSizer(): … … 2529 2526 widthSizer = wx.BoxSizer(wx.HORIZONTAL) 2530 2527 for i in range(2): 2531 widthSizer.Add(wx.StaticText(layerData,label= ' layer width(%s) (<= 1\xb5m): '%(Labels[i])),0,WACV)2528 widthSizer.Add(wx.StaticText(layerData,label=u' layer width(%s) (<= 1\xb5m): '%(Labels[i])),0,WACV) 2532 2529 widthVal = wx.TextCtrl(layerData,value='%.3f'%(widths[i]),style=wx.TE_PROCESS_ENTER) 2533 2530 widthVal.Bind(wx.EVT_TEXT_ENTER,OnWidthChange) … … 2928 2925 dlg = G2gd.DIFFaXcontrols(G2frame,ctrls) 2929 2926 if dlg.ShowModal() == wx.ID_OK: 2930 ctrls,plane,lmax, x,x,x = dlg.GetSelection()2927 ctrls,plane,lmax,mult,x,x,x = dlg.GetSelection() 2931 2928 data['Layers']['Sadp'] = {} 2932 2929 data['Layers']['Sadp']['Plane'] = plane 2933 2930 data['Layers']['Sadp']['Lmax'] = lmax 2931 data['Layers']['Sadp']['Mult'] = mult 2934 2932 else: 2935 2933 return … … 2969 2967 else: #selected area 2970 2968 G2pwd.StackSim(data['Layers'],ctrls) 2971 # if GSASIIpath.GetConfigValue('debug'): 2972 # G2pwd.CalcStackingSADP(data['Layers']) 2969 # G2pwd.CalcStackingSADP(data['Layers']) 2973 2970 wx.CallAfter(UpdateLayerData) 2974 2971 … … 2979 2976 dlg = G2gd.DIFFaXcontrols(G2frame,ctrls,Parms) 2980 2977 if dlg.ShowModal() == wx.ID_OK: 2981 ctrls,plane,lmax, parm,parmRange,parmStep = dlg.GetSelection()2978 ctrls,plane,lmax,mult,parm,parmRange,parmStep = dlg.GetSelection() 2982 2979 data['Layers']['Sadp'] = {} 2983 2980 data['Layers']['Sadp']['Plane'] = plane 2984 2981 data['Layers']['Sadp']['Lmax'] = lmax 2982 data['Layers']['Sadp']['Mult'] = mult 2985 2983 data['Layers']['Multi'] = [parm,parmRange,parmStep] 2986 2984 else: -
trunk/GSASIIplot.py
r2183 r2187 2397 2397 '''simple contour plot of xyz data, used for diagnostic purposes 2398 2398 ''' 2399 def OnKeyPress(event): 2400 if event.key == 'u': 2401 G2frame.Cmax = min(1.0,G2frame.Cmax*1.2) 2402 elif event.key == 'd': 2403 G2frame.Cmax = max(0.0,G2frame.Cmax*0.8) 2404 elif event.key == 'o': 2405 G2frame.Cmax = 1.0 2406 2407 elif event.key == 'i': 2408 choice = ['nearest','bilinear','bicubic','spline16','spline36','hanning', 2409 'hamming','hermite','kaiser','quadric','catrom','gaussian','bessel', 2410 'mitchell','sinc','lanczos'] 2411 dlg = wx.SingleChoiceDialog(G2frame,'Select','Interpolation',choice) 2412 if dlg.ShowModal() == wx.ID_OK: 2413 sel = dlg.GetSelection() 2414 G2frame.Interpolate = choice[sel] 2415 else: 2416 G2frame.Interpolate = 'nearest' 2417 dlg.Destroy() 2418 2419 elif event.key == 's': 2420 choice = [m for m in mpl.cm.datad.keys() if not m.endswith("_r")] 2421 choice.sort() 2422 dlg = wx.SingleChoiceDialog(G2frame,'Select','Color scheme',choice) 2423 if dlg.ShowModal() == wx.ID_OK: 2424 sel = dlg.GetSelection() 2425 G2frame.ContourColor = choice[sel] 2426 else: 2427 G2frame.ContourColor = 'Paired' 2428 dlg.Destroy() 2429 wx.CallAfter(PlotXYZ,G2frame,XY,Z,labelX,labelY,False,Title) 2430 2399 2431 def OnMotion(event): 2400 2432 xpos = event.xdata 2401 if xpos: #avoid out of frame mouse position2433 if Xmin<xpos<Xmax: #avoid out of frame mouse position 2402 2434 ypos = event.ydata 2403 Page.canvas.SetCursor(wx.CROSS_CURSOR) 2404 ix = int(Nxy[0]*(xpos-Xmin)+0.5) 2405 iy = int(Nxy[1]*(ypos-Ymin)+0.5) 2406 try: 2407 G2frame.G2plotNB.status.SetStatusText('%s =%9.3f %s =%9.3f val =%9.3f'% \ 2408 (labelX,xpos,labelY,ypos,Z[ix,iy]),1) 2409 except TypeError: 2410 G2frame.G2plotNB.status.SetStatusText('Select '+Title+' pattern first',1) 2411 2435 if Ymin<ypos<Ymax: 2436 Xwd = Xmax-Xmin 2437 Ywd = Ymax-Ymin 2438 Page.canvas.SetCursor(wx.CROSS_CURSOR) 2439 ix = int(Nxy[0]*(xpos-Xmin)/Xwd) 2440 iy = int(Nxy[1]*(ypos-Ymin)/Ywd) 2441 try: 2442 G2frame.G2plotNB.status.SetStatusText('%s =%9.3f %s =%9.3f val =%9.3f'% \ 2443 (labelX,xpos,labelY,ypos,Z[ix,iy]),1) 2444 except TypeError: 2445 G2frame.G2plotNB.status.SetStatusText('Select '+Title+' pattern first',1) 2446 2412 2447 try: 2413 2448 plotNum = G2frame.G2plotNB.plotList.index(Title) … … 2424 2459 Page = G2frame.G2plotNB.nb.GetPage(plotNum) 2425 2460 Page.canvas.mpl_connect('motion_notify_event', OnMotion) 2461 Page.canvas.mpl_connect('key_press_event', OnKeyPress) 2426 2462 2427 Page.Choice = None 2463 Page.Choice = (' key press','d: lower contour max','u: raise contour max','o: reset contour max', 2464 'i: interpolation method','s: color scheme') 2428 2465 Page.SetFocus() 2429 2466 G2frame.G2plotNB.status.DestroyChildren() 2430 2467 Nxy = Z.shape 2468 Zmax = np.max(Z) 2431 2469 Xmin = np.min(XY[0]) 2432 2470 Xmax = np.max(XY[0]) … … 2442 2480 else: 2443 2481 Plot.set_ylabel(r'Y',fontsize=14) 2444 Img = Plot.imshow(Z.T,cmap='Paired',interpolation='nearest',origin='lower', \ 2445 aspect='auto',extent=[Xmin,Xmax,Ymin,Ymax]) 2482 acolor = mpl.cm.get_cmap(G2frame.ContourColor) 2483 Img = Plot.imshow(Z.T,cmap=acolor,interpolation=G2frame.Interpolate,origin='lower', \ 2484 aspect='auto',extent=[Xmin,Xmax,Ymin,Ymax],vmin=0,vmax=Zmax*G2frame.Cmax) 2446 2485 Page.figure.colorbar(Img) 2447 2486 if not newPlot: -
trunk/GSASIIpwd.py
r2184 r2187 22 22 import scipy as sp 23 23 import numpy.linalg as nl 24 import random as rand 24 25 from numpy.fft import ifft, fft, fftshift 25 26 import scipy.interpolate as si … … 36 37 import GSASIImath as G2mth 37 38 import pypowder as pyd 39 import pydiffax as pyx 38 40 39 41 # trig functions in degrees … … 1912 1914 bakType,backDict,backVary = SetBackgroundParms(background) 1913 1915 backDict['Lam1'] = G2mth.getWave(inst) 1914 # GSASIIpath.IPyBreak()1915 1916 profile[4][iBeg:iFin] = getBackground('',backDict,bakType,inst['Type'][0],profile[0][iBeg:iFin])[0] 1916 1917 profile[3][iBeg:iFin] = Xpat[2]*scale+profile[4][iBeg:iFin] … … 1936 1937 def CalcStackingSADP(Layers): 1937 1938 1939 rand.seed() 1940 ranSeed = rand.randint(1,2**16-1) 1941 # Scattering factors 1942 import atmdata 1938 1943 atTypes = Layers['AtInfo'].keys() 1939 Adat = [] 1944 aTypes = [] 1945 for atype in atTypes: 1946 aTypes.append('%4s'%(atype.ljust(4))) 1947 SFdat = [] 1940 1948 for atType in atTypes: 1941 1949 if atType == 'H': … … 1943 1951 else: 1944 1952 blen = Layers['AtInfo'][atType]['Isotopes']['Nat. Abund.']['SL'][0] 1945 Adat.append([[Adat['fa'][i],Adat['fb'][i]] for i in range(4)]+[Adat['fc'],]) 1946 Adat = np.array(Adat).flatten() 1953 Adat = atmdata.XrayFF[atType] 1954 SF = np.zeros(9) 1955 SF[:8:2] = Adat['fa'] 1956 SF[1:8:2] = Adat['fb'] 1957 SF[8] = Adat['fc'] 1958 SFdat.append(SF) 1959 SFdat = np.array(SFdat) 1960 pyx.pyloadscf(len(atTypes),aTypes,SFdat.T) 1961 # Controls 1962 try: 1963 laueId = ['-1','2/m(ab)','2/m(c)','mmm','-3','-3m','4/m','4/mmm', 1964 '6/m','6/mmm'].index(Layers['Laue'])+1 1965 except ValueError: 1966 laueId = -1 1967 planeId = ['h0l','0kl','hhl','h-hl'].index(Layers['Sadp']['Plane'])+1 1968 lmax = int(Layers['Sadp']['Lmax']) 1969 mult = int(Layers['Sadp']['Mult']) 1970 # Sequences 1971 StkType = ['recursive','explicit'].index(Layers['Stacking'][0]) 1972 try: 1973 StkParm = ['infinite','random','list'].index(Layers['Stacking'][1]) 1974 except ValueError: 1975 StkParm = -1 1976 if StkParm == 2: #list 1977 StkSeq = [int(val) for val in Layers['Stacking'][2].split()] 1978 Nstk = len(StkSeq) 1979 else: 1980 Nstk = 1 1981 StkSeq = [0,] 1982 if StkParm == -1: 1983 StkParm = int(Layers['Stacking'][1]) 1984 Wdth = Layers['Width'][0] 1985 controls = [laueId,planeId,lmax,mult,StkType,StkParm,ranSeed] 1986 LaueSym = Layers['Laue'].ljust(12) 1987 pyx.pygetclay(controls,LaueSym,Wdth,Nstk,StkSeq) 1988 1989 Cell = Layers['Cell'][1:4]+Layers['Cell'][6:7] 1990 # atoms in layers 1947 1991 AtomXOU = [] 1948 1992 AtomTp = [] 1949 AtomNL = []1950 1993 LayerSymm = [] 1951 1994 LayerNum = [] 1952 1995 layerNames = [] 1953 Natm = 11996 Natm = 0 1954 1997 Nuniq = 0 1955 1998 for layer in Layers['Layers']: … … 1960 2003 continue 1961 2004 else: 1962 LayerNum.append(il )2005 LayerNum.append(il+1) 1963 2006 Nuniq += 1 1964 2007 if '-1' in layer['Symm']: … … 1966 2009 else: 1967 2010 LayerSymm.append(0) 1968 AtomNL.append(Natm)1969 2011 for ia,atom in enumerate(layer['Atoms']): 1970 2012 [name,atype,x,y,z,frac,Uiso] = atom 1971 2013 Natm += 1 1972 AtomTp.append(atype) 1973 AtomXOU.append([x,y,z,frac,Uiso*78.9568]) 2014 AtomTp.append('%4s'%(atype.ljust(4))) 2015 Ta = atTypes.index(atype)+1 2016 AtomXOU.append([float(Nuniq),float(ia+1),float(Ta),x,y,z,frac,Uiso*78.9568]) 2017 AtomXOU = np.array(AtomXOU) 2018 Nlayers = len(layerNames) 2019 pyx.pycellayer(Cell,Natm,AtomTp,AtomXOU.T,Nuniq,LayerSymm,Nlayers,LayerNum) 2020 # Transitions 1974 2021 TransX = [] 1975 2022 TransP = [] … … 1977 2024 TransP.append([trans[0] for trans in Ytrans]) #get just the numbers 1978 2025 TransX.append([trans[1:4] for trans in Ytrans]) #get just the numbers 1979 TransP = np.array(Trans,dtype='float') 1980 TransX = np.array(Trans,dtype='float') 1981 Nlayers = np.sqrt(TransP.shape[0]) 1982 Cell = Layers['Cell'][1:4]+Layers['Cell'][6:7] 1983 1984 laueId = ['-1','2/m(ab)','2/m(c)','mmm','-3','-3m','4/m','4/mmm', 1985 '6/m','6/mmm','axial','unknown'].index(Layers['Laue']) 1986 planeId = ['h0l','0kl','hhl','h-hl'],index(Layers['Sadp']['Plane'])+1 1987 lmax = float(Layers['Sadp']['Lmax']) 1988 controls = [laueId,planeId,lmax,Nuniq,] 1989 1990 Sadp = np.array(256**2) 1991 Sadp = pygetsadp(controls,len(AtTypes),AtTypes,Adat,Cell,Natm,AtomTp,AtomXOU,Nlayers,TransP,TransX,stackseq,Sadp) 1992 2026 TransP = np.array(TransP,dtype='float') 2027 TransX = np.array(TransX,dtype='float') 2028 pyx.pygettrans(Nlayers,TransP,TransX) 2029 # result as Sadp 2030 mirror = laueId in [2,3,4,7,8,9,10] 2031 Nspec = 20001 2032 spec = np.zeros(Nspec,dtype='double') 2033 time0 = time.time() 2034 hkLim,Incr = pyx.pygetsadp(controls,Nspec,spec) 2035 # GSASIIpath.IPyBreak() 2036 Sapd = np.zeros((256,256)) 2037 maxInt = np.max(spec[1:]) 2038 Scale = mult*32767./maxInt 2039 iB = 0 2040 for i in range(hkLim): 2041 iF = iB+128 2042 p1 = 128+int(i*Incr) 2043 Sapd[:128,p1] = spec[iB:iF] 2044 Sapd[128:,p1] = spec[iF:iB:-1] 2045 if mirror: 2046 p2 = 128-int(i*Incr) 2047 Sapd[:128,p2] = spec[iB:iF] 2048 Sapd[128:,p2] = spec[iF:iB:-1] 2049 iB += 128 2050 Sapd *= Scale 2051 Sapd = np.where(Sapd<32767.,Sapd,32767.) 2052 Layers['Sadp']['Img'] = Sapd 2053 print 'GETSAD time = %.2fs'%(time.time()-time0) 1993 2054 1994 2055 #testing data -
trunk/makeBat.py
r2133 r2187 20 20 @echo for small angle use also cite: 21 21 @echo R.B. Von Dreele, J. Appl. Cryst. 47, 1784-9 (2014) 22 @echo for DIFFaX use also cite: 23 @echo M.M.J. Treacy, J.M. Newsam and M.W. Deem, 24 @echo Proc. Roy. Soc. Lond. 433A, 499-520 (1991) 22 25 @echo ======================================================================== 23 26 @
Note: See TracChangeset
for help on using the changeset viewer.