Changeset 2187


Ignore:
Timestamp:
Mar 31, 2016 3:17:43 PM (7 years ago)
Author:
vondreele
Message:

Modify the Cite please banners to add small angle & DIFFaX references
remov
e 'axial' from DIFFaX choices (for now) as it leads to a streak calculation not supported in GSAS-II
replace pylab stuff with use of PlotXYZ which has been improved
fix character Greek 'mu' in Layers GUI
new GSAS-II function for calculating selected area diffraction (still testing)

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIctrls.py

    r2151 r2187  
    30853085
    30863086Please cite as:
    3087 B.H. Toby & R.B. Von Dreele, J. Appl. Cryst. 46, 544-549 (2013) '''
     3087B.H. Toby & R.B. Von Dreele, J. Appl. Cryst. 46, 544-549 (2013)
     3088For small angle use cite:
     3089R.B. Von Dreele, J. Appl. Cryst. 47, 1748-9 (2014)
     3090For DIFFaX use cite:
     3091M.M.J. Treacy, J.M. Newsam & M.W. Deem,
     3092       Proc. Roy. Soc. Lond. A 433, 499-520 (1991)
     3093'''
    30883094
    30893095        info.WebSite = ("https://subversion.xray.aps.anl.gov/trac/pyGSAS","GSAS-II home page")
  • trunk/GSASIIgrid.py

    r2183 r2187  
    621621            return '0\n0\n4\n1\n%d\n%d\n16\n1\n%d\n0\nend\n'%    \
    622622                (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,       \
    624624                self.Parm,self.parmRange,self.parmStep
    625625
  • trunk/GSASIIphsGUI.py

    r2184 r2187  
    24022402       
    24032403        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']
    24052405        colLabels = ['Name','Type','x','y','z','frac','Uiso']
    24062406        transLabels = ['Prob','Dx','Dy','Dz','refine','plot']
     
    24282428        def OnSadpPlot(event):
    24292429            sadpPlot.SetValue(False)
    2430             import pylab as pl
    24312430            labels = Layers['Sadp']['Plane']
    24322431            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'])
    24382435           
    24392436        def CellSizer():
     
    25292526            widthSizer = wx.BoxSizer(wx.HORIZONTAL)
    25302527            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)
    25322529                widthVal = wx.TextCtrl(layerData,value='%.3f'%(widths[i]),style=wx.TE_PROCESS_ENTER)
    25332530                widthVal.Bind(wx.EVT_TEXT_ENTER,OnWidthChange)       
     
    29282925        dlg = G2gd.DIFFaXcontrols(G2frame,ctrls)
    29292926        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()
    29312928            data['Layers']['Sadp'] = {}
    29322929            data['Layers']['Sadp']['Plane'] = plane
    29332930            data['Layers']['Sadp']['Lmax'] = lmax
     2931            data['Layers']['Sadp']['Mult'] = mult
    29342932        else:
    29352933            return
     
    29692967        else:   #selected area
    29702968            G2pwd.StackSim(data['Layers'],ctrls)
    2971 #            if GSASIIpath.GetConfigValue('debug'):
    2972 #                G2pwd.CalcStackingSADP(data['Layers'])
     2969#            G2pwd.CalcStackingSADP(data['Layers'])
    29732970        wx.CallAfter(UpdateLayerData)
    29742971       
     
    29792976        dlg = G2gd.DIFFaXcontrols(G2frame,ctrls,Parms)
    29802977        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()
    29822979            data['Layers']['Sadp'] = {}
    29832980            data['Layers']['Sadp']['Plane'] = plane
    29842981            data['Layers']['Sadp']['Lmax'] = lmax
     2982            data['Layers']['Sadp']['Mult'] = mult
    29852983            data['Layers']['Multi'] = [parm,parmRange,parmStep]
    29862984        else:
  • trunk/GSASIIplot.py

    r2183 r2187  
    23972397    '''simple contour plot of xyz data, used for diagnostic purposes
    23982398    '''
     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   
    23992431    def OnMotion(event):
    24002432        xpos = event.xdata
    2401         if xpos:                                        #avoid out of frame mouse position
     2433        if Xmin<xpos<Xmax:                                        #avoid out of frame mouse position
    24022434            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                   
    24122447    try:
    24132448        plotNum = G2frame.G2plotNB.plotList.index(Title)
     
    24242459        Page = G2frame.G2plotNB.nb.GetPage(plotNum)
    24252460        Page.canvas.mpl_connect('motion_notify_event', OnMotion)
     2461        Page.canvas.mpl_connect('key_press_event', OnKeyPress)
    24262462   
    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')
    24282465    Page.SetFocus()
    24292466    G2frame.G2plotNB.status.DestroyChildren()
    24302467    Nxy = Z.shape
     2468    Zmax = np.max(Z)
    24312469    Xmin = np.min(XY[0])
    24322470    Xmax = np.max(XY[0])
     
    24422480    else:
    24432481        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)
    24462485    Page.figure.colorbar(Img)
    24472486    if not newPlot:
  • trunk/GSASIIpwd.py

    r2184 r2187  
    2222import scipy as sp
    2323import numpy.linalg as nl
     24import random as rand
    2425from numpy.fft import ifft, fft, fftshift
    2526import scipy.interpolate as si
     
    3637import GSASIImath as G2mth
    3738import pypowder as pyd
     39import pydiffax as pyx
    3840
    3941# trig functions in degrees
     
    19121914        bakType,backDict,backVary = SetBackgroundParms(background)
    19131915        backDict['Lam1'] = G2mth.getWave(inst)
    1914     #    GSASIIpath.IPyBreak()
    19151916        profile[4][iBeg:iFin] = getBackground('',backDict,bakType,inst['Type'][0],profile[0][iBeg:iFin])[0]   
    19161917        profile[3][iBeg:iFin] = Xpat[2]*scale+profile[4][iBeg:iFin]
     
    19361937def CalcStackingSADP(Layers):
    19371938   
     1939    rand.seed()
     1940    ranSeed = rand.randint(1,2**16-1)
     1941# Scattering factors
     1942    import atmdata
    19381943    atTypes = Layers['AtInfo'].keys()
    1939     Adat = []
     1944    aTypes = []
     1945    for atype in atTypes:
     1946        aTypes.append('%4s'%(atype.ljust(4)))
     1947    SFdat = []
    19401948    for atType in atTypes:
    19411949        if atType == 'H':
     
    19431951        else:
    19441952            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
    19471991    AtomXOU = []
    19481992    AtomTp = []
    1949     AtomNL = []
    19501993    LayerSymm = []
    19511994    LayerNum = []
    19521995    layerNames = []
    1953     Natm = 1
     1996    Natm = 0
    19541997    Nuniq = 0
    19551998    for layer in Layers['Layers']:
     
    19602003            continue
    19612004        else:
    1962             LayerNum.append(il)
     2005            LayerNum.append(il+1)
    19632006            Nuniq += 1
    19642007        if '-1' in layer['Symm']:
     
    19662009        else:
    19672010            LayerSymm.append(0)
    1968         AtomNL.append(Natm)
    19692011        for ia,atom in enumerate(layer['Atoms']):
    19702012            [name,atype,x,y,z,frac,Uiso] = atom
    19712013            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
    19742021    TransX = []
    19752022    TransP = []
     
    19772024        TransP.append([trans[0] for trans in Ytrans])   #get just the numbers
    19782025        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)
    19932054   
    19942055#testing data
  • trunk/makeBat.py

    r2133 r2187  
    2020@echo                   for small angle use also cite:
    2121@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)
    2225@echo ========================================================================
    2326@
Note: See TracChangeset for help on using the changeset viewer.