Changeset 2197
- Timestamp:
- Apr 6, 2016 4:14:46 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 24 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASII.py
r2196 r2197 2325 2325 self.oldImagefile = '' # the name of the last image file read 2326 2326 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 = [] 2331 2328 self.Integrate = 0 2332 2329 self.imageDefault = {} -
trunk/GSASIIgrid.py
r2195 r2197 512 512 self.parmRange = [0.,1.] 513 513 self.parmStep = 2 514 self.Inst = 'None' 514 515 self.Draw() 515 516 … … 540 541 parmrange.SetValue('%.3f %.3f'%(vals[0],vals[1])) 541 542 self.parmRange = vals 543 544 def OnInstSel(event): 545 self.Inst = instsel.GetValue() 542 546 543 547 self.panel.Destroy() … … 545 549 mainSizer = wx.BoxSizer(wx.VERTICAL) 546 550 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) 555 562 if self.Parms: 556 563 parmSel = wx.BoxSizer(wx.HORIZONTAL) … … 587 594 planeSizer.Add(lmax,0,WACV) 588 595 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) 589 605 OkBtn = wx.Button(self.panel,-1,"Ok") 590 606 OkBtn.Bind(wx.EVT_BUTTON, self.OnOk) … … 605 621 def GetSelection(self): 606 622 if 'powder' in self.calcType: 607 return ' 0\n0\n3\n','','',self.Parm,self.parmRange,self.parmStep623 return 'PWDR',self.Inst,self.Parm,self.parmRange,self.parmStep 608 624 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 612 626 613 627 def OnOk(self,event): -
trunk/GSASIIphsGUI.py
r2195 r2197 2657 2657 Obj.SetCellValue(Xi,5,'') 2658 2658 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) 2659 2673 2660 2674 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) 2662 2681 Names = [layer['Name'] for layer in Layers['Layers']] 2663 2682 transArray = Layers['Transitions'] … … 2684 2703 attr.SetEditor(G2G.GridFractionEditor(transGrid)) 2685 2704 transGrid.SetColAttr(c, attr) 2686 transGrid.Bind(wg.EVT_GRID_CELL_LEFT_ DCLICK, PlotSelect)2705 transGrid.Bind(wg.EVT_GRID_CELL_LEFT_CLICK, PlotSelect) 2687 2706 transGrid.AutoSizeColumns(True) 2688 2707 transSizer.Add(transGrid) … … 2926 2945 dlg = G2gd.DIFFaXcontrols(G2frame,ctrls) 2927 2946 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() 2932 2948 else: 2933 2949 return 2934 if ctrls == '0\n0\n3\n': #powder pattern 2950 if 'PWDR' in simCodes[0]: #powder pattern 2951 data['Layers']['selInst'] = simCodes[1] 2935 2952 UseList = [] 2936 2953 for item in data['Histograms']: … … 2963 2980 profile = G2frame.PatternTree.GetItemPyData(G2frame.PatternId)[1] 2964 2981 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() 2967 2990 G2plt.PlotPatterns(G2frame,plotType='PWDR') 2968 2991 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) 2969 2999 # G2pwd.StackSim(data['Layers'],ctrls) 2970 3000 G2pwd.CalcStackingSADP(data['Layers']) … … 2977 3007 dlg = G2gd.DIFFaXcontrols(G2frame,ctrls,Parms) 2978 3008 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]] 2984 3011 else: 2985 3012 return -
trunk/GSASIIplot.py
r2196 r2197 313 313 return 314 314 # print 'OnPageChanged' 315 self.status.DestroyChildren() 315 self.status.DestroyChildren() #get rid of special stuff on status bar 316 316 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 318 318 page.needsUpdate = True 319 319 if page.Refresh(): # refresh plot, if possible … … 2526 2526 Page.canvas.draw() 2527 2527 2528 ################################################################################ 2529 ##### PlotXYZ 2530 ################################################################################ 2531 2528 2532 def PlotXYZ(G2frame,XY,Z,labelX=None,labelY=None,newPlot=False,Title=''): 2529 2533 '''simple contour plot of xyz data, used for diagnostic purposes … … 2561 2565 wx.CallAfter(PlotXYZ,G2frame,XY,Z,labelX,labelY,False,Title) 2562 2566 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 2563 2574 def OnMotion(event): 2564 2575 xpos = event.xdata … … 2597 2608 'i: interpolation method','s: color scheme') 2598 2609 # G2frame.G2plotNB.RaisePageNoRefresh(Page) 2610 Page.keyPress = OnKeyPress 2611 Page.SetFocus() 2599 2612 G2frame.G2plotNB.status.DestroyChildren() 2600 2613 Nxy = Z.shape … … 2851 2864 G2frame.G2plotNB.clearReplotFlag('Peak Widths') 2852 2865 Page.Choice = None 2853 #G2frame.G2plotNB.RaisePageNoRefresh(Page)2866 G2frame.G2plotNB.RaisePageNoRefresh(Page) 2854 2867 2855 2868 Page.canvas.SetToolTipString('') … … 2970 2983 Plot.legend(loc='best') 2971 2984 Page.canvas.draw() 2972 2973 2985 2974 2986 ################################################################################ … … 3365 3377 Page.canvas.mpl_connect('key_press_event', OnPlotKeyPress) 3366 3378 3367 # G2frame.G2plotNB.RaisePageNoRefresh(Page) 3379 G2frame.G2plotNB.RaisePageNoRefresh(Page) 3380 G2frame.G2plotNB.status.DestroyChildren() 3368 3381 General = data['General'] 3369 3382 cx,ct,cs,cia = General['AtomPtrs'] … … 3453 3466 newAtomDict = Data.get('newAtomDict',{}) 3454 3467 G2frame.G2plotNB.Delete('Covariance') 3468 G2frame.G2plotNB.status.DestroyChildren() 3455 3469 3456 3470 … … 3506 3520 Page.Choice = ['s: to change colors'] 3507 3521 Page.keyPress = OnPlotKeyPress 3508 #G2frame.G2plotNB.RaisePageNoRefresh(Page)3522 G2frame.G2plotNB.RaisePageNoRefresh(Page) 3509 3523 G2frame.G2plotNB.status.SetFields(['','']) 3510 3524 acolor = mpl.cm.get_cmap(G2frame.VcovColor) … … 3575 3589 Page.canvas.mpl_connect('motion_notify_event', OnMotion) 3576 3590 3577 #G2frame.G2plotNB.RaisePageNoRefresh(Page)3591 G2frame.G2plotNB.RaisePageNoRefresh(Page) 3578 3592 G2frame.G2plotNB.status.SetFields(['','Use mouse LB to identify torsion atoms']) 3579 3593 Plot.plot(X,torsion,'b+') … … 3662 3676 Page.Choice = ['s: to change colors'] 3663 3677 Page.keyPress = OnPlotKeyPress 3664 #G2frame.G2plotNB.RaisePageNoRefresh(Page)3678 G2frame.G2plotNB.RaisePageNoRefresh(Page) 3665 3679 G2frame.G2plotNB.status.SetFields(['','Use mouse LB to identify phi/psi atoms']) 3666 3680 acolor = mpl.cm.get_cmap(G2frame.RamaColor) … … 4922 4936 G2frame.dataDisplay.cameraPosTxt.SetLabel('Camera Position: '+'%.2f'%(drawingData['cameraPos'])) 4923 4937 G2frame.dataDisplay.cameraSlider.SetValue(drawingData['cameraPos']) 4924 4938 Draw('wheel') 4925 4939 4926 4940 def getSelection(): … … 5628 5642 altDown = False 5629 5643 Font = Page.GetFont() 5630 #G2frame.G2plotNB.RaisePageNoRefresh(Page)5644 G2frame.G2plotNB.RaisePageNoRefresh(Page) 5631 5645 Page.Choice = None 5632 5646 if mapData.get('Flip',False): … … 5645 5659 cb.Bind(wx.EVT_COMBOBOX, OnKeyBox) 5646 5660 cb.SetValue(' save as/key:') 5647 Page.canvas.Bind(wx.EVT_MOUSEWHEEL, OnMouseWheel)5648 5661 Page.canvas.Bind(wx.EVT_LEFT_DOWN, OnMouseDown) 5649 5662 Page.canvas.Bind(wx.EVT_RIGHT_DOWN, OnMouseDown) … … 5652 5665 Page.canvas.Bind(wx.EVT_KEY_DOWN,OnKeyPressed) 5653 5666 Page.canvas.Bind(wx.EVT_MOTION, OnMouseMove) 5667 Page.canvas.Bind(wx.EVT_MOUSEWHEEL, OnMouseWheel) 5654 5668 Page.canvas.Bind(wx.EVT_SIZE, OnSize) 5655 5669 Page.canvas.Bind(wx.EVT_SET_FOCUS, OnFocus) … … 6297 6311 if Page.labels: 6298 6312 RenderLabel(x,y,z,' '+AtNames[iat],matRot) 6299 #if Page.context: Page.canvas.SetCurrent(Page.context) # wx 2.9 fix6313 if Page.context: Page.canvas.SetCurrent(Page.context) # wx 2.9 fix 6300 6314 Page.canvas.SwapBuffers() 6301 6315 … … 6317 6331 choice = [' save as:','jpeg','tiff','bmp'] 6318 6332 Page.keyPress = OnPlotKeyPress 6319 #G2frame.G2plotNB.RaisePageNoRefresh(Page)6333 G2frame.G2plotNB.RaisePageNoRefresh(Page) 6320 6334 Font = Page.GetFont() 6321 6335 cb = wx.ComboBox(G2frame.G2plotNB.status,style=wx.CB_DROPDOWN|wx.CB_READONLY,choices=choice) -
trunk/GSASIIpwd.py
r2195 r2197 62 62 npT2stl = lambda tth, wave: 2.0*npsind(tth/2.0)/wave 63 63 npT2q = lambda tth,wave: 2.0*np.pi*npT2stl(tth,wave) 64 forln2 = 4.0*math.log(2.0)64 ateln2 = 8.0*math.log(2.0) 65 65 66 66 #GSASII pdf calculation routines … … 1773 1773 return Parms 1774 1774 1775 def StackSim(Layers,ctrls, HistName='',scale=0.,background={},limits=[],inst={},profile=[]):1775 def StackSim(Layers,ctrls,scale=0.,background={},limits=[],inst={},profile=[]): 1776 1776 '''Simulate powder or selected area diffraction pattern from stacking faults using DIFFaX 1777 1777 … … 1779 1779 'Width':[[10.,10.],[False,False]],'Toler':0.01,'AtInfo':{}, 1780 1780 '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 1782 1782 param: scale float: scale factor 1783 1783 param: background dict: background parameters … … 1838 1838 if ctrls == '0\n0\n3\n': 1839 1839 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. 1843 1843 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)) 1845 1845 # 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') 1848 1852 else: 1849 1853 df.write('0.10\nNone\n') … … 1919 1923 subp.call(DIFFaX) 1920 1924 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) 1923 1927 if os.path.exists('GSASII-DIFFaX.spc'): 1924 1928 Xpat = np.loadtxt('GSASII-DIFFaX.spc').T … … 1927 1931 backDict['Lam1'] = G2mth.getWave(inst) 1928 1932 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] 1930 1934 if not np.any(profile[1]): #fill dummy data x,y,w,yc,yb,yd 1931 1935 rv = st.poisson(profile[3][iBeg:iFin]) … … 1947 1951 os.remove('GSASII-DIFFaX.dat') 1948 1952 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 1953 def 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 1965 def SetStackingSF(Layers): 1966 # Load scattering factors into DIFFaX arrays 1957 1967 import atmdata 1958 1968 atTypes = Layers['AtInfo'].keys() … … 1974 1984 SFdat = np.array(SFdat) 1975 1985 pyx.pyloadscf(len(atTypes),aTypes,SFdat.T) 1986 1987 def SetStackingClay(Layers,Type): 1976 1988 # Controls 1989 rand.seed() 1990 ranSeed = rand.randint(1,2**16-1) 1977 1991 try: 1978 1992 laueId = ['-1','2/m(ab)','2/m(c)','mmm','-3','-3m','4/m','4/mmm', … … 1980 1994 except ValueError: #for 'unknown' 1981 1995 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 1985 2002 # Sequences 1986 2003 StkType = ['recursive','explicit'].index(Layers['Stacking'][0]) … … 1998 2015 StkParm = int(Layers['Stacking'][1]) 1999 2016 Wdth = Layers['Width'][0] 2017 mult = 1 2000 2018 controls = [laueId,planeId,lmax,mult,StkType,StkParm,ranSeed] 2001 2019 LaueSym = Layers['Laue'].ljust(12) 2002 2020 pyx.pygetclay(controls,LaueSym,Wdth,Nstk,StkSeq) 2003 2021 return laueId,controls 2022 2023 def SetCellAtoms(Layers): 2004 2024 Cell = Layers['Cell'][1:4]+Layers['Cell'][6:7] 2005 2025 # atoms in layers 2026 atTypes = Layers['AtInfo'].keys() 2006 2027 AtomXOU = [] 2007 2028 AtomTp = [] … … 2033 2054 Nlayers = len(layerNames) 2034 2055 pyx.pycellayer(Cell,Natm,AtomTp,AtomXOU.T,Nuniq,LayerSymm,Nlayers,LayerNum) 2056 return Nlayers 2057 2058 def SetStackingTrans(Layers,Nlayers): 2035 2059 # Transitions 2036 2060 TransX = [] … … 2042 2066 TransX = np.array(TransX,dtype='float') 2043 2067 pyx.pygettrans(Nlayers,TransP,TransX) 2068 2069 def 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 2122 def 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) 2044 2132 # result as Sadp 2045 2133 mirror = laueId in [-1,2,3,7,8,9,10] … … 2066 2154 iB += Nblk 2067 2155 Layers['Sadp']['Img'] = Sapd 2068 print ' GETSAD time = %.2fs'%(time.time()-time0)2156 print ' GETSAD time = %.2fs'%(time.time()-time0) 2069 2157 # GSASIIpath.IPyBreak() 2070 2158 -
trunk/fsource/DIFFaXsubs/DIFFaXsubs.for
r2191 r2197 2572 2572 max_th = HALF * th2_max 2573 2573 max_indx = int((max_th - min_th) / d_theta + 1) 2574 if(max_indx.gt.MAX_SP) then2575 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*RAD2DEG2580 endif2581 * 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_shrp2586 if(CFile) write(op,400) full_shrp2574 * 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 2587 2587 * zero out spectra 2588 2588 do 10 i = 1, MAX_SP … … 2626 2626 | SymGrpNo.ne.1) goto 30 2627 2627 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)),'''' 2630 2630 on_bndry = abs(hk_th-theta1).le.eps3 .or. 2631 2631 | abs(hk_th-theta2).le.eps3 … … 2665 2665 if(.not.shrp .or. full_shrp.eq.1) then 2666 2666 * 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' 2669 2669 * integrate each d_theta's range of reciprocal space 2670 2670 do 40 theta = tmp, max_th-eps10, d_theta -
trunk/fsource/pydiffax.for
r2191 r2197 24 24 intp_F = .TRUE. 25 25 n_atoms = NATP 26 RETURN 27 END 28 29 SUBROUTINE PYGETINST(LAMB,TTHMIN,TTHMAX,DELTTH) 30 31 Cf2py intent(in) LAMB 32 Cf2py intent(in) TTHMIN 33 Cf2py intent(in) TTHMAX 34 Cf2py 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 26 46 RETURN 27 47 END … … 62 82 SymGrpNo = CNTRLS(1) 63 83 check_sym = .TRUE. 84 full_shrp = 1 85 full_brd = 1 64 86 C CNTRLS = [laueId,planeId,lmax,mult,StkType,StkParm,ranSeed] 65 87 bitdepth = 16 … … 180 202 END 181 203 204 SUBROUTINE PYGETSPC(CNTRLS,NSADP,SADP) 205 206 Cf2py intent(in) CNTRLS 207 Cf2py intent(in) NSADP 208 Cf2py intent(in/out) SADP 209 Cf2py 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 221 C print *,n_actual,(l_n_atoms(i),i=1,n_actual) 222 C do j=1,n_actual 223 C do i=1,l_n_atoms(j) 224 C print *,a_name(i,j),(a_pos(k,i,j),k=1,3) 225 C end do 226 C end do 227 c print *, recrsv,inf_thick,xplcit,rndm,l_cnt,has_l_mirror 228 C do i=1,n_layers 229 C print *,' layer',i 230 C do j=1,n_layers 231 C print *,'layer',j,l_alpha(i,j),(l_r(k,i,j),k=1,3) 232 C end do 233 C end do 234 c print *,cell_a,cell_b,cell_c,cell_gamma,pnt_grp,SymGrpNo 235 c DoSymDump = .TRUE. 236 237 ok = .TRUE. 238 CALL SPHCST() 239 CALL DETUN() 240 CALL OPTIMZ('GSAS-II',ok) 241 242 C print *,lambda,max_angle,h_bnd,k_bnd,l_bnd,no_trials, 243 C 1 rad_type,X_RAY,n_atoms 244 C print *,(l_g(j),j=1,n_layers) 245 C do j=1,n_layers 246 C print *,(hx_ky(i,j),i=1,l_n_atoms(j)) 247 C print *,(mat(i,j),i=1,n_layers) 248 C print *,(mat1(i,j),i=1,n_layers) 249 C print *,(l_phi(i,j),i=1,n_layers) 250 C 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 261 Cf2py intent(in) U 262 Cf2py intent(in) V 263 Cf2py intent(in) W 264 Cf2py intent(in) HW 265 Cf2py intent(in) NBRD 266 Cf2py intent(in/out) BRDSPC 267 Cf2py 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 182 294 SUBROUTINE PYGETSADP(CNTRLS,NSADP,SADP,HKLIM,INCR,NBLK) 183 295 … … 193 305 INCLUDE 'DIFFaXsubs/DIFFaX.inc' 194 306 195 INTEGER*4 CNTRLS(7),NSADP, GET_SYM,i_plane,hk_lim,i,j,k307 INTEGER*4 CNTRLS(7),NSADP,i_plane,hk_lim,i,j,k 196 308 INTEGER*4 HKLIM,NBLK 197 309 REAL*8 SADP(NSADP),AGLQ16,l_upper,INCR 198 310 LOGICAL ok 199 311 200 EXTERNAL AGLQ16 ,GET_SYM312 EXTERNAL AGLQ16 201 313 202 314 i_plane = CNTRLS(2)
Note: See TracChangeset
for help on using the changeset viewer.