Changeset 2197


Ignore:
Timestamp:
Apr 6, 2016 4:14:46 PM (7 years ago)
Author:
vondreele
Message:

replace pyd files for binwin2.7 & binwin64-2.7
implement new pyGetSpc routine for PWDR simulations - checked against DIFFaX
Add a transition probability normalizer button
change transition plots from DCLICK to CLICK - much nicer
invoke G2frame.G2plotNB.RaisePageNoRefresh?(Page) in a number of places to get plots to appear on demand
fix layer plotting issues after normal structure plots made

Location:
trunk
Files:
24 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASII.py

    r2196 r2197  
    23252325        self.oldImagefile = '' # the name of the last image file read
    23262326        self.oldImageTag = None # the name of the tag for multi-image files
    2327         self.ImageZ = []  # this contains the image plotted
    2328         # self.ImageZ and self.oldImagefile are set in GSASIIplot.PlotImage
    2329         # and GSASIIIO.GetImageData
    2330         # any changes to self.ImageZ should initialize self.oldImagefile to force a reread
     2327        self.ImageZ = []
    23312328        self.Integrate = 0
    23322329        self.imageDefault = {}
  • trunk/GSASIIgrid.py

    r2195 r2197  
    512512        self.parmRange = [0.,1.]
    513513        self.parmStep = 2
     514        self.Inst = 'None'
    514515        self.Draw()
    515516       
     
    540541            parmrange.SetValue('%.3f %.3f'%(vals[0],vals[1]))
    541542            self.parmRange = vals
     543           
     544        def OnInstSel(event):
     545            self.Inst = instsel.GetValue()
    542546       
    543547        self.panel.Destroy()
     
    545549        mainSizer = wx.BoxSizer(wx.VERTICAL)
    546550        mainSizer.Add(wx.StaticText(self.panel,label=' Controls for DIFFaX'),0,WACV)
    547         calcChoice = ['powder pattern','selected area']
    548         calcSizer = wx.BoxSizer(wx.HORIZONTAL)
    549         calcSizer.Add(wx.StaticText(self.panel,label=' Select calculation type: '),0,WACV)
    550         calcType = wx.ComboBox(self.panel,value=self.calcType,choices=calcChoice,
    551             style=wx.CB_READONLY|wx.CB_DROPDOWN)
    552         calcType.Bind(wx.EVT_COMBOBOX,OnCalcType)
    553         calcSizer.Add(calcType,0,WACV)
    554         mainSizer.Add(calcSizer)
     551        if self.Parms:
     552            mainSizer.Add(wx.StaticText(self.panel,label=' Sequential powder pattern simulation'),0,WACV)
     553        else:
     554            calcChoice = ['powder pattern','selected area']
     555            calcSizer = wx.BoxSizer(wx.HORIZONTAL)
     556            calcSizer.Add(wx.StaticText(self.panel,label=' Select calculation type: '),0,WACV)
     557            calcType = wx.ComboBox(self.panel,value=self.calcType,choices=calcChoice,
     558                style=wx.CB_READONLY|wx.CB_DROPDOWN)
     559            calcType.Bind(wx.EVT_COMBOBOX,OnCalcType)
     560            calcSizer.Add(calcType,0,WACV)
     561            mainSizer.Add(calcSizer)
    555562        if self.Parms:
    556563            parmSel = wx.BoxSizer(wx.HORIZONTAL)
     
    587594            planeSizer.Add(lmax,0,WACV)           
    588595            mainSizer.Add(planeSizer)
     596        else:
     597            instChoice = ['None','Mean Gaussian','Gaussian',]
     598            instSizer = wx.BoxSizer(wx.HORIZONTAL)
     599            instSizer.Add(wx.StaticText(self.panel,label=' Select instrument broadening: '),0,WACV)
     600            instsel = wx.ComboBox(self.panel,value=self.Inst,choices=instChoice,
     601                style=wx.CB_READONLY|wx.CB_DROPDOWN)
     602            instsel.Bind(wx.EVT_COMBOBOX,OnInstSel)
     603            instSizer.Add(instsel,0,WACV)
     604            mainSizer.Add(instSizer)
    589605        OkBtn = wx.Button(self.panel,-1,"Ok")
    590606        OkBtn.Bind(wx.EVT_BUTTON, self.OnOk)
     
    605621    def GetSelection(self):
    606622        if 'powder' in self.calcType:
    607             return '0\n0\n3\n','','',self.Parm,self.parmRange,self.parmStep
     623            return 'PWDR',self.Inst,self.Parm,self.parmRange,self.parmStep
    608624        elif 'selected' in self.calcType:
    609             return '0\n0\n4\n1\n%d\n1\n16\n1\n%d\n0\nend\n'%    \
    610                 (self.planeChoice.index(self.plane)+1,self.lmaxChoice.index(self.lmax)+1),   \
    611                 self.plane,self.lmax,self.Parm,self.parmRange,self.parmStep
     625            return 'SADP',self.plane,self.lmax
    612626
    613627    def OnOk(self,event):
  • trunk/GSASIIphsGUI.py

    r2195 r2197  
    26572657                    Obj.SetCellValue(Xi,5,'')
    26582658                    G2plt.PlotLayers(G2frame,Layers,[Yi,Xi,],plotDefaults)
     2659                else:
     2660                    event.Skip()
     2661                   
     2662            def OnNormProb(event):
     2663                for Yi,Yname in enumerate(Names):
     2664                    Psum = 0.
     2665                    for Xi,Xname in enumerate(Names):
     2666                        Psum += transArray[Yi][Xi][0]
     2667                    if not Psum:
     2668                        transArray[Yi][0][0] = 1.0
     2669                        Psum = 1.0
     2670                    for Xi,Xname in enumerate(Names):
     2671                        transArray[Yi][Xi][0] /= Psum
     2672                wx.CallAfter(UpdateLayerData)
    26592673           
    26602674            transSizer = wx.BoxSizer(wx.VERTICAL)
    2661             transSizer.Add(wx.StaticText(layerData,label=' Layer-Layer transition probabilities:'),0,WACV)
     2675            topSizer = wx.BoxSizer(wx.HORIZONTAL)
     2676            topSizer.Add(wx.StaticText(layerData,label=' Layer-Layer transition probabilities: '),0,WACV)
     2677            normprob = wx.CheckBox(layerData,label=' Normalize probabilities?')
     2678            normprob.Bind(wx.EVT_CHECKBOX,OnNormProb)
     2679            topSizer.Add(normprob,0,WACV)
     2680            transSizer.Add(topSizer,0,WACV)
    26622681            Names = [layer['Name'] for layer in Layers['Layers']]
    26632682            transArray = Layers['Transitions']
     
    26842703                    attr.SetEditor(G2G.GridFractionEditor(transGrid))
    26852704                    transGrid.SetColAttr(c, attr)
    2686                 transGrid.Bind(wg.EVT_GRID_CELL_LEFT_DCLICK, PlotSelect)
     2705                transGrid.Bind(wg.EVT_GRID_CELL_LEFT_CLICK, PlotSelect)
    26872706                transGrid.AutoSizeColumns(True)
    26882707                transSizer.Add(transGrid)
     
    29262945        dlg = G2gd.DIFFaXcontrols(G2frame,ctrls)
    29272946        if dlg.ShowModal() == wx.ID_OK:
    2928             ctrls,plane,lmax,x,x,x = dlg.GetSelection()
    2929             data['Layers']['Sadp'] = {}
    2930             data['Layers']['Sadp']['Plane'] = plane
    2931             data['Layers']['Sadp']['Lmax'] = lmax
     2947            simCodes = dlg.GetSelection()
    29322948        else:
    29332949            return
    2934         if ctrls == '0\n0\n3\n':    #powder pattern
     2950        if 'PWDR' in  simCodes[0]:    #powder pattern
     2951            data['Layers']['selInst'] = simCodes[1]
    29352952            UseList = []
    29362953            for item in data['Histograms']:
     
    29632980            profile = G2frame.PatternTree.GetItemPyData(G2frame.PatternId)[1]
    29642981            dlg.Destroy()       
    2965             G2pwd.StackSim(data['Layers'],ctrls,HistName,scale,background,limits,inst,profile)
    2966             G2pwd.CalcStackingPWDR(data['Layers'],HistName,scale,background,limits,inst,profile)
     2982            ctrls = '0\n0\n3\n'
     2983            G2pwd.StackSim(data['Layers'],ctrls,scale,background,limits,inst,profile)
     2984            test1 = np.copy(profile[3])
     2985            test1 = np.where(test1,test1,1.0)
     2986            G2pwd.CalcStackingPWDR(data['Layers'],scale,background,limits,inst,profile)
     2987            test2 = np.copy(profile[3])
     2988            rat = (test1-test2)/test1
     2989#            GSASIIpath.IPyBreak()
    29672990            G2plt.PlotPatterns(G2frame,plotType='PWDR')
    29682991        else:   #selected area
     2992            data['Layers']['Sadp'] = {}
     2993            data['Layers']['Sadp']['Plane'] = simCodes[1]
     2994            data['Layers']['Sadp']['Lmax'] = simCodes[2]
     2995#            planeChoice = ['h0l','0kl','hhl','h-hl',]
     2996#            lmaxChoice = [str(i+1) for i in range(6)]
     2997#            ctrls = '0\n0\n4\n1\n%d\n1\n16\n1\n%d\n0\nend\n'%    \
     2998#                (planeChoice.index(simCodes[1])+1,lmaxChoice.index(simCodes[2])+1)
    29692999#            G2pwd.StackSim(data['Layers'],ctrls)
    29703000            G2pwd.CalcStackingSADP(data['Layers'])
     
    29773007        dlg = G2gd.DIFFaXcontrols(G2frame,ctrls,Parms)
    29783008        if dlg.ShowModal() == wx.ID_OK:
    2979             ctrls,plane,lmax,mult,parm,parmRange,parmStep = dlg.GetSelection()
    2980             data['Layers']['Sadp'] = {}
    2981             data['Layers']['Sadp']['Plane'] = plane
    2982             data['Layers']['Sadp']['Lmax'] = lmax
    2983             data['Layers']['Multi'] = [parm,parmRange,parmStep]
     3009            simCodes = dlg.GetSelection()
     3010            data['Layers']['Multi'] = [simCodes[2:5]]
    29843011        else:
    29853012            return
  • trunk/GSASIIplot.py

    r2196 r2197  
    313313            return
    314314#        print 'OnPageChanged'
    315         self.status.DestroyChildren()                           #get rid of special stuff on status bar
     315        self.status.DestroyChildren()    #get rid of special stuff on status bar
    316316        self.status.SetStatusText('',1)  # clear old status message
    317         page = self.nb.GetCurrentPage()
     317        page = self.panelList[self.nb.GetSelection()]   #GetCurrentPage() not in wx 2.7
    318318        page.needsUpdate = True
    319319        if page.Refresh():  # refresh plot, if possible
     
    25262526        Page.canvas.draw()
    25272527       
     2528################################################################################
     2529##### PlotXYZ
     2530################################################################################
     2531           
    25282532def PlotXYZ(G2frame,XY,Z,labelX=None,labelY=None,newPlot=False,Title=''):
    25292533    '''simple contour plot of xyz data, used for diagnostic purposes
     
    25612565        wx.CallAfter(PlotXYZ,G2frame,XY,Z,labelX,labelY,False,Title)
    25622566   
     2567    def OnKeyBox(event):
     2568        if G2frame.G2plotNB.nb.GetSelection() == G2frame.G2plotNB.plotList.index(type):
     2569            event.key = cb.GetValue()[0]
     2570            cb.SetValue(' key press')
     2571            wx.CallAfter(OnKeyPress,event)
     2572        Page.canvas.SetFocus() # redirect the Focus from the button back to the plot
     2573
    25632574    def OnMotion(event):
    25642575        xpos = event.xdata
     
    25972608        'i: interpolation method','s: color scheme')
    25982609#    G2frame.G2plotNB.RaisePageNoRefresh(Page)
     2610    Page.keyPress = OnKeyPress
     2611    Page.SetFocus()
    25992612    G2frame.G2plotNB.status.DestroyChildren()
    26002613    Nxy = Z.shape
     
    28512864    G2frame.G2plotNB.clearReplotFlag('Peak Widths')   
    28522865    Page.Choice = None
    2853 #    G2frame.G2plotNB.RaisePageNoRefresh(Page)
     2866    G2frame.G2plotNB.RaisePageNoRefresh(Page)
    28542867   
    28552868    Page.canvas.SetToolTipString('')
     
    29702983        Plot.legend(loc='best')
    29712984        Page.canvas.draw()
    2972 
    29732985   
    29742986################################################################################
     
    33653377        Page.canvas.mpl_connect('key_press_event', OnPlotKeyPress)
    33663378   
    3367 #    G2frame.G2plotNB.RaisePageNoRefresh(Page)
     3379    G2frame.G2plotNB.RaisePageNoRefresh(Page)
     3380    G2frame.G2plotNB.status.DestroyChildren()
    33683381    General = data['General']
    33693382    cx,ct,cs,cia = General['AtomPtrs']
     
    34533466    newAtomDict = Data.get('newAtomDict',{})
    34543467    G2frame.G2plotNB.Delete('Covariance')
     3468    G2frame.G2plotNB.status.DestroyChildren()
    34553469   
    34563470
     
    35063520    Page.Choice = ['s: to change colors']
    35073521    Page.keyPress = OnPlotKeyPress
    3508 #    G2frame.G2plotNB.RaisePageNoRefresh(Page)
     3522    G2frame.G2plotNB.RaisePageNoRefresh(Page)
    35093523    G2frame.G2plotNB.status.SetFields(['',''])   
    35103524    acolor = mpl.cm.get_cmap(G2frame.VcovColor)
     
    35753589        Page.canvas.mpl_connect('motion_notify_event', OnMotion)
    35763590   
    3577 #    G2frame.G2plotNB.RaisePageNoRefresh(Page)
     3591    G2frame.G2plotNB.RaisePageNoRefresh(Page)
    35783592    G2frame.G2plotNB.status.SetFields(['','Use mouse LB to identify torsion atoms'])
    35793593    Plot.plot(X,torsion,'b+')
     
    36623676    Page.Choice = ['s: to change colors']
    36633677    Page.keyPress = OnPlotKeyPress
    3664 #    G2frame.G2plotNB.RaisePageNoRefresh(Page)
     3678    G2frame.G2plotNB.RaisePageNoRefresh(Page)
    36653679    G2frame.G2plotNB.status.SetFields(['','Use mouse LB to identify phi/psi atoms'])
    36663680    acolor = mpl.cm.get_cmap(G2frame.RamaColor)
     
    49224936                G2frame.dataDisplay.cameraPosTxt.SetLabel('Camera Position: '+'%.2f'%(drawingData['cameraPos']))
    49234937                G2frame.dataDisplay.cameraSlider.SetValue(drawingData['cameraPos'])
    4924             Draw('wheel')
     4938        Draw('wheel')
    49254939       
    49264940    def getSelection():
     
    56285642        altDown = False
    56295643    Font = Page.GetFont()
    5630 #    G2frame.G2plotNB.RaisePageNoRefresh(Page)
     5644    G2frame.G2plotNB.RaisePageNoRefresh(Page)
    56315645    Page.Choice = None
    56325646    if mapData.get('Flip',False):
     
    56455659    cb.Bind(wx.EVT_COMBOBOX, OnKeyBox)
    56465660    cb.SetValue(' save as/key:')
    5647     Page.canvas.Bind(wx.EVT_MOUSEWHEEL, OnMouseWheel)
    56485661    Page.canvas.Bind(wx.EVT_LEFT_DOWN, OnMouseDown)
    56495662    Page.canvas.Bind(wx.EVT_RIGHT_DOWN, OnMouseDown)
     
    56525665    Page.canvas.Bind(wx.EVT_KEY_DOWN,OnKeyPressed)
    56535666    Page.canvas.Bind(wx.EVT_MOTION, OnMouseMove)
     5667    Page.canvas.Bind(wx.EVT_MOUSEWHEEL, OnMouseWheel)
    56545668    Page.canvas.Bind(wx.EVT_SIZE, OnSize)
    56555669    Page.canvas.Bind(wx.EVT_SET_FOCUS, OnFocus)
     
    62976311            if Page.labels:
    62986312                RenderLabel(x,y,z,'  '+AtNames[iat],matRot)
    6299 #        if Page.context: Page.canvas.SetCurrent(Page.context)    # wx 2.9 fix
     6313        if Page.context: Page.canvas.SetCurrent(Page.context)    # wx 2.9 fix
    63006314        Page.canvas.SwapBuffers()
    63016315
     
    63176331    choice = [' save as:','jpeg','tiff','bmp']
    63186332    Page.keyPress = OnPlotKeyPress
    6319 #    G2frame.G2plotNB.RaisePageNoRefresh(Page)
     6333    G2frame.G2plotNB.RaisePageNoRefresh(Page)
    63206334    Font = Page.GetFont()
    63216335    cb = wx.ComboBox(G2frame.G2plotNB.status,style=wx.CB_DROPDOWN|wx.CB_READONLY,choices=choice)
  • trunk/GSASIIpwd.py

    r2195 r2197  
    6262npT2stl = lambda tth, wave: 2.0*npsind(tth/2.0)/wave
    6363npT2q = lambda tth,wave: 2.0*np.pi*npT2stl(tth,wave)
    64 forln2 = 4.0*math.log(2.0)
     64ateln2 = 8.0*math.log(2.0)
    6565   
    6666#GSASII pdf calculation routines
     
    17731773    return Parms
    17741774
    1775 def StackSim(Layers,ctrls,HistName='',scale=0.,background={},limits=[],inst={},profile=[]):
     1775def StackSim(Layers,ctrls,scale=0.,background={},limits=[],inst={},profile=[]):
    17761776    '''Simulate powder or selected area diffraction pattern from stacking faults using DIFFaX
    17771777   
     
    17791779                        'Width':[[10.,10.],[False,False]],'Toler':0.01,'AtInfo':{},
    17801780                        'Layers':[],'Stacking':[],'Transitions':[]}
    1781     param: HistName str: histogram name to simulate 'PWDR...'
     1781    param: ctrls string: controls string to be written on DIFFaX controls.dif file
    17821782    param: scale float: scale factor
    17831783    param: background dict: background parameters
     
    18381838    if ctrls == '0\n0\n3\n':
    18391839        df.write('%.4f\n'%(G2mth.getMeanWave(inst)))
    1840         U = forln2*inst['U'][1]/10000.
    1841         V = forln2*inst['V'][1]/10000.
    1842         W = forln2*inst['W'][1]/10000.
     1840        U = ateln2*inst['U'][1]/10000.
     1841        V = ateln2*inst['V'][1]/10000.
     1842        W = ateln2*inst['W'][1]/10000.
    18431843        HWHM = U*nptand(x0[iBeg:iFin]/2.)**2+V*nptand(x0[iBeg:iFin]/2.)+W
    1844         HW = np.mean(HWHM)
     1844        HW = np.sqrt(np.mean(HWHM))
    18451845    #    df.write('PSEUDO-VOIGT 0.015 -0.0036 0.009 0.605 TRIM\n')
    1846     #    df.write('GAUSSIAN %.6f TRIM\n'%(HW))     #fast option - might not really matter
    1847         df.write('GAUSSIAN %.6f %.6f %.6f TRIM\n'%(U,V,W))    #slow - make a GUI option?
     1846        if 'Mean' in Layers['selInst']:
     1847            df.write('GAUSSIAN %.6f TRIM\n'%(HW))     #fast option - might not really matter
     1848        elif 'Gaussian' in Layers['selInst']:
     1849            df.write('GAUSSIAN %.6f %.6f %.6f TRIM\n'%(U,V,W))    #slow - make a GUI option?
     1850        else:
     1851            df.write('None\n')
    18481852    else:
    18491853        df.write('0.10\nNone\n')
     
    19191923        subp.call(DIFFaX)
    19201924    except OSError:
    1921         print 'DIFFax.exe is not available for this platform - under development'
    1922     print 'DIFFaX time = %.2fs'%(time.time()-time0)
     1925        print ' DIFFax.exe is not available for this platform - under development'
     1926    print ' DIFFaX time = %.2fs'%(time.time()-time0)
    19231927    if os.path.exists('GSASII-DIFFaX.spc'):
    19241928        Xpat = np.loadtxt('GSASII-DIFFaX.spc').T
     
    19271931        backDict['Lam1'] = G2mth.getWave(inst)
    19281932        profile[4][iBeg:iFin] = getBackground('',backDict,bakType,inst['Type'][0],profile[0][iBeg:iFin])[0]   
    1929         profile[3][iBeg:iFin] = Xpat[2]*scale+profile[4][iBeg:iFin]
     1933        profile[3][iBeg:iFin] = Xpat[-1]*scale+profile[4][iBeg:iFin]
    19301934        if not np.any(profile[1]):                   #fill dummy data x,y,w,yc,yb,yd
    19311935            rv = st.poisson(profile[3][iBeg:iFin])
     
    19471951    os.remove('GSASII-DIFFaX.dat')
    19481952   
    1949 def CalcStackingPWDR(Layers,HistName,scale,background,limits,inst,profile):
    1950     pass
    1951    
    1952 def CalcStackingSADP(Layers):
    1953    
    1954     rand.seed()
    1955     ranSeed = rand.randint(1,2**16-1)
    1956 # Scattering factors
     1953def SetPWDRscan(inst,limits,profile):
     1954   
     1955    wave = G2mth.getMeanWave(inst)
     1956    x0 = profile[0]
     1957    iBeg = np.searchsorted(x0,limits[0])
     1958    iFin = np.searchsorted(x0,limits[1])
     1959    if iFin-iBeg > 20000:
     1960        iFin = iBeg+20000
     1961    Dx = (x0[iFin]-x0[iBeg])/(iFin-iBeg)
     1962    pyx.pygetinst(wave,x0[iBeg],x0[iFin],Dx)
     1963    return iFin-iBeg
     1964       
     1965def SetStackingSF(Layers):
     1966# Load scattering factors into DIFFaX arrays
    19571967    import atmdata
    19581968    atTypes = Layers['AtInfo'].keys()
     
    19741984    SFdat = np.array(SFdat)
    19751985    pyx.pyloadscf(len(atTypes),aTypes,SFdat.T)
     1986   
     1987def SetStackingClay(Layers,Type):
    19761988# Controls
     1989    rand.seed()
     1990    ranSeed = rand.randint(1,2**16-1)
    19771991    try:   
    19781992        laueId = ['-1','2/m(ab)','2/m(c)','mmm','-3','-3m','4/m','4/mmm',
     
    19801994    except ValueError:  #for 'unknown'
    19811995        laueId = -1
    1982     planeId = ['h0l','0kl','hhl','h-hl'].index(Layers['Sadp']['Plane'])+1
    1983     lmax = int(Layers['Sadp']['Lmax'])
    1984     mult = 1
     1996    if 'SADP' in Type:
     1997        planeId = ['h0l','0kl','hhl','h-hl'].index(Layers['Sadp']['Plane'])+1
     1998        lmax = int(Layers['Sadp']['Lmax'])
     1999    else:
     2000        planeId = 0
     2001        lmax = 0
    19852002# Sequences
    19862003    StkType = ['recursive','explicit'].index(Layers['Stacking'][0])
     
    19982015        StkParm = int(Layers['Stacking'][1])
    19992016    Wdth = Layers['Width'][0]
     2017    mult = 1
    20002018    controls = [laueId,planeId,lmax,mult,StkType,StkParm,ranSeed]
    20012019    LaueSym = Layers['Laue'].ljust(12)
    20022020    pyx.pygetclay(controls,LaueSym,Wdth,Nstk,StkSeq)
    2003    
     2021    return laueId,controls
     2022   
     2023def SetCellAtoms(Layers):
    20042024    Cell = Layers['Cell'][1:4]+Layers['Cell'][6:7]
    20052025# atoms in layers
     2026    atTypes = Layers['AtInfo'].keys()
    20062027    AtomXOU = []
    20072028    AtomTp = []
     
    20332054    Nlayers = len(layerNames)
    20342055    pyx.pycellayer(Cell,Natm,AtomTp,AtomXOU.T,Nuniq,LayerSymm,Nlayers,LayerNum)
     2056    return Nlayers
     2057   
     2058def SetStackingTrans(Layers,Nlayers):
    20352059# Transitions
    20362060    TransX = []
     
    20422066    TransX = np.array(TransX,dtype='float')
    20432067    pyx.pygettrans(Nlayers,TransP,TransX)
     2068   
     2069def CalcStackingPWDR(Layers,scale,background,limits,inst,profile):
     2070# Scattering factors
     2071    SetStackingSF(Layers)
     2072# Controls & sequences
     2073    laueId,controls = SetStackingClay(Layers,'PWDR')
     2074# cell & atoms
     2075    Nlayers = SetCellAtoms(Layers)   
     2076# Transitions
     2077    SetStackingTrans(Layers,Nlayers)
     2078# PWDR scan
     2079    Nsteps = SetPWDRscan(inst,limits,profile)
     2080# result as Spec
     2081    x0 = profile[0]
     2082    iBeg = np.searchsorted(x0,limits[0])
     2083    iFin = np.searchsorted(x0,limits[1])
     2084    if iFin-iBeg > 20000:
     2085        iFin = iBeg+20000
     2086    Nspec = 20001       
     2087    spec = np.zeros(Nspec,dtype='double')   
     2088    time0 = time.time()
     2089    pyx.pygetspc(controls,Nspec,spec)
     2090    print ' GETSPC time = %.2fs'%(time.time()-time0)
     2091    time0 = time.time()
     2092    U = ateln2*inst['U'][1]/10000.
     2093    V = ateln2*inst['V'][1]/10000.
     2094    W = ateln2*inst['W'][1]/10000.
     2095    HWHM = U*nptand(x0[iBeg:iFin]/2.)**2+V*nptand(x0[iBeg:iFin]/2.)+W
     2096    HW = np.mean(HWHM)
     2097    BrdSpec = np.zeros(Nsteps)
     2098    if 'Mean' in Layers['selInst']:
     2099        pyx.pyprofile(U,V,W,HW,1,Nsteps,BrdSpec)
     2100    elif 'Gaussian' in Layers['selInst']:
     2101        pyx.pyprofile(U,V,W,HW,4,Nsteps,BrdSpec)
     2102    else:
     2103        BrdSpec = spec[:Nsteps]
     2104    iFin = iBeg+Nsteps
     2105    bakType,backDict,backVary = SetBackgroundParms(background)
     2106    backDict['Lam1'] = G2mth.getWave(inst)
     2107    profile[4][iBeg:iFin] = getBackground('',backDict,bakType,inst['Type'][0],profile[0][iBeg:iFin])[0]   
     2108    profile[3][iBeg:iFin] = BrdSpec*scale+profile[4][iBeg:iFin]
     2109    if not np.any(profile[1]):                   #fill dummy data x,y,w,yc,yb,yd
     2110        rv = st.poisson(profile[3][iBeg:iFin])
     2111        profile[1][iBeg:iFin] = rv.rvs()
     2112        Z = np.ones_like(profile[3][iBeg:iFin])
     2113        Z[1::2] *= -1
     2114        profile[1][iBeg:iFin] = profile[3][iBeg:iFin]+np.abs(profile[1][iBeg:iFin]-profile[3][iBeg:iFin])*Z
     2115        profile[2][iBeg:iFin] = np.where(profile[1][iBeg:iFin]>0.,1./profile[1][iBeg:iFin],1.0)
     2116    profile[5][iBeg:iFin] = profile[1][iBeg:iFin]-profile[3][iBeg:iFin]
     2117    print ' Broadening time = %.2fs'%(time.time()-time0)
     2118   
     2119   
     2120#    GSASIIpath.IPyBreak()
     2121   
     2122def CalcStackingSADP(Layers):
     2123   
     2124# Scattering factors
     2125    SetStackingSF(Layers)
     2126# Controls & sequences
     2127    laueId,controls = SetStackingClay(Layers,'SADP')
     2128# cell & atoms
     2129    Nlayers = SetCellAtoms(Layers)   
     2130# Transitions
     2131    SetStackingTrans(Layers,Nlayers)
    20442132# result as Sadp
    20452133    mirror = laueId in [-1,2,3,7,8,9,10]
     
    20662154        iB += Nblk
    20672155    Layers['Sadp']['Img'] = Sapd
    2068     print 'GETSAD time = %.2fs'%(time.time()-time0)
     2156    print ' GETSAD time = %.2fs'%(time.time()-time0)
    20692157#    GSASIIpath.IPyBreak()
    20702158   
  • trunk/fsource/DIFFaXsubs/DIFFaXsubs.for

    r2191 r2197  
    25722572      max_th = HALF * th2_max
    25732573      max_indx = int((max_th - min_th) / d_theta + 1)
    2574       if(max_indx.gt.MAX_SP) then
    2575         d_theta = (max_th - min_th) / (MAX_SP - 1)
    2576         max_indx = int((max_th - min_th) / d_theta + 1)
    2577         write(op,300) ''
    2578         write(op,250) 'd_theta is too small and has been adjusted to ',
    2579      |                   TWO*d_theta*RAD2DEG
    2580       endif
    2581 *
    2582  1234 write(op,300)
    2583      | 'Enter 1 for adaptive quadrature over all l values'
    2584       write(op,300) 'on rows with "sharp" spots'
    2585       read(cntrl,*,err=1234) full_shrp
    2586       if(CFile) write(op,400) full_shrp
     2574*      if(max_indx.gt.MAX_SP) then
     2575*        d_theta = (max_th - min_th) / (MAX_SP - 1)
     2576*        max_indx = int((max_th - min_th) / d_theta + 1)
     2577*        write(op,300) ''
     2578*        write(op,250) 'd_theta is too small and has been adjusted to ',
     2579*     |                   TWO*d_theta*RAD2DEG
     2580*      endif
     2581*
     2582* 1234 write(op,300)
     2583*     | 'Enter 1 for adaptive quadrature over all l values'
     2584*      write(op,300) 'on rows with "sharp" spots'
     2585*      read(cntrl,*,err=1234) full_shrp
     2586*      if(CFile) write(op,400) full_shrp
    25872587* zero out spectra
    25882588      do 10 i = 1, MAX_SP
     
    26262626     |            SymGrpNo.ne.1) goto 30
    26272627            if(SymGrpNo.eq.11 .and. .not.l_axis) goto 30
    2628             write(op,200) 'Integrating along l at ',h,k,
    2629      |            '''',infile(1:LENGTH(infile)),''''
     2628*            write(op,200) 'Integrating along l at ',h,k,
     2629*     |            '''',infile(1:LENGTH(infile)),''''
    26302630            on_bndry = abs(hk_th-theta1).le.eps3 .or.
    26312631     |                 abs(hk_th-theta2).le.eps3
     
    26652665            if(.not.shrp .or. full_shrp.eq.1) then
    26662666* broad streak or full adaptive integration over sharp spots
    2667               if(full_shrp.eq.1 .or. full_brd.eq.1)
    2668      |                write(op,300) 'Full adaptive integration'
     2667*              if(full_shrp.eq.1 .or. full_brd.eq.1)
     2668*     |                write(op,300) 'Full adaptive integration'
    26692669* integrate each d_theta's range of reciprocal space
    26702670              do 40 theta = tmp, max_th-eps10, d_theta
  • trunk/fsource/pydiffax.for

    r2191 r2197  
    2424      intp_F = .TRUE.
    2525      n_atoms = NATP
     26      RETURN
     27      END
     28       
     29      SUBROUTINE PYGETINST(LAMB,TTHMIN,TTHMAX,DELTTH)
     30       
     31Cf2py intent(in) LAMB
     32Cf2py intent(in) TTHMIN
     33Cf2py intent(in) TTHMAX
     34Cf2py intent(in) DELTTH
     35   
     36      INCLUDE 'DIFFaXsubs/DIFFaX.par'
     37      INCLUDE 'DIFFaXsubs/DIFFaX.inc'
     38
     39      REAL*8 LAMB,TTHMIN,TTHMAX,DELTTH
     40       
     41      lambda = lamb
     42      th2_min = TTHMIN*DEG2RAD
     43      th2_max = TTHMAX*DEG2RAD
     44      d_theta = DELTTH*HALF*DEG2RAD
     45       
    2646      RETURN
    2747      END
     
    6282      SymGrpNo = CNTRLS(1)
    6383      check_sym = .TRUE.
     84      full_shrp = 1
     85      full_brd = 1
    6486C CNTRLS = [laueId,planeId,lmax,mult,StkType,StkParm,ranSeed]
    6587      bitdepth = 16
     
    180202      END
    181203       
     204      SUBROUTINE PYGETSPC(CNTRLS,NSADP,SADP)
     205       
     206Cf2py intent(in) CNTRLS
     207Cf2py intent(in) NSADP
     208Cf2py intent(in/out) SADP
     209Cf2py depend(NSADP) SADP
     210           
     211      INCLUDE 'DIFFaXsubs/DIFFaX.par'
     212      INCLUDE 'DIFFaXsubs/DIFFaX.inc'
     213
     214      INTEGER*4 CNTRLS(7),NSADP,I,j,k
     215      REAL*8 SADP(NSADP),AGLQ16
     216      LOGICAL GETSPC,ok
     217       
     218      EXTERNAL AGLQ16,GETSPC
     219
     220
     221C      print *,n_actual,(l_n_atoms(i),i=1,n_actual)
     222C      do j=1,n_actual
     223C        do i=1,l_n_atoms(j)
     224C          print *,a_name(i,j),(a_pos(k,i,j),k=1,3)
     225C        end do
     226C      end do
     227c      print *, recrsv,inf_thick,xplcit,rndm,l_cnt,has_l_mirror
     228C      do i=1,n_layers
     229C      print *,' layer',i
     230C         do j=1,n_layers
     231C            print *,'layer',j,l_alpha(i,j),(l_r(k,i,j),k=1,3)
     232C         end do
     233C      end do
     234c      print *,cell_a,cell_b,cell_c,cell_gamma,pnt_grp,SymGrpNo
     235c      DoSymDump = .TRUE.
     236   
     237      ok = .TRUE.
     238      CALL SPHCST()
     239      CALL DETUN()
     240      CALL OPTIMZ('GSAS-II',ok)
     241       
     242C      print *,lambda,max_angle,h_bnd,k_bnd,l_bnd,no_trials,
     243C     1  rad_type,X_RAY,n_atoms
     244C      print *,(l_g(j),j=1,n_layers)
     245C      do j=1,n_layers
     246C        print *,(hx_ky(i,j),i=1,l_n_atoms(j))
     247C        print *,(mat(i,j),i=1,n_layers)
     248C        print *,(mat1(i,j),i=1,n_layers)
     249C        print *,(l_phi(i,j),i=1,n_layers)
     250C      end do
     251       
     252      ok = GETSPC(AGLQ16,'GSAS-II')             
     253      DO I=1,NSADP
     254        SADP(I) = spec(I)
     255      END DO
     256      RETURN
     257      END
     258       
     259      SUBROUTINE PYPROFILE(U,V,W,HW,BLUR,NBRD,BRDSPC)
     260       
     261Cf2py intent(in) U
     262Cf2py intent(in) V
     263Cf2py intent(in) W
     264Cf2py intent(in) HW
     265Cf2py intent(in) NBRD
     266Cf2py intent(in/out) BRDSPC
     267Cf2py depend(NBRD) BRDSPC
     268               
     269      INCLUDE 'DIFFaXsubs/DIFFaX.par'
     270      INCLUDE 'DIFFaXsubs/DIFFaX.inc'
     271       
     272      INTEGER*4 BLUR,i,NBRD   
     273      REAL*8 U,V,W,HW,BRDSPC(NBRD),tth_min
     274       
     275      tth_min = ZERO
     276           
     277      if (blur.eq.GAUSS) then
     278        FWHM = HW
     279        call GAUSSN(tth_min)
     280      else if (blur.eq.PV_GSS) then
     281        pv_u = U
     282        pv_v = V
     283        pv_w = W
     284        pv_gamma = ZERO
     285        call PV(tth_min)
     286      end if
     287      do i=1,NBRD
     288        BRDSPC(i) = brd_spc(i)
     289      end do
     290       
     291      RETURN
     292      END
     293       
    182294      SUBROUTINE PYGETSADP(CNTRLS,NSADP,SADP,HKLIM,INCR,NBLK)
    183295       
     
    193305      INCLUDE 'DIFFaXsubs/DIFFaX.inc'
    194306
    195       INTEGER*4 CNTRLS(7),NSADP,GET_SYM,i_plane,hk_lim,i,j,k
     307      INTEGER*4 CNTRLS(7),NSADP,i_plane,hk_lim,i,j,k
    196308      INTEGER*4 HKLIM,NBLK
    197309      REAL*8 SADP(NSADP),AGLQ16,l_upper,INCR
    198310      LOGICAL ok
    199311       
    200       EXTERNAL AGLQ16,GET_SYM                  
     312      EXTERNAL AGLQ16                 
    201313                   
    202314      i_plane = CNTRLS(2)
Note: See TracChangeset for help on using the changeset viewer.