Changeset 4200


Ignore:
Timestamp:
Dec 13, 2019 8:37:00 AM (4 years ago)
Author:
vondreele
Message:

Add visualization of RMCProfile results, i.e. G(R), S(Q), partials, etc.
MOre enhancements for RMCProfile stuff

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk

    • Property svn:global-ignores
      •  

        old new  
        11CifFile
        22binwin2.7
         3pdbparser
         4pdbparser - Copy
    • Property svn:ignore
      •  

        old new  
        33basinhopping.py
        44binwin2.7
        5 binwin2.7
         5pdbparser
  • trunk/GSASIIdataGUI.py

    r4198 r4200  
    57175717       
    57185718        #Phase / fullrmc & RMCprofile (Reverse Monte Carlo method) tab
    5719         G2G.Define_wxId('wxID_SETUPRMC','wxID_LOADRMC','wxID_SAVERMC','wxID_RUNRMC', )       
     5719        G2G.Define_wxId('wxID_SETUPRMC','wxID_LOADRMC','wxID_SAVERMC','wxID_RUNRMC','wxID_VIEWRMC' )       
    57205720        self.FRMCMenu = wx.MenuBar()
    57215721        self.PrefillDataMenu(self.FRMCMenu)
     
    57275727        self.FRMCDataEdit.Append(G2G.wxID_SAVERMC,'Save','Save fullrmc or RMCprofile file')
    57285728        self.FRMCDataEdit.Append(G2G.wxID_RUNRMC,'Execute','Run fullrmc or RMCprofile file')
     5729        self.FRMCDataEdit.Append(G2G.wxID_VIEWRMC,'View','View fullrmc or RMCprofile results')
    57295730        self.PostfillDataMenu()
    57305731       
  • trunk/GSASIIphsGUI.py

    r4196 r4200  
    10951095        self.Phase = Phase
    10961096        self.SuperCell = [1,1,1]
     1097        self.UseSampBrd = [True,True]
    10971098        self.aTypes = self.Phase['General']['AtomTypes']
    10981099        self.atSeq = self.aTypes[:]
     
    11161117                self.atSeq = G2lat.SwapItems(self.atSeq,itype,tid)
    11171118            wx.CallAfter(self.Draw)
     1119           
     1120        def OnSize(event):
     1121            self.UseSampBrd[0] = samSize.GetValue()
     1122           
     1123        def OnStrain(event):
     1124            self.UseSampBrd[1] = strain.GetValue()
    11181125       
    11191126        self.panel.Destroy()
     
    11451152        histo.Bind(wx.EVT_COMBOBOX,OnHisto)
    11461153        mainSizer.Add(histo,0,WACV)
     1154        samSizer = wx.BoxSizer(wx.HORIZONTAL)
     1155        samSize = wx.CheckBox(self.panel,label=' Use size broadening?')
     1156        samSize.SetValue(self.UseSampBrd[0])
     1157        samSize.Bind(wx.EVT_CHECKBOX,OnSize)
     1158        strain = wx.CheckBox(self.panel,label=' Use mustrain broadening?')
     1159        strain.SetValue(self.UseSampBrd[1])
     1160        strain.Bind(wx.EVT_CHECKBOX,OnStrain)
     1161        samSizer.Add(samSize,0,WACV)
     1162        samSizer.Add(strain,0,WACV)
     1163        mainSizer.Add(samSizer,0,WACV)
    11471164        metalist = ['title','owner','material','comment','source']
    11481165        metaSizer = wx.FlexGridSizer(0,2,5,5)
     
    11671184    def GetData(self):
    11681185        'Returns the values from the dialog'
    1169         return self.SuperCell,self.histogram,self.metadata,self.atSeq
     1186        return self.SuperCell,self.histogram,self.metadata,self.atSeq,self.UseSampBrd
    11701187       
    11711188    def OnOK(self,event):
     
    45314548        RMCsel.Bind(wx.EVT_RADIOBOX, OnRMCselect)
    45324549        mainSizer.Add(RMCsel,0,WACV)
     4550        mainSizer.Add((5,5),0,WACV)
    45334551        if G2frame.RMCchoice == 'fullrmc':
    45344552            mainSizer.Add(wx.StaticText(G2frame.FRMC,label=' fullrmc run.py file preparation:'),0,WACV)
     
    45364554            G2frame.runtext = wx.TextCtrl(G2frame.FRMC,style=wx.TE_MULTILINE|wx.TE_DONTWRAP,size=(850,450))
    45374555#            G2frame.runtext.SetFont(font1)
     4556            mainSizer.Add(G2frame.runtext)
    45384557        else:
    45394558            mainSizer.Add(wx.StaticText(G2frame.FRMC,label=' RMCProfile input file preparation:'),0,WACV)
    4540            
    4541        
    4542         mainSizer.Add((5,5),0,WACV)
    4543         mainSizer.Add(G2frame.runtext)
     4559            G2frame.runtext = wx.TextCtrl(G2frame.FRMC,style=wx.TE_MULTILINE|wx.TE_DONTWRAP,size=(850,450))
     4560            mainSizer.Add(G2frame.runtext)
     4561           
     4562       
    45444563        SetPhaseWindow(G2frame.FRMC,mainSizer)
    45454564       
     
    46014620            dlg = SetUpRMCProfileDialog(G2frame,Name=pName,Phase=data)
    46024621            if dlg.ShowModal() == wx.ID_OK:
    4603                 superCell,histoName,meta,atSeq = dlg.GetData()
     4622                superCell,histoName,meta,atSeq,useSamBrd = dlg.GetData()
    46044623                PWId = G2gd.GetGPXtreeItemId(G2frame,G2frame.root,histoName)
    46054624                if PWId:
    46064625#                    Progress
     4626#                    print(useSamBrd)
     4627#                    print(data['Histograms'][histoName]['Size'])
     4628#                    print(data['Histograms'][histoName]['Mustrain'])
    46074629                    print(G2pwd.MakeInst(G2frame,pName,PWId)+ ' written')
    46084630                    backfile = G2pwd.MakeBack(G2frame,pName,PWId)
     
    47014723            pName = generalData['Name'].replace(' ','_')
    47024724            batch = open('runrmc.bat','w')
    4703             batch.write('::PATH=%PATH%;'+rmcexe+';c:'+rmcexe+'\cygwin_libs\n')
     4725            batch.write('ECHO OFF\n')
     4726            batch.write('::PATH=%PATH%;'+rmcexe+'\n')
    47044727            batch.write('SET RMCPROFILE_DIR='+G2frame.dirname+'\n')
    47054728            batch.write('SET RMCPROFILE_DRIVE=%~d1\n')
    4706             batch.write('::PATH=%PATH%;%RMCPROFILE_DIR%\exe;%RMCPROFILE_DIR%\exe\cygwin_libs\n')
    4707             batch.write('PATH=%RMCPROFILE_DIR%\exe;%RMCPROFILE_DIR%\exe\cygwin_libs;%PATH%\n')
     4729            batch.write('::PATH=%PATH%;%RMCPROFILE_DIR%\exe\n')
     4730            batch.write('PATH=%RMCPROFILE_DIR%\exe;%PATH%\n')
    47084731            batch.write('PATH\n')
    47094732            batch.write('Title RMCProfile\n')
     
    47224745#            finally:
    47234746#                dlg.Destroy()
    4724 
     4747           
     4748    def OnViewRMC(event):
     4749        if G2frame.RMCchoice == 'fullrmc':
     4750            print('view fullrmc results - TBD')
     4751        else:
     4752            generalData = data['General']
     4753            pName = generalData['Name'].replace(' ','_')
     4754            files =  {'_PDF1.csv':[],'_PDFpartials.csv':[],'_SQ1.csv':[],'_XFQ1.csv':[],
     4755                      '_SQ1partials.csv':[],'_FQ1.csv':[],'_FT_XFQ1.csv':[],
     4756                      '_FQ1partials.csv':[],'_bragg.csv':[],'.chi2':[]}
     4757            for item in files:
     4758                if os.path.exists(pName+item):
     4759                    OutFile = open(pName+item,'r')
     4760                    files[item] = OutFile.readlines()
     4761                    OutFile.close()
     4762                    print('RMCProfile file %s read'%(pName+item))
     4763                else:
     4764                    print('RMCProfile file %s not found'%(pName+item))
     4765#total result plots
     4766            Labels = {'_PDF1.csv':[r'$\mathsf{R,\AA}$','G(R)','RMCprofile G(R) for '],
     4767                '_SQ1.csv':[r'$\mathsf{Q,\AA^-1}$','S(Q)','RMCprofile S(Q) for '],
     4768                '_FQ1.csv':[r'$\mathsf{Q,\AA^-1}$','F(Q)','RMCprofile F(Q) for '],
     4769                '_FT_XFQ1.csv':[r'$\mathsf{R,\AA}$','G(R)','RMCprofile x-ray G(R) for '],
     4770                '_XFQ1.csv':[r'$\mathsf{Q,\AA^-1}$','F(Q)','RMCprofile x-ray F(Q) for '],
     4771                '_bragg.csv':[r'$\mathsf{TOF,\mu s}$','Normalized Intensity','RMCprofile bragg for ']}
     4772            for label in Labels:
     4773                X = []
     4774                Yobs = []
     4775                Ycalc = []
     4776                if len(files[label]):
     4777                    Names = files[label][0][:-1].split(',')
     4778                    for line in files[label][1:]:
     4779                        items = line.split(',')
     4780                        X.append(float(items[0]))
     4781                        Yobs.append(float(items[1]))
     4782                        Ycalc.append(float(items[2]))
     4783                    Yobs = np.array([X,Yobs])
     4784                    Ycalc = np.array([X,Ycalc])                       
     4785                    G2plt.PlotXY(G2frame,[Yobs,Ycalc],labelX=Labels[label][0],
     4786                        labelY=Labels[label][1],newPlot=True,Title=Labels[label][2]+pName,
     4787                        lines=True,names=Names[1:])
     4788#partials plots
     4789            Labels = {'_PDFpartials.csv':[r'$\mathsf{R,\AA}$','G(R)','RMCprofile G(R) partials for '],
     4790                '_SQ1partials.csv':[r'$\mathsf{Q,\AA^-1}$','S(Q)','RMCprofile S(Q) partials for '],
     4791                '_FQ1partials.csv':[r'$\mathsf{Q,\AA^-1}$','F(Q)','RMCprofile F(Q) partials for ']}
     4792            for label in Labels:
     4793                X = []
     4794                Partials = []
     4795                if len(files[label]):
     4796                    Names = files[label][0][:-1].split(',')
     4797                    for line in files[label][1:]:
     4798                        items = line.split(',')[:-1]
     4799                        X.append(float(items[0]))
     4800                        Partials.append([float(item) for item in items[1:]])
     4801                    X = np.array(X)
     4802                    Partials = np.array(Partials).T
     4803                    XY = [[X.T,Y.T] for Y in Partials]
     4804                    G2plt.PlotXY(G2frame,XY,labelX=Labels[label][0],
     4805                        labelY=Labels[label][1],newPlot=True,Title=Labels[label][2]+pName,
     4806                        lines=True,names=Names[1:])
     4807#chi**2 plot
     4808            X = []
     4809            Chi = []
     4810            Names = files['.chi2'][0][:-1].split()
     4811            if len(files['.chi2']) > 2:
     4812                for line in files['.chi2'][1:]:
     4813                    items = line[:-1].split()
     4814                    X.append(float(items[1]))
     4815                    Chi.append([float(item) for item in items[3:]])
     4816                X = np.array(X)
     4817                Chi = np.array(Chi).T
     4818                XY = [[X.T,Y.T] for Y in Chi]
     4819                G2plt.PlotXY(G2frame,XY,labelX='no. generated',
     4820                    labelY=r'$\mathsf{\chi^2}$',newPlot=True,Title='RMCProfile Chi^2 for '+pName,
     4821                    lines=True,names=Names[3:])
    47254822           
    47264823################################################################################
     
    1029910396            G2frame.Bind(wx.EVT_MENU, OnSaveRMC, id=G2G.wxID_SAVERMC)
    1030010397            G2frame.Bind(wx.EVT_MENU, OnRunRMC, id=G2G.wxID_RUNRMC)
     10398            G2frame.Bind(wx.EVT_MENU, OnViewRMC, id=G2G.wxID_VIEWRMC)
    1030110399        except:
    1030210400            pass
  • trunk/GSASIIpwd.py

    r4199 r4200  
    20952095        prms = ['Bank',
    20962096                'difC','difA','Zero','2-theta',
    2097                 'alpha','beta-0','beta-1','sig-0',
    2098                 'sig-1','sig-2','X','Y']
     2097                'alpha','beta-0','beta-1',
     2098                'sig-0','sig-1','sig-2',
     2099                'Z','X','Y']
    20992100        fname = Name+'.inst'
    21002101        fl = open(fname,'w')
     
    21022103        fl.write('%d\n'%int(inst[prms[0]][1]))
    21032104        fl.write('%10.3f%10.3f%10.3f%10.3f\n'%(inst[prms[1]][1],inst[prms[2]][1],inst[prms[3]][1],inst[prms[4]][1]))
    2104         fl.write('%10.3f%10.6f%10.6f%10.3f\n'%(inst[prms[5]][1],inst[prms[6]][1],inst[prms[7]][1],inst[prms[8]][1]))
    2105         fl.write('%10.3f%10.3f%10.3f%10.4f\n'%(inst[prms[9]][1],inst[prms[10]][1],0.0,inst[prms[12]][1]))   
    2106         fl.write('%10.4f%10.3f%10.3f%10.3f\n'%(inst[prms[11]][1],0.0,0.0,0.0))
    2107         fl.write('%10.4f%10.3f%10.3f%10.3f\n'%(0.0,0.0,0.0,0.0))
     2105        fl.write('%10.3f%10.6f%10.6f\n'%(inst[prms[5]][1],inst[prms[6]][1],inst[prms[7]][1]))
     2106        fl.write('%10.3f%10.3f%10.3f\n'%(inst[prms[8]][1],inst[prms[9]][1],inst[prms[10]][1]))   
     2107        fl.write('%10.4f%10.3f%10.3f%10.3f%10.3f\n'%(inst[prms[11]][1],inst[prms[12]][1],inst[prms[13]][1],0.0,0.0))
    21082108        fl.close()
    21092109    else:
    21102110        prms = ['Bank',
    2111                 'Lam','Zero',
     2111                'Lam','Zero','Polariz.',
    21122112                'U','V','W',
    2113                 'X','Y',]
     2113                'X','Y']
    21142114        fname = Name+'.inst'
    21152115        fl = open(fname,'w')
    21162116        fl.write('1\n')
    21172117        fl.write('%d\n'%int(inst[prms[0]][1]))
    2118         fl.write('%10.3f%10.3f%10.3f%10.3f\n'%(inst[prms[1]][1],inst[prms[2]][1],0.0,0.0))
    2119         fl.write('%10.3f%10.6f%10.6f%10.3f\n'%(inst[prms[3]][1],inst[prms[4]][1],inst[prms[5]][1],0.0))
    2120         fl.write('%10.3f%10.3f%10.3f%10.3f\n'%(inst[prms[6]][1],inst[prms[7]][1],0.0,0.0))   
    2121         fl.write('%10.3f%10.3f%10.3f%10.3f\n'%(0.0,0.0,0.0,0.0))
     2118        fl.write('%10.5f%10.5f%10.4f%10d\n'%(inst[prms[1]][1],inst[prms[2]][1]/100.,inst[prms[3]][1],0))
     2119        fl.write('%10.3f%10.3f%10.3f\n'%(inst[prms[4]][1],inst[prms[5]][1],inst[prms[6]][1]))
     2120        fl.write('%10.3f%10.3f%10.3f\n'%(inst[prms[7]][1],inst[prms[8]][1],0.0))   
     2121        fl.write('%10.3f%10.3f%10.3f\n'%(0.0,0.0,0.0))
    21222122        fl.close()
    21232123    return fname
     
    21262126    PWDdata = G2frame.GetPWDRdatafromTree(PWId)
    21272127    Back = PWDdata['Background'][0]
     2128    inst = PWDdata['Instrument Parameters'][0]
    21282129    if 'chebyschev' not in Back[0]:
    21292130        return None
     
    21342135    fl.write('%10d\n'%Nback)
    21352136    for val in BackVals:
    2136         fl.write('%12.6g\n'%val)
     2137        if 'T' in inst['Type'][1]:
     2138            fl.write('%12.6g\n'%(float(val)))
     2139        else:
     2140            fl.write('%12.6g\n'%val)
    21372141    fl.close()
    21382142    return fname
Note: See TracChangeset for help on using the changeset viewer.