Changeset 5071


Ignore:
Timestamp:
Nov 9, 2021 4:11:31 PM (2 years ago)
Author:
vondreele
Message:

Add 'Temp' to PDF controls - needed for future se. PDFfit
fix bugs in export of PDF files F(Q) & G(R)
finish setup for seq. PDFfit & add the PDFfit atom constraints table

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIdataGUI.py

    r5070 r5071  
    27042704            self.GPXtree.SetItemPyData(self.GPXtree.AppendItem(Id,text='PDF Controls'),
    27052705                {'G(R)':[valuesdict,rd.pdfdata,HistName],'diffGRname':'','diffMult':1.0,'Rmax':Ymax,'Type':rd.Type,
    2706                  'dscale':[1.0,False],'Fitrange':[Rmin,Rmax],'qdamp':[0.03,False],'qbroad':[0,False]})
     2706                 'dscale':[1.0,False],'Fitrange':[Rmin,Rmax],'qdamp':[0.03,False],'qbroad':[0,False],'Temp':300.})
    27072707            self.GPXtree.SetItemPyData(self.GPXtree.AppendItem(Id,text='PDF Peaks'),
    27082708                {'Limits':[1.,5.],'Background':[2,[0.,-0.2*np.pi],False],'Peaks':[]})
  • trunk/GSASIIfiles.py

    r5008 r5071  
    10281028        qnew = np.arange(fqdata[0][0],fqdata[0][-1],0.005)
    10291029        nq = qnew.shape[0]
    1030         fqfile.write('%20d\n'%nq-1)
     1030        fqfile.write('%20d\n'%(nq-1))
    10311031        fqfile.write(fqfilename+'\n')
    10321032        fqnew = zip(qnew,fqfxn(qnew))
    1033         for q,fq in fqnew[1:]:
     1033        for q,fq in fqnew:
     1034            if not q:
     1035                continue
    10341036            fqfile.write("%15.6g %15.6g\n" % (q,fq))
    10351037        fqfile.close()
     
    10421044        rnew = np.arange(grdata[0][0],grdata[0][-1],0.010)
    10431045        nr = rnew.shape[0]
    1044         grfile.write('%20d\n'%nr-1)
     1046        grfile.write('%20d\n'%(nr-1))
    10451047        grfile.write(grfilename+'\n')
    10461048        grnew = zip(rnew,grfxn(rnew))
    1047         for r,gr in grnew[1:]:
     1049        for r,gr in grnew:
     1050            if not r:
     1051                continue
    10481052            grfile.write("%15.6g %15.6g\n" % (r,gr))
    10491053        grfile.close()
  • trunk/GSASIIobj.py

    r5067 r5071  
    33933393        'DetType':'Area detector','ObliqCoeff':0.3,'Ruland':0.025,'QScaleLim':Qlimits,
    33943394        'Lorch':False,'BackRatio':0.0,'Rmax':100.,'noRing':False,'IofQmin':1.0,'Rmin':1.0,
    3395         'I(Q)':[],'S(Q)':[],'F(Q)':[],'G(R)':[]}
     3395        'I(Q)':[],'S(Q)':[],'F(Q)':[],'G(R)':[],
     3396        #items for sequential PDFfit
     3397        'Datarange':[0.,30.],'Fitrange':[0.,30.],'qdamp':[0.03,False],'qbroad':[0,False],'Temp':300}
    33963398    G2frame.GPXtree.SetItemPyData(G2frame.GPXtree.AppendItem(Id,text='PDF Controls'),Data)
    33973399    G2frame.GPXtree.SetItemPyData(G2frame.GPXtree.AppendItem(Id,text='PDF Peaks'),
  • trunk/GSASIIphsGUI.py

    r5070 r5071  
    49234923                wx.CallAfter(UpdateRMC)
    49244924
    4925             def OnAddPDF(event):
    4926                 usedList = RMCPdict['seqfiles']
    4927                 PDFdict = dict([item[1:] for item in G2frame.GetFileList('PDF')])
    4928                 PDFnames = [item for item in PDFdict if item not in usedList]
    4929                 dlg = G2G.G2MultiChoiceDialog(G2frame.FRMC,'PDF dataset',
    4930                     'Select G(r) data to use in seq. PDFfit',PDFnames)
    4931 #                    style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER|wx.OK|wx.CENTRE)
    4932                 if dlg.ShowModal() == wx.ID_OK:
    4933                     PDFuse = dlg.GetSelections()
    4934                     for item in PDFuse:
    4935                         pId = G2gd.GetGPXtreeItemId(G2frame,G2frame.root,PDFnames[item])
    4936                         data = G2frame.GPXtree.GetItemPyData(G2gd.GetGPXtreeItemId(G2frame,pId,'PDF Controls'))
    4937                         RMCPdict['seqfiles'].append([PDFnames[item],data])
    4938                 dlg.Destroy()
    4939                 wx.CallAfter(UpdateRMC)
    4940                
    49414925            Indx = {}
    49424926            topSizer = wx.BoxSizer(wx.HORIZONTAL)
     
    50215005            elif G2frame.RMCchoice == 'PDFfit' and RMCPdict['refinement'] == 'sequential':
    50225006               
     5007                def OnAddPDF(event):
     5008                    ''' Add PDF G(r)s while maintanining original sequence
     5009                    '''
     5010                    usedList = RMCPdict['seqfiles']
     5011                    PDFlist = [item[1:][0] for item in G2frame.GetFileList('PDF')]
     5012                    PDFdict = dict([item[1:] for item in G2frame.GetFileList('PDF')])
     5013                    PDFnames = [item for item in PDFdict if item not in [itm[0] for itm in usedList]]
     5014                    dlg = G2G.G2MultiChoiceDialog(G2frame.FRMC,'Add PDF dataset',
     5015                        'Select G(r) data to use in seq. PDFfit',PDFnames)
     5016                    if dlg.ShowModal() == wx.ID_OK:
     5017                        PDFuse = dlg.GetSelections()
     5018                        for item in PDFuse:
     5019                            pId = G2gd.GetGPXtreeItemId(G2frame,G2frame.root,PDFnames[item])
     5020                            data = G2frame.GPXtree.GetItemPyData(G2gd.GetGPXtreeItemId(G2frame,pId,'PDF Controls'))
     5021                            try:
     5022                                insrt = PDFlist.index(PDFnames[item])-1
     5023                                RMCPdict['seqfiles'].insert(insrt+1,[PDFnames[item],data])
     5024                            except ValueError:
     5025                                RMCPdict['seqfiles'].append([PDFnames[item],data])
     5026                    dlg.Destroy()
     5027                    wx.CallAfter(UpdateRMC)
     5028                   
     5029                def OnDelPDF(event):
     5030                    usedList = [item[0] for item in RMCPdict['seqfiles']]
     5031                    dlg = G2G.G2MultiChoiceDialog(G2frame.FRMC,'Delete PDF dataset',
     5032                        'Select G(r) data to delete frpm seq. PDFfit',usedList)
     5033                    if dlg.ShowModal() == wx.ID_OK:
     5034                        PDFdel = dlg.GetSelections()
     5035                        PDFdel.reverse()
     5036                        for item in PDFdel:
     5037                            del RMCPdict['seqfiles'][item]
     5038                    dlg.Destroy()
     5039                    wx.CallAfter(UpdateRMC)
     5040               
    50235041                def OnSetColVal(event):
    50245042                   
    5025                     parms = {'Rmin':[0.0,5.0],'Rmax':[5.,30.],'dscale':[0.5,2.0],'qdamp':[0.0,0.5],'qbroad':[0.0,0.1]}
     5043                    parms = {'Rmin':[0.0,5.0],'Rmax':[5.,30.],'dscale':[0.5,2.0],
     5044                        'qdamp':[0.0,0.5],'qbroad':[0.0,0.1],'Temp':300}
    50265045                    c =  event.GetCol()
    50275046                    if c >= 0:
     
    50415060                                else:
    50425061                                    for row in range(seqGrid.GetNumberRows()): RMCPdict['seqfiles'][row][1][varib][1]=False
    5043                         elif c in [0,1,2,4,6]:
     5062                        elif c in [0,1,2,4,6,8]:
    50445063                            seqGrid.ClearSelection()
    50455064                            seqGrid.SelectCol(c,True)
     
    50505069                                if c in [2,4,6]:
    50515070                                    for row in range(seqGrid.GetNumberRows()): RMCPdict['seqfiles'][row][1][parm][0] = value
     5071                                elif c == 8:
     5072                                    for row in range(seqGrid.GetNumberRows()): RMCPdict['seqfiles'][row][1][parm] = value
    50525073                                else:
    50535074                                    for row in range(seqGrid.GetNumberRows()): RMCPdict['seqfiles'][row][1]['Fitrange'][c] = value
    50545075                        wx.CallAfter(UpdateRMC)
     5076                       
     5077                def OnSetVal(event):
     5078                    r,c= event.GetRow(),event.GetCol()
     5079                    if c >= 0:
     5080                        if c in [3,5,7]:
     5081                            varib = colLabels[c-1]
     5082                            RMCPdict['seqfiles'][r][1][varib][1] = bool(seqGrid.GetCellValue(r,c))
     5083                        elif c in [0,1,2,4,6,8]:
     5084                            parm = colLabels[c]
     5085                            if c in [2,4,6]:
     5086                                RMCPdict['seqfiles'][r][1][parm][0] = float(seqGrid.GetCellValue(r,c))
     5087                            elif c == 8:
     5088                                RMCPdict['seqfiles'][r][1][parm] = float(seqGrid.GetCellValue(r,c))
     5089                            else:
     5090                                RMCPdict['seqfiles'][r][1]['Fitrange'][c] = float(seqGrid.GetCellValue(r,c))
    50555091                               
    50565092                if 'seqfiles' not in RMCPdict:
     
    50615097                addPDF.Bind(wx.EVT_BUTTON,OnAddPDF)
    50625098                topSizer.Add(addPDF,0,WACV)
     5099                delPDF = wx.Button(G2frame.FRMC,label='Delete PDF G(r) data sets')
     5100                delPDF.Bind(wx.EVT_BUTTON,OnDelPDF)
     5101                topSizer.Add(delPDF,0,WACV)
    50635102                mainSizer.Add(topSizer)
    50645103                table = [[item[1]['Fitrange'][0],item[1]['Fitrange'][1],
    50655104                    item[1]['dscale'][0],item[1]['dscale'][1],item[1]['qdamp'][0],item[1]['qdamp'][1],
    5066                     item[1]['qbroad'][0],item[1]['qbroad'][1],] for item in RMCPdict['seqfiles']]
    5067                 colLabels = ['Rmin','Rmax','dscale','refine','qdamp','refine','qbroad','refine']
     5105                    item[1]['qbroad'][0],item[1]['qbroad'][1],item[1].get('Temp',300.)] for item in RMCPdict['seqfiles']]
     5106                colLabels = ['Rmin','Rmax','dscale','refine','qdamp','refine','qbroad','refine','Temp']
    50685107                rowLabels = [item[0] for item in RMCPdict['seqfiles']]
    50695108                Types = [wg.GRID_VALUE_FLOAT+':10,2',wg.GRID_VALUE_FLOAT+':10,2',
    50705109                         wg.GRID_VALUE_FLOAT+':10,4',wg.GRID_VALUE_BOOL,
    50715110                         wg.GRID_VALUE_FLOAT+':10,4',wg.GRID_VALUE_BOOL,
    5072                          wg.GRID_VALUE_FLOAT+':10,4',wg.GRID_VALUE_BOOL,]
     5111                         wg.GRID_VALUE_FLOAT+':10,4',wg.GRID_VALUE_BOOL,wg.GRID_VALUE_FLOAT+':10,2']
    50735112                seqTable = G2G.Table(table,rowLabels=rowLabels,colLabels=colLabels,types=Types)
    50745113                seqGrid = G2G.GSGrid(G2frame.FRMC)
     
    50765115                seqGrid.AutoSizeColumns(True)
    50775116                seqGrid.Bind(wg.EVT_GRID_LABEL_LEFT_DCLICK, OnSetColVal)
     5117                seqGrid.Bind(wg.EVT_GRID_CELL_CHANGED, OnSetVal)
    50785118                mainSizer.Add(seqGrid)
    50795119               
     
    59766016               
    59776017            def AtomSizer():
    5978                 return None
     6018               
     6019                def OnSetVal(event):
     6020                    r,c = event.GetRow(),event.GetCol()
     6021                    if c > 0:
     6022                        strval = atmGrid.GetCellValue(r,c).strip()
     6023                        if strval == '' or '@' in strval:
     6024                            RMCPdict['AtomConstr'][r][c+1] = strval
     6025                        else:
     6026                            print('ERROR - atom constraints must be blank or contain "@"')                   
     6027               
     6028                atmSizer = wx.BoxSizer(wx.VERTICAL)
     6029                atmSizer.Add(wx.StaticText(G2frame.FRMC,label=' Atom Constraints; enter as e.g. "@n" or "0.5-@n"; n>=10'))
     6030
     6031                table = [item[1:] for item in RMCPdict['AtomConstr']]
     6032                colLabels = ['Type','x constraint','y constraint','z  constraint','frac constr','Uiso constr']
     6033                rowLabels = [item[0] for item in RMCPdict['AtomConstr']]
     6034                Types = 6*[wg.GRID_VALUE_STRING,]
     6035                atmTable = G2G.Table(table,rowLabels=rowLabels,colLabels=colLabels,types=Types)
     6036                atmGrid = G2G.GSGrid(G2frame.FRMC)
     6037                atmGrid.SetTable(atmTable, True,useFracEdit=False)
     6038                atmGrid.AutoSizeColumns(True)
     6039                atmGrid.Bind(wg.EVT_GRID_CELL_CHANGED, OnSetVal)
     6040                atmSizer.Add(atmGrid)
     6041                return atmSizer
    59796042               
    59806043
     
    59986061                data['RMC']['PDFfit'] = {'files':files,'ReStart':[False,False],'metadata':metadata,
    59996062                'delta1':[0.,False],'delta2':[0.,False],'spdiameter':[0.,False],'refinement':'normal',
    6000                 'sratio':[1.,False],'rcut':0.0,'stepcut':0.0,'shape':'sphere','SGData':SGData,'cellref':False,       
     6063                'sratio':[1.,False],'rcut':0.0,'stepcut':0.0,'shape':'sphere','SGData':SGData,'cellref':False,
     6064                'AtomConstr':[],
    60016065                'Xdata':{'dscale':[1.0,False],'Datarange':[0.,30.],'Fitrange':[0.,30.],'qdamp':[0.03,False],'qbroad':[0,False]},
    60026066                'Ndata':{'dscale':[1.0,False],'Datarange':[0.,30.],'Fitrange':[0.,30.],'qdamp':[0.03,False],'qbroad':[0,False]},}
     
    60106074            if 'cellref' not in RMCPdict:
    60116075                RMCPdict['cellref'] = False
     6076            if 'AtomConstr' not in RMCPdict:
     6077                RMCPdict['AtomConstr'] = []
    60126078            if 'metadata' not in RMCPdict:
    60136079                RMCPdict['metadata'] = {'title':'none','date':str(time.ctime()),'temperature':'300K','doping':0}
    60146080#end patch
     6081            Atoms = data['Atoms']
     6082            cx,ct,cs,ci = G2mth.getAtomPtrs(data)     
     6083            if not RMCPdict['AtomConstr']:
     6084                for atom in Atoms:
     6085                    RMCPdict['AtomConstr'].append([atom[ct-1],atom[ct],'','','','',''])
     6086               
    60156087            mainSizer.Add(wx.StaticText(G2frame.FRMC,label=' Enter metadata items:'),0)
    60166088            mainSizer.Add(GetMetaSizer(RMCPdict,['title','date','temperature','doping']),0)
     
    60336105            mainSizer.Add(cellref,0,WACV)
    60346106                       
     6107            G2G.HorizontalLine(mainSizer,G2frame.FRMC)
    60356108            mainSizer.Add(wx.StaticText(G2frame.FRMC,label='PDFfit atom parameters:'),0,WACV)
    6036 #            mainSizer.Add(AtomSizer())
    6037            
     6109            mainSizer.Add(AtomSizer())
     6110           
     6111            G2G.HorizontalLine(mainSizer,G2frame.FRMC)
    60386112            mainSizer.Add(wx.StaticText(G2frame.FRMC,label=' PDFfit phase profile coefficients:'),0,WACV)
    60396113            mainSizer.Add(PDFParmSizer(),0)
Note: See TracChangeset for help on using the changeset viewer.