Changeset 5106
- Timestamp:
- Dec 3, 2021 1:07:59 PM (7 months ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIdataGUI.py
r5095 r5106 6141 6141 self.PostfillDataMenu() 6142 6142 6143 # P DR / Background6143 # PWDR / Background 6144 6144 G2G.Define_wxId('wxID_BACKCOPY', 'wxID_BACKFLAGCOPY','wxID_MAKEBACKRDF', 6145 6145 'wxID_RESCALEALL','wxID_BACKPEAKSMOVE','wxID_BACKSAVE','wxID_BACKLOAD') … … 6172 6172 self.PostfillDataMenu() 6173 6173 6174 # P DR / Instrument Parameters6174 # PWDR / Instrument Parameters 6175 6175 G2G.Define_wxId('wxID_INSTPRMRESET','wxID_INSTCOPY','wxID_INSTFLAGCOPY','wxID_INSTLOAD', 6176 6176 'wxID_INSTSAVE', 'wxID_INST1VAL', 'wxID_INSTCALIB', 'wxID_INSTSAVEALL',) … … 6189 6189 self.PostfillDataMenu() 6190 6190 6191 # P DR / Sample Parameters6191 # PWDR / Sample Parameters 6192 6192 G2G.Define_wxId('wxID_SAMPLECOPY', 'wxID_SAMPLECOPYSOME', 'wxID_SAMPLEFLAGCOPY','wxID_SAMPLESAVE', 6193 6193 'wxID_SAMPLELOAD', 'wxID_SETSCALE', 'wxID_SAMPLE1VAL', 'wxID_ALLSAMPLELOAD',) … … 6208 6208 self.SetScale.Enable(False) 6209 6209 6210 # P DR / Peak List6210 # PWDR / Peak List 6211 6211 G2G.Define_wxId('wxID_UNDO', 'wxID_LSQPEAKFIT', 'wxID_LSQONECYCLE', 'wxID_RESETSIGGAM', 6212 6212 'wxID_CLEARPEAKS', 'wxID_AUTOSEARCH','wxID_PEAKSCOPY', 'wxID_SEQPEAKFIT','wxID_PEAKLOAD','wxID_PEAKSAVE') … … 6236 6236 self.AutoSearch.Enable(True) 6237 6237 6238 # P DR / Index Peak List6238 # PWDR / Index Peak List 6239 6239 G2G.Define_wxId('wxID_INDXRELOAD','wxID_INDEXSAVE',) 6240 6240 self.IndPeaksMenu = wx.MenuBar() … … 6246 6246 self.PostfillDataMenu() 6247 6247 6248 # P DR / Unit Cells List6248 # PWDR / Unit Cells List 6249 6249 G2G.Define_wxId('wxID_INDEXPEAKS', 'wxID_REFINECELL', 'wxID_COPYCELL', 'wxID_MAKENEWPHASE', 6250 6250 'wxID_EXPORTCELLS','wxID_LOADCELL','wxID_IMPORTCELL','wxID_TRANSFORMCELL','wxID_RUNSUB','wxID_RUNSUBMAG','wxID_LATSYM') … … 6283 6283 self.MakeNewPhase.Enable(False) 6284 6284 6285 # P DR / Reflection Lists6285 # PWDR / Reflection Lists 6286 6286 G2G.Define_wxId('wxID_SELECTPHASE','wxID_SHOWHIDEEXTINCT','wxID_WILSONSTAT' ) #some wxIDs defined above in PWDR & SASD 6287 6287 self.ReflMenu = wx.MenuBar() -
trunk/GSASIIphsGUI.py
r5097 r5106 4891 4891 except ValueError: 4892 4892 start += 1 4893 if start > 500: #absurd number of header lines! 4894 wx.MessageBox('WARNING: %s has bad data at end;\n RMCProfile may fail to read it'%fileItem[0], 4895 style=wx.ICON_ERROR) 4896 break 4893 4897 Xlab = 'Q' 4894 4898 if 'G(R)' in fileItem[2].upper(): … … 4921 4925 def OnDataSel(event): 4922 4926 RMCPdict['SeqDataType'] = dataType.GetStringSelection() 4927 4928 def OnSeqCopy(event): 4929 RMCPdict['SeqCopy'] = not RMCPdict['SeqCopy'] 4930 4931 def OnSeqReverse(event): 4932 RMCPdict['SeqReverse'] = not RMCPdict['SeqReverse'] 4923 4933 4924 4934 Indx = {} … … 4935 4945 dataType.Bind(wx.EVT_RADIOBOX,OnDataSel) 4936 4946 topSizer.Add(dataType) 4947 endSizer = wx.BoxSizer(wx.VERTICAL) 4948 seqcopy = wx.CheckBox(G2frame.FRMC,label=' Copy to next') 4949 seqcopy.SetValue(RMCPdict['SeqCopy']) 4950 seqcopy.Bind(wx.EVT_CHECKBOX,OnSeqCopy) 4951 endSizer.Add(seqcopy) 4952 seqreverse = wx.CheckBox(G2frame.FRMC,label=' Reverse processing') 4953 seqreverse.SetValue(RMCPdict['SeqReverse']) 4954 seqreverse.Bind(wx.EVT_CHECKBOX,OnSeqReverse) 4955 endSizer.Add(seqreverse) 4956 topSizer.Add(endSizer,0,WACV) 4957 4937 4958 mainSizer.Add(topSizer) 4938 4959 if G2frame.RMCchoice == 'fullrmc': … … 6027 6048 strval = atmGrid.GetCellValue(r,c).strip() 6028 6049 try: 6029 if strval == '' or ('@' in strval and int(strval.split('@')[-1]) >= 10):6050 if strval == '' or ('@' in strval and int(strval.split('@')[-1]) >= 20): 6030 6051 RMCPdict['AtomConstr'][r][c+1] = strval 6031 6052 else: … … 6033 6054 except ValueError: 6034 6055 atmGrid.SetCellValue(r,c,RMCPdict['AtomConstr'][r][c+1]) 6035 wx.MessageBox('ERROR - atom constraints must be blank or have "@n" at end with n >= 10',6056 wx.MessageBox('ERROR - atom constraints must be blank or have "@n" at end with n >= 20', 6036 6057 style=wx.ICON_ERROR) 6037 6058 6038 6059 atmSizer = wx.BoxSizer(wx.VERTICAL) 6039 atmSizer.Add(wx.StaticText(G2frame.FRMC,label=' Atom Constraints; enter as e.g. "@n" or "0.5-@n"; n>= 10 && "@n" should be at end'))6060 atmSizer.Add(wx.StaticText(G2frame.FRMC,label=' Atom Constraints; enter as e.g. "@n" or "0.5-@n"; n>=20 && "@n" should be at end')) 6040 6061 6041 6062 table = [item[1:] for item in RMCPdict['AtomConstr']] … … 6079 6100 'delta1':[0.,False],'delta2':[0.,False],'spdiameter':[0.,False],'refinement':'normal', 6080 6101 'sratio':[1.,False],'rcut':0.0,'stepcut':0.0,'shape':'sphere','SGData':SGData,'cellref':False, 6081 'AtomConstr':[],'AtomVar':{},'SeqDataType':'X', 6102 'AtomConstr':[],'AtomVar':{},'SeqDataType':'X','SeqCopy':True,'SeqReverse':False, 6082 6103 'Xdata':{'dscale':[1.0,False],'Datarange':[0.,30.],'Fitrange':[0.,30.],'qdamp':[0.03,False],'qbroad':[0,False]}, 6083 6104 'Ndata':{'dscale':[1.0,False],'Datarange':[0.,30.],'Fitrange':[0.,30.],'qdamp':[0.03,False],'qbroad':[0,False]},} … … 6097 6118 if 'SeqDataType' not in RMCPdict: 6098 6119 RMCPdict['SeqDataType'] = 'X' 6120 if 'SeqCopy' not in RMCPdict: 6121 RMCPdict['SeqCopy'] = False 6122 RMCPdict['SeqReverse'] = False 6099 6123 if 'AtomVar' not in RMCPdict: 6100 6124 RMCPdict['AtomVar'] = {} … … 6256 6280 print('PDFfit file build completed') 6257 6281 6258 6259 def OnRunRMC(event): 6260 '''Run a previously created RMCProfile/fullrmc/PDFfit2 script 6261 ''' 6282 def RunPDFfit(event): 6262 6283 generalData = data['General'] 6263 if G2frame.RMCchoice == 'fullrmc': 6264 fullrmc_exec = G2pwd.findfullrmc() 6265 if fullrmc_exec is None: 6266 G2G.G2MessageBox(G2frame,'fullrmc Python not found. How did we get here?') 6267 return 6268 pName = G2frame.GSASprojectfile.split('.')[0] + '-' + generalData['Name'] 6269 pName = pName.replace(' ','_') 6270 rname = pName+'-fullrmc.py' 6271 if not os.path.exists(rname): 6272 G2G.G2MessageBox(G2frame,'The fullrmc script has not been created. Running setup.', 6273 'Not setup') 6274 OnSetupRMC(event) 6275 RMCPdict = data['RMC']['fullrmc'] 6276 rmcname = pName+'-fullrmc.rmc' 6277 if os.path.isdir(rmcname) and RMCPdict['ReStart'][0]: 6278 msg = '''You have asked to start a new fullrmc run rather than 6279 continue the existing {} run. 6280 %%Press "Yes" to continue, deleting this 6281 previous run or "No" to change the restart checkbox to 6282 continue from the previous results.'''.format(rmcname) 6283 6284 dlg = wx.MessageDialog(G2frame,G2G.StripIndents(msg,True), 6285 'Restart or continue', 6286 wx.YES|wx.NO) 6287 try: 6288 dlg.CenterOnParent() 6289 result = dlg.ShowModal() 6290 finally: 6291 dlg.Destroy() 6292 if result == wx.ID_YES: 6293 import shutil 6294 shutil.rmtree(rmcname) 6295 else: 6296 return 6297 G2G.G2MessageBox(G2frame, 6298 '''For use of fullrmc, please cite: 6299 "Fullrmc, a Rigid Body Reverse Monte Carlo 6300 Modeling Package Enabled with Machine Learning 6301 and Artificial Intelligence", 6302 B. Aoun, Jour. Comp. Chem. 2016, 37, 1102-1111. 6303 DOI: https://doi.org/10.1002/jcc.24304 6304 ''', 6305 'Please cite fullrmc') 6306 ilog = 0 6307 while True: 6308 logname = '%s_%d.log'%(pName,ilog) 6309 if os.path.isfile(logname): 6310 if GSASIIpath.GetConfigValue('debug'): 6311 print('removing',logname) 6312 os.remove(logname) 6313 else: 6314 break 6315 ilog += 1 6316 if sys.platform.lower().startswith('win'): 6317 batch = open('fullrmc.bat','w') 6318 #batch.write('CALL '+sys.exec_prefix+'\\Scripts\\activate\n') 6319 batch.write(fullrmc_exec+' '+rname+'\n') 6320 batch.write('pause') 6321 batch.close() 6322 subp.Popen('fullrmc.bat',creationflags=subp.CREATE_NEW_CONSOLE) 6323 else: 6324 batch = open('fullrmc.sh','w') 6325 batch.write('#!/bin/bash\n') 6326 #activate = os.path.split(os.environ.get('CONDA_EXE',''))[0] +'/activate' 6327 batch.write('cd ' + os.path.split(os.path.abspath(rname))[0] + '\n') 6328 #if os.path.exists(activate): 6329 # batch.write('source ' + activate + ' ' + 6330 # os.environ['CONDA_DEFAULT_ENV'] +'\n') 6331 # batch.write('python ' + rname + '\n') 6332 #else: 6333 # batch.write(sys.exec_prefix+'/python ' + rname + '\n') 6334 batch.write(fullrmc_exec + ' ' + os.path.abspath(rname) + '\n') 6335 batch.close() 6336 if sys.platform == "darwin": 6337 GSASIIpath.MacRunScript(os.path.abspath('fullrmc.sh')) 6338 else: 6339 # TODO: better to create this in a new terminal on Linux 6340 subp.Popen(['/bin/bash','fullrmc.sh']) 6341 6342 elif G2frame.RMCchoice == 'RMCProfile': 6343 pName = generalData['Name'].replace(' ','_') 6344 RMCPdict = data['RMC']['RMCProfile'] 6345 rmcfile = G2fl.find('rmcprofile.exe',GSASIIpath.path2GSAS2) 6346 if rmcfile is None: 6347 wx.MessageBox(''' RMCProfile is not correctly installed for use in GSAS-II 6348 Obtain the zip file distribution from www.rmcprofile.org, 6349 unzip it and place the RMCProfile main directory in the main GSAS-II directory ''', 6350 caption='RMCProfile',style=wx.ICON_INFORMATION) 6351 return 6352 rmcexe = os.path.split(rmcfile)[0] 6353 print(rmcexe) 6354 wx.MessageBox(''' For use of RMCProfile, please cite: 6355 RMCProfile: Reverse Monte Carlo for polycrystalline materials, 6356 M.G. Tucker, D.A. Keen, M.T. Dove, A.L. Goodwin and Q. Hui, 6357 Jour. Phys.: Cond. Matter 2007, 19, 335218. 6358 doi: https://doi.org/10.1088/0953-8984/19/33/335218''', 6359 caption='RMCProfile',style=wx.ICON_INFORMATION) 6360 if os.path.isfile(pName+'.his6f'): 6361 os.remove(pName+'.his6f') 6362 if os.path.isfile(pName+'.xray'): 6363 os.remove(pName+'.xray') 6364 if os.path.isfile(pName+'.neigh'): 6365 os.remove(pName+'.neigh') 6366 if os.path.isfile(pName+'.bonds'): 6367 os.remove(pName+'.bonds') 6368 if os.path.isfile(pName+'.triplets'): 6369 os.remove(pName+'.triplets') 6370 i = 1 6371 while True: 6372 if os.path.isfile(pName+'.bondodf_%d'%i): 6373 os.remove(pName+'.bondodf_%d'%i) 6374 os.remove(pName+'_bondplot_%d.ppm'%i) 6375 i += 1 6376 else: 6377 break 6378 i = 1 6379 while True: 6380 if os.path.isfile(pName+'_anglehist_%d.csv'%i): 6381 os.remove(pName+'_anglehist_%d.csv'%i) 6382 i += 1 6383 else: 6384 break 6385 6386 G2frame.OnFileSave(event) 6387 print (' GSAS-II project saved') 6388 generalData = data['General'] 6389 pName = generalData['Name'].replace(' ','_') 6390 exstr = rmcexe+'\\rmcprofile.exe '+pName 6391 batch = open('runrmc.bat','w') 6392 batch.write('Title RMCProfile\n') 6393 batch.write(exstr+'\n') 6394 batch.write('pause\n') 6395 batch.close() 6396 subp.Popen('runrmc.bat',creationflags=subp.CREATE_NEW_CONSOLE) 6397 6398 elif G2frame.RMCchoice == 'PDFfit': 6399 PDFfit_exec = G2pwd.findPDFfit() #returns location of python (not pdffit!) 6400 if not PDFfit_exec: 6401 wx.MessageBox(''' PDFfit2 is currently not available for this platform. 6284 PDFfit_exec = G2pwd.findPDFfit() #returns location of python (not pdffit!) 6285 if not PDFfit_exec: 6286 wx.MessageBox(''' PDFfit2 is currently not available for this platform. 6402 6287 Please contact us for assistance''',caption='No PDFfit2',style=wx.ICON_INFORMATION) 6403 return 6404 pName = generalData['Name'].replace(' ','_') 6288 return 6289 RMCPdict = data['RMC']['PDFfit'] 6290 pName = generalData['Name'].replace(' ','_') 6291 if 'sequential' in RMCPdict['refinement']: 6292 rname = 'Seq_PDFfit.py' 6293 else: 6405 6294 rname = pName+'-PDFfit.py' 6406 6295 wx.MessageBox(''' For use of PDFfit2, please cite: 6407 6296 PDFfit2 and PDFgui: computer progerama for studying nanostructures in crystals, 6408 6297 C.L. Farrow, P.Juhas, J.W. Liu, D. Bryndin, E.S. Bozin, J. Bloch, Th. Proffen & … … 6410 6299 (2007), 19, 335218. doi: https://doi.org/10.1088/0953-8984/19/33/335219''', 6411 6300 caption='PDFfit2',style=wx.ICON_INFORMATION) 6412 G2frame.OnFileSave(event) 6413 print (' GSAS-II project saved') 6301 G2frame.OnFileSave(event) 6302 print (' GSAS-II project saved') 6303 if sys.platform.lower().startswith('win'): 6304 batch = open('pdffit2.bat','w') 6305 batch.write(PDFfit_exec+' '+rname+'\n') 6306 if 'normal' in RMCPdict['refinement']: 6307 batch.write('pause') 6308 batch.close() 6309 else: 6310 batch = open('pdffit2.sh','w') 6311 batch.write('#!/bin/bash\n') 6312 batch.write('cd ' + os.path.split(os.path.abspath(rname))[0] + '\n') 6313 batch.write(PDFfit_exec + ' ' + os.path.abspath(rname) + '\n') 6314 batch.close() 6315 if 'sequential' in RMCPdict['refinement']: 6316 Id = G2gd.GetGPXtreeItemId(G2frame,G2frame.root,'Sequential PDFfit2 results') 6317 if Id: 6318 SeqResult = G2frame.GPXtree.GetItemPyData(Id) 6319 else: 6320 SeqResult = {} 6321 Id = G2frame.GPXtree.AppendItem(parent=G2frame.root,text='Sequential PDFfit2 results') 6322 SeqResult = {'SeqPseudoVars':{},'SeqParFitEqList':[]} 6323 SeqResult['histNames'] = [] #this clears the previous seq. result! 6324 for itm in range(len(RMCPdict['seqfiles'])): 6325 SeqResult['histNames'].append([itm,RMCPdict['seqfiles'][itm][0]]) 6326 if RMCPdict['SeqReverse']: 6327 SeqResult['histNames'].reverse() 6328 nPDF = len(SeqResult['histNames']) 6329 pgbar = wx.ProgressDialog('Sequential PDFfit','PDF G(R) done = 0',nPDF+1, 6330 style = wx.PD_ELAPSED_TIME|wx.PD_AUTO_HIDE|wx.PD_CAN_ABORT) 6331 newParms = {} 6332 for itm,item in enumerate(SeqResult['histNames']): 6333 PDFfile = RMCPdict['seqfiles'][item[0]] 6334 pfdata = PDFfile[1]['G(R)'][1].T 6335 # pfname = PDFfile[0].replace(' ','_') 6336 pfname = 'Seq_PDF.gr' 6337 pfile = open(pfname,'w') 6338 for dp in pfdata: 6339 pfile.write('%12.5f%12.5f\n'%(dp[0],dp[1])) 6340 pfile.close() 6341 rfile = open('Seq_PDFfit_template.py','r') 6342 lines = rfile.readlines() #template lines 6343 rfile.close() 6344 newlines = [] 6345 parms = {} 6346 Np = 0 6347 for line in lines: 6348 if '#sequential' in line: 6349 newlines += "pf.read_data('%s', '%s', 30.0, %.4f)\n"%(pfname,PDFfile[1]['Type'][0],PDFfile[1]['qdamp'][0]) 6350 newlines += 'pf.setdata(1)\n' 6351 newlines += 'pf.pdfrange(1, %6.2f, %6.2f)\n'%(PDFfile[1]['Fitrange'][0],PDFfile[1]['Fitrange'][1]) 6352 for item in ['dscale','qdamp','qbroad']: 6353 if PDFfile[1][item][1]: 6354 Np += 1 6355 newlines += 'pf.constrain(pf.%s(),"@%d")\n'%(item,Np) 6356 parms[item] = '%d'%Np 6357 elif '#parameters' in line: 6358 startParms = RMCPdict['Parms'] 6359 if newParms and RMCPdict['SeqCopy']: 6360 startParms = newParms 6361 for iprm in startParms: 6362 newlines += 'pf.setpar(%s,%.6f)\n'%(iprm,startParms[iprm][0]) 6363 else: 6364 newlines += line 6365 rfile= open('Seq_PDFfit.py','w') 6366 rfile.writelines(newlines) 6367 rfile.close() 6368 6369 if sys.platform.lower().startswith('win'): 6370 Proc = subp.Popen('pdffit2.bat',creationflags=subp.CREATE_NEW_CONSOLE) 6371 Proc.wait() #for it to finish before continuing on 6372 else: 6373 if sys.platform == "darwin": 6374 GSASIIpath.MacRunScript(os.path.abspath('pdffit2.sh')) 6375 else: 6376 Proc = subp.Popen(['/bin/bash','pdffit2.sh']) 6377 Proc.wait() 6378 6379 newParms,Rwp = G2pwd.UpdatePDFfit(data,RMCPdict) 6380 for item in ['dscale','qdamp','qbroad']: 6381 if PDFfile[1][item][1]: 6382 PDFfile[1][item][0] = newParms[parms[item]][0] 6383 parmDict = copy.deepcopy(newParms) 6384 parmDict.update({'Temperature':PDFfile[1]['Temp']}) 6385 varyList = ['%s-%s'%(item,RMCPdict['Parms'][item][1]) for item in RMCPdict['Parms']] 6386 result = np.array(list(newParms.values())).T 6387 SeqResult[PDFfile[0]] = {'variables':result[0],'varyList':varyList,'sig':result[1],'Rvals':{'Rwp':Rwp,}, 6388 'covMatrix':[],'title':PDFfile[0],'parmDict':parmDict} 6389 6390 pfile = open('Sequential_PDFfit%s.fgr'%(PDFfile[1]['Type'][0])) # X or N 6391 XYcalc = np.loadtxt(pfile).T[:2] 6392 pfile.close() 6393 pId = G2gd.GetGPXtreeItemId(G2frame,G2frame.root,PDFfile[0]) 6394 PDFctrl = G2frame.GPXtree.GetItemPyData(G2gd.GetGPXtreeItemId(G2frame,pId,'PDF Controls')) 6395 XYobs = PDFctrl['G(R)'][1] 6396 XYobs = np.concatenate((XYobs,np.zeros_like(XYobs)),axis=0) 6397 ibeg = np.searchsorted( XYobs[0],XYcalc[0][0]) 6398 ifin = ibeg+XYcalc.shape[1] 6399 XYobs[2][ibeg:ifin] = XYcalc[1] 6400 XYobs[3] = XYobs[1]-XYobs[2] 6401 PDFctrl['G(R)'][1] = XYobs 6402 G2frame.GPXtree.SetItemPyData(G2gd.GetGPXtreeItemId(G2frame,pId,'PDF Controls'),PDFctrl) 6403 GoOn = pgbar.Update(itm,newmsg='PDF G(R) done = %d'%(itm)) 6404 if not GoOn[0]: 6405 print(' Sequential PDFfit aborted') 6406 break 6407 6408 pgbar.Destroy() 6409 G2frame.GPXtree.SetItemPyData(Id,SeqResult) 6410 G2frame.G2plotNB.Delete('Sequential refinement') #clear away probably invalid plot 6411 G2frame.GPXtree.SelectItem(Id) 6412 6413 else: 6414 6414 if sys.platform.lower().startswith('win'): 6415 batch = open('pdffit2.bat','w') 6416 batch.write(PDFfit_exec+' '+rname+'\n') 6417 batch.write('pause') 6418 batch.close() 6419 subp.Popen('pdffit2.bat',creationflags=subp.CREATE_NEW_CONSOLE) 6415 Proc = subp.Popen('pdffit2.bat',creationflags=subp.CREATE_NEW_CONSOLE) 6416 Proc.wait() #for it to finish before continuing on 6420 6417 else: 6421 batch = open('pdffit2.sh','w')6422 batch.write('#!/bin/bash\n')6423 batch.write('cd ' + os.path.split(os.path.abspath(rname))[0] + '\n')6424 batch.write(PDFfit_exec + ' ' + os.path.abspath(rname) + '\n')6425 batch.close()6426 6418 if sys.platform == "darwin": 6427 6419 GSASIIpath.MacRunScript(os.path.abspath('pdffit2.sh')) 6428 6420 else: 6429 subp.Popen(['/bin/bash','pdffit2.sh']) 6421 Proc = subp.Popen(['/bin/bash','pdffit2.sh']) 6422 Proc.wait() #for it to finish before continuing on 6430 6423 #update choice? here? 6431 6424 dlg = wx.MessageDialog(G2frame,'Check PDFfit console for results; do you want to update?', … … 6440 6433 Error = G2pwd.UpdatePDFfit(data,RMCPdict) 6441 6434 if Error: 6442 wx.MessageBox('PDFfit failed',caption='%s not found'%Error[0],style=wx.ICON_EXCLAMATION) 6443 wx.CallAfter(UpdateRMC) 6435 wx.MessageBox('PDFfit failed',caption='%s not found'%Error[0],style=wx.ICON_EXCLAMATION) 6436 UpdateRMC() 6437 6438 def Runfullrmc(event): 6439 fullrmc_exec = G2pwd.findfullrmc() 6440 if fullrmc_exec is None: 6441 G2G.G2MessageBox(G2frame,'fullrmc Python not found. How did we get here?') 6442 return 6443 generalData = data['General'] 6444 pName = G2frame.GSASprojectfile.split('.')[0] + '-' + generalData['Name'] 6445 pName = pName.replace(' ','_') 6446 rname = pName+'-fullrmc.py' 6447 if not os.path.exists(rname): 6448 G2G.G2MessageBox(G2frame,'The fullrmc script has not been created. Running setup.', 6449 'Not setup') 6450 OnSetupRMC(event) 6451 RMCPdict = data['RMC']['fullrmc'] 6452 rmcname = pName+'-fullrmc.rmc' 6453 if os.path.isdir(rmcname) and RMCPdict['ReStart'][0]: 6454 msg = '''You have asked to start a new fullrmc run rather than 6455 continue the existing {} run. 6456 %%Press "Yes" to continue, deleting this 6457 previous run or "No" to change the restart checkbox to 6458 continue from the previous results.'''.format(rmcname) 6459 6460 dlg = wx.MessageDialog(G2frame,G2G.StripIndents(msg,True), 6461 'Restart or continue',wx.YES|wx.NO) 6462 try: 6463 dlg.CenterOnParent() 6464 result = dlg.ShowModal() 6465 finally: 6466 dlg.Destroy() 6467 if result == wx.ID_YES: 6468 import shutil 6469 shutil.rmtree(rmcname) 6470 else: 6471 return 6472 G2G.G2MessageBox(G2frame, 6473 '''For use of fullrmc, please cite: 6474 "Fullrmc, a Rigid Body Reverse Monte Carlo 6475 Modeling Package Enabled with Machine Learning 6476 and Artificial Intelligence", 6477 B. Aoun, Jour. Comp. Chem. 2016, 37, 1102-1111. 6478 DOI: https://doi.org/10.1002/jcc.24304''','Please cite fullrmc') 6479 ilog = 0 6480 while True: 6481 logname = '%s_%d.log'%(pName,ilog) 6482 if os.path.isfile(logname): 6483 if GSASIIpath.GetConfigValue('debug'): 6484 print('removing',logname) 6485 os.remove(logname) 6486 else: 6487 break 6488 ilog += 1 6489 if sys.platform.lower().startswith('win'): 6490 batch = open('fullrmc.bat','w') 6491 #batch.write('CALL '+sys.exec_prefix+'\\Scripts\\activate\n') 6492 batch.write(fullrmc_exec+' '+rname+'\n') 6493 batch.write('pause') 6494 batch.close() 6495 Proc = subp.Popen('fullrmc.bat',creationflags=subp.CREATE_NEW_CONSOLE) 6496 Proc.wait() #for it to finish before continuing on 6497 else: 6498 batch = open('fullrmc.sh','w') 6499 batch.write('#!/bin/bash\n') 6500 #activate = os.path.split(os.environ.get('CONDA_EXE',''))[0] +'/activate' 6501 batch.write('cd ' + os.path.split(os.path.abspath(rname))[0] + '\n') 6502 #if os.path.exists(activate): 6503 # batch.write('source ' + activate + ' ' + 6504 # os.environ['CONDA_DEFAULT_ENV'] +'\n') 6505 # batch.write('python ' + rname + '\n') 6506 #else: 6507 # batch.write(sys.exec_prefix+'/python ' + rname + '\n') 6508 batch.write(fullrmc_exec + ' ' + os.path.abspath(rname) + '\n') 6509 batch.close() 6510 if sys.platform == "darwin": 6511 GSASIIpath.MacRunScript(os.path.abspath('fullrmc.sh')) 6512 else: 6513 # TODO: better to create this in a new terminal on Linux 6514 Proc = subp.Popen(['/bin/bash','fullrmc.sh']) 6515 Proc.wait() #for it to finish before continuing on 6516 UpdateRMC() 6517 6518 def RunRMCProfile(event): 6519 generalData = data['General'] 6520 pName = generalData['Name'].replace(' ','_') 6521 rmcfile = G2fl.find('rmcprofile.exe',GSASIIpath.path2GSAS2) 6522 if rmcfile is None: 6523 wx.MessageBox(''' RMCProfile is not correctly installed for use in GSAS-II 6524 Obtain the zip file distribution from www.rmcprofile.org, 6525 unzip it and place the RMCProfile main directory in the main GSAS-II directory ''', 6526 caption='RMCProfile',style=wx.ICON_INFORMATION) 6527 return 6528 rmcexe = os.path.split(rmcfile)[0] 6529 print(rmcexe) 6530 wx.MessageBox(''' For use of RMCProfile, please cite: 6531 RMCProfile: Reverse Monte Carlo for polycrystalline materials, 6532 M.G. Tucker, D.A. Keen, M.T. Dove, A.L. Goodwin and Q. Hui, 6533 Jour. Phys.: Cond. Matter 2007, 19, 335218. 6534 doi: https://doi.org/10.1088/0953-8984/19/33/335218''', 6535 caption='RMCProfile',style=wx.ICON_INFORMATION) 6536 if os.path.isfile(pName+'.his6f'): 6537 os.remove(pName+'.his6f') 6538 if os.path.isfile(pName+'.xray'): 6539 os.remove(pName+'.xray') 6540 if os.path.isfile(pName+'.neigh'): 6541 os.remove(pName+'.neigh') 6542 if os.path.isfile(pName+'.bonds'): 6543 os.remove(pName+'.bonds') 6544 if os.path.isfile(pName+'.triplets'): 6545 os.remove(pName+'.triplets') 6546 i = 1 6547 while True: 6548 if os.path.isfile(pName+'.bondodf_%d'%i): 6549 os.remove(pName+'.bondodf_%d'%i) 6550 os.remove(pName+'_bondplot_%d.ppm'%i) 6551 i += 1 6552 else: 6553 break 6554 i = 1 6555 while True: 6556 if os.path.isfile(pName+'_anglehist_%d.csv'%i): 6557 os.remove(pName+'_anglehist_%d.csv'%i) 6558 i += 1 6559 else: 6560 break 6561 6562 G2frame.OnFileSave(event) 6563 print (' GSAS-II project saved') 6564 pName = generalData['Name'].replace(' ','_') 6565 exstr = rmcexe+'\\rmcprofile.exe '+pName 6566 batch = open('runrmc.bat','w') 6567 batch.write('Title RMCProfile\n') 6568 batch.write(exstr+'\n') 6569 batch.write('pause\n') 6570 batch.close() 6571 Proc = subp.Popen('runrmc.bat',creationflags=subp.CREATE_NEW_CONSOLE) 6572 Proc.wait() #for it to finish before continuing on 6573 UpdateRMC() 6574 6575 def OnRunRMC(event): 6576 '''Run a previously created RMCProfile/fullrmc/PDFfit2 script 6577 ''' 6578 if G2frame.RMCchoice == 'fullrmc': 6579 Runfullrmc(event) 6580 elif G2frame.RMCchoice == 'RMCProfile': 6581 RunRMCProfile(event) 6582 elif G2frame.RMCchoice == 'PDFfit': 6583 RunPDFfit(event) 6444 6584 6445 6585 def OnStopRMC(event): -
trunk/GSASIIplot.py
r5104 r5106 5363 5363 Plot.set_ylabel('Data sequence',fontsize=12) 5364 5364 else: 5365 ifCalc = False 5365 5366 X = xye[0]+Page.Offset[0]*.005*N 5366 5367 Y = xye[1]+Page.Offset[1]*.01*N 5367 XYlist.append(list(zip(X,Y))) 5368 if xye.shape[0] > 2 and len(PlotList) == 1: #PDF calc present - single plot only 5369 ifCalc = True 5370 NZ = np.nonzero(xye[2])[0] 5371 ibeg = NZ[0] 5372 ifin = NZ[-1]+1 5373 Z = xye[2] 5374 D = xye[3] 5375 D -= 0.75*(np.max(D)-np.min(Z)) 5376 XYlist.append(np.array([X,Y])) 5377 XYlist.append(np.array([X,Z])) 5378 XYlist.append(np.array([X,D])) 5379 else: 5380 XYlist.append(list(zip(X,Y))) 5368 5381 # if G2frame.Legend: 5369 5382 # Plot.plot(X,Y,colors[N%6],picker=False,label='Azm:'+Pattern[2].split('=')[1]) … … 5379 5392 else: 5380 5393 XYlist = np.array(XYlist) 5381 Xmin = np.amin(XYlist.T[0]) 5382 Xmax = np.amax(XYlist.T[0]) 5394 if ifCalc: 5395 Xmin = np.amin(XYlist[0][0]) 5396 Xmax = np.amax(XYlist[0][0]) 5397 Ymax = np.amax(XYlist[0][1]) 5398 Ymin = np.amin(XYlist[2][1]) 5399 else: 5400 Xmin = np.amin(XYlist.T[0]) 5401 Xmax = np.amax(XYlist.T[0]) 5402 Ymin = np.amin(XYlist.T[1][1:]) 5403 Ymax = np.amax(XYlist.T[1][1:]) 5383 5404 dx = 0.02*(Xmax-Xmin) 5384 Ymin = np.amin(XYlist.T[1][1:])5385 Ymax = np.amax(XYlist.T[1][1:])5386 5405 dy = 0.02*(Ymax-Ymin) 5387 5406 try: … … 5408 5427 axcb.set_label(plotType) 5409 5428 else: #ok 5410 lines = mplC.LineCollection(XYlist,cmap=acolor) 5411 lines.set_array(np.arange(XYlist.shape[0])) 5412 Plot.add_collection(lines) 5413 axcb = Page.figure.colorbar(lines) 5414 axcb.set_label('PDF number') 5415 lgndlist = [] 5416 if G2frame.Legend: 5417 # make short names from choices dropping PDF and AZM and then extension 5418 labels = [os.path.splitext(i[3:i.find('Azm')].strip())[0] for i in choices] 5419 numlines = len(labels) 5420 # create an empty labeled line for each label with color from color map 5421 for i,lbl in enumerate(labels): 5422 color = acolor(int(0.5+acolor.N*i/(numlines-1.))) 5423 lgndlist.append(mpl.lines.Line2D([], [], color=color, label=lbl)) 5424 Plot.legend(handles=lgndlist,loc='best') 5429 if ifCalc: #obs, calc & diff 5430 Plot.plot(XYlist[0][0],XYlist[0][1],color='b',marker='+',linewidth=0) 5431 Plot.plot(XYlist[1][0][ibeg:ifin],XYlist[1][1][ibeg:ifin],color='g') 5432 Plot.plot(XYlist[2][0][ibeg:ifin],XYlist[2][1][ibeg:ifin],color='r') 5433 else: 5434 lines = mplC.LineCollection(XYlist,cmap=acolor) 5435 lines.set_array(np.arange(XYlist.shape[0])) 5436 Plot.add_collection(lines) 5437 axcb = Page.figure.colorbar(lines) 5438 axcb.set_label('PDF number') 5439 lgndlist = [] 5440 if G2frame.Legend: 5441 # make short names from choices dropping PDF and AZM and then extension 5442 labels = [os.path.splitext(i[3:i.find('Azm')].strip())[0] for i in choices] 5443 numlines = len(labels) 5444 # create an empty labeled line for each label with color from color map 5445 for i,lbl in enumerate(labels): 5446 color = acolor(int(0.5+acolor.N*i/(numlines-1.))) 5447 lgndlist.append(mpl.lines.Line2D([], [], color=color, label=lbl)) 5448 Plot.legend(handles=lgndlist,loc='best') 5425 5449 else: 5426 5450 if G2frame.Waterfall: -
trunk/GSASIIpwd.py
r5096 r5106 2969 2969 ''' 2970 2970 try: 2971 sys.path.append('%s'%GSASIIpath.path2GSAS2) 2971 2972 from diffpy.pdffit2 import PdfFit 2972 2973 return sys.executable … … 2981 2982 cx,ct,cs,cia = General['AtomPtrs'] 2982 2983 AtomVar = RMCPdict['AtomVar'] 2984 varnames = [] 2983 2985 for iat,atom in enumerate(RMCPdict['AtomConstr']): 2984 2986 for it,item in enumerate(atom): 2985 2987 if it > 1 and item: 2986 2988 itnum = item.split('@')[1] 2989 varname = '@%s'%itnum 2990 varnames.append(varname) 2987 2991 if it < 6: 2988 if '@%s'%itnumnot in AtomVar:2989 AtomVar[ '@%s'%itnum] = 0.0 #put ISODISTORT mode displ here?2992 if varname not in AtomVar: 2993 AtomVar[varname] = 0.0 #put ISODISTORT mode displ here? 2990 2994 else: 2991 2995 for i in range(3): 2992 if '@%s'%itnum not in AtomVar: 2993 AtomVar['@%s'%itnum] = Atoms[iat][cia+i+2] 2996 if varname not in AtomVar: 2997 AtomVar[varname] = Atoms[iat][cia+i+2] 2998 varnames = set(varnames) 2999 for name in list(AtomVar.keys()): #clear out unused parameters 3000 if name not in varnames: 3001 del AtomVar[name] 2994 3002 2995 3003 def MakePDFfitAtomsFile(Phase,RMCPdict): … … 3003 3011 fatm.write('format pdffit\n') 3004 3012 fatm.write('scale 1.000000\n') #fixed 3005 if RMCPdict['shape'] == 'sphere': 3006 sharp = '%10.6f,%10.6f,%10.6f\n'%(RMCPdict['delta2'][0],RMCPdict['delta1'][0],RMCPdict['sratio'][0]) 3007 else: 3008 sharp = '%10.6f,%10.6f,%10.6f,%10.6f\n'%(RMCPdict['delta2'][0],RMCPdict['delta1'][0],RMCPdict['sratio'][0],RMCPdict['rcut']) 3013 # if RMCPdict['shape'] == 'sphere': 3014 # sharp = '%10.6f,%10.6f,%10.6f\n'%(RMCPdict['delta2'][0],RMCPdict['delta1'][0],RMCPdict['sratio'][0]) 3015 # else: 3016 # sharp = '%10.6f,%10.6f,%10.6f,%10.6f\n'%(RMCPdict['delta2'][0],RMCPdict['delta1'][0],RMCPdict['sratio'][0],RMCPdict['rcut']) 3017 sharp = '%10.6f,%10.6f,%10.6f,%10.6f\n'%(RMCPdict['delta2'][0],RMCPdict['delta1'][0],RMCPdict['sratio'][0],RMCPdict['rcut']) 3009 3018 fatm.write('sharp '+sharp) 3010 3019 shape = '' … … 3069 3078 Nd = 0 3070 3079 Np = 0 3071 for file in RMCPdict['files']: 3072 if 'Select' in RMCPdict['files'][file][0]: 3073 continue 3074 if 'Neutron' in file: 3075 Nd += 1 3076 dType = 'Ndata' 3077 else: 3078 Nd += 1 3079 dType = 'Xdata' 3080 rundata += "pf.read_data('%s', '%s', 30.0, %.4f)\n"%(RMCPdict['files'][file][0],dType[0],RMCPdict[dType]['qdamp'][0]) 3081 rundata += 'pf.setdata(%d)\n'%Nd 3082 rundata += 'pf.pdfrange(%d, %6.2f, %6.2f)\n'%(Nd,RMCPdict[dType]['Fitrange'][0],RMCPdict[dType]['Fitrange'][1]) 3083 for item in ['dscale','qdamp','qbroad']: 3084 if RMCPdict[dType][item][1]: 3085 Np += 1 3086 rundata += 'pf.constrain(pf.%s(),"@%d")\n'%(item,Np) 3087 rundata += "pf.setpar(%d, %.2f)\n"%(Np,RMCPdict[dType][item][0]) 3080 parms = {} 3081 if 'sequential' in RMCPdict['refinement']: 3082 Np = 3 3083 rundata += '#sequential data here\n' 3084 else: 3085 for file in RMCPdict['files']: 3086 if 'Select' in RMCPdict['files'][file][0]: 3087 continue 3088 if 'Neutron' in file: 3089 Nd += 1 3090 dType = 'Ndata' 3091 else: 3092 Nd += 1 3093 dType = 'Xdata' 3094 rundata += "pf.read_data('%s', '%s', 30.0, %.4f)\n"%(RMCPdict['files'][file][0],dType[0],RMCPdict[dType]['qdamp'][0]) 3095 rundata += 'pf.setdata(%d)\n'%Nd 3096 rundata += 'pf.pdfrange(%d, %6.2f, %6.2f)\n'%(Nd,RMCPdict[dType]['Fitrange'][0],RMCPdict[dType]['Fitrange'][1]) 3097 for item in ['dscale','qdamp','qbroad']: 3098 if RMCPdict[dType][item][1]: 3099 Np += 1 3100 rundata += 'pf.constrain(pf.%s(),"@%d")\n'%(item,Np) 3101 parms[Np] = [RMCPdict[dType][item][0],item] 3088 3102 fName = General['Name']+'-PDFfit.stru' 3089 3103 fName = fName.replace(' ','_') 3104 Np = 9 3090 3105 rundata += "pf.read_struct('%s')\n"%(fName) 3091 3106 for item in ['delta1','delta2','sratio']: … … 3093 3108 Np += 1 3094 3109 rundata += 'pf.constrain(pf.%s,"@%d")\n'%(item,Np) 3095 rundata += 'pf.setpar(%d,%.3f)\n'%(Np,RMCPdict[item][0])3110 parms[Np] = [RMCPdict[item][0],item] 3096 3111 if 'sphere' in RMCPdict['shape'][0] and RMCPdict['spdiameter'][1]: 3097 3112 Np += 1 3098 3113 rundata += 'pf.constrain(pf.spdiameter,"@%d")\n'%Np 3099 rundata += 'pf.setpar(%d,%.3f)\n'%(Np,RMCPdict['spdiameter'][0])3100 3114 parms[Np] = [RMCPdict['spdiameter'][0],'spdiameter'] 3115 3101 3116 if RMCPdict['cellref']: 3102 3117 cellconst = GetCellConstr(RMCPdict['SGData']) 3103 3118 used = [] 3119 cellNames = ['a','b','c','alpha','beta','gamma'] 3104 3120 for ic in range(6): 3105 3121 if cellconst[ic]: 3106 3122 rundata += 'pf.constrain(pf.lat(%d), "@%d")\n'%(ic+1,Np+cellconst[ic]) 3107 3123 if cellconst[ic] not in used: 3108 rundata += 'pf.setpar(%d,%.5f)\n'%(Np+cellconst[ic],Cell[ic])3124 parms[Np+cellconst[ic]] = [Cell[ic],cellNames[ic]] 3109 3125 used.append(cellconst[ic]) 3110 3126 #Atom constraints here ------------------------------------------------------- … … 3119 3135 rundata += 'pf.constrain(%s,"%s")\n'%(names[it-2],item) 3120 3136 if itnum not in used: 3121 rundata += 'pf.setpar(%s,%.6f)\n'%(itnum,AtomVar['@%s'%itnum])3137 parms[itnum] = [AtomVar['@%s'%itnum],names[it-2].split('.')[1]] 3122 3138 used.append(itnum) 3123 3139 else: … … 3126 3142 rundata += 'pf.constrain(%s,"%s")\n'%(uijs[i],item) 3127 3143 if itnum not in used: 3128 rundata += 'pf.setpar(%s,%.5f)\n'%(itnum,AtomVar['@%s'%itnum])3144 parms[itnum] = [AtomVar['@%s'%itnum],uijs[i].split('.')[1]] 3129 3145 used.append(itnum) 3146 3147 if 'sequential' in RMCPdict['refinement']: 3148 rundata += '#parameters here\n' 3149 else: 3150 # set parameter values 3151 RMCPdict['Parms'] = parms 3152 for iprm in parms: 3153 rundata += 'pf.setpar(%s,%.6f)\n'%(iprm,parms[iprm][0]) 3130 3154 3131 3155 # Refine & Save results --------------------------------------------------------------- 3132 3156 rundata += 'pf.refine()\n' 3133 fName = General['Name'].replace(' ','_')+'-PDFfit' 3157 if 'sequential' in RMCPdict['refinement']: 3158 fName = 'Sequential_PDFfit' 3159 else: 3160 fName = General['Name'].replace(' ','_')+'-PDFfit' 3134 3161 Nd = 0 3135 3162 for file in RMCPdict['files']: … … 3142 3169 rundata += 'pf.save_res("%s")\n'%(fName+'.res') 3143 3170 3144 rfile = open(fName+'.py','w') 3171 if 'sequential' in RMCPdict['refinement']: 3172 rfile = open('Seq_PDFfit_template.py','w') 3173 else: 3174 rfile = open(fName+'.py','w') 3145 3175 rfile.writelines(rundata) 3146 3176 rfile.close() … … 3153 3183 3154 3184 General = Phase['General'] 3155 fName = General['Name']+'-PDFfit.rstr' 3156 try: 3157 rstr = open(fName.replace(' ','_'),'r') 3158 except FileNotFoundError: 3159 return [fName,'Not found - PDFfit failed'] 3160 lines = rstr.readlines() 3161 rstr.close() 3162 header = [line[:-1].split(' ',1) for line in lines[:7]] 3163 resdict = dict(header) 3164 for item in ['scale','sharp','cell']: 3165 resdict[item] = [float(val) for val in resdict[item].split(',')] 3166 General['Cell'][1:7] = resdict['cell'] 3167 for inam,name in enumerate(['delta2','delta1','sratio']): 3168 RMCPdict[name][0] = resdict['sharp'][inam] 3169 if 'shape' in resdict and 'sphere' in resdict['shape']: 3170 RMCPdict['spdiameter'][0] = resdict['shape'][-1] 3171 cx,ct,cs,ci = G2mth.getAtomPtrs(Phase) 3172 Atoms = Phase['Atoms'] 3173 atmBeg = 0 3174 for line in lines: 3175 atmBeg += 1 3176 if 'atoms' in line: 3177 break 3178 for atom in Atoms: 3179 atstr = lines[atmBeg][:-1].split() 3180 Uiistr = lines[atmBeg+2][:-1].split() 3181 Uijstr = lines[atmBeg+4][:-1].split() 3182 atom[cx:cx+4] = [float(atstr[1]),float(atstr[2]),float(atstr[3]),float(atstr[4])] 3183 atom[ci] = 'A' 3184 atom[ci+2:ci+5] = [float(Uiistr[0]),float(Uiistr[1]),float(Uiistr[2])] 3185 atom[ci+5:ci+8] = [float(Uijstr[0]),float(Uijstr[1]),float(Uijstr[2])] 3186 atmBeg += 6 3187 3188 fName = General['Name']+'-PDFfit.res' 3185 if RMCPdict['refinement'] == 'normal': 3186 fName = General['Name']+'-PDFfit.rstr' 3187 try: 3188 rstr = open(fName.replace(' ','_'),'r') 3189 except FileNotFoundError: 3190 return [fName,'Not found - PDFfit failed'] 3191 lines = rstr.readlines() 3192 rstr.close() 3193 header = [line[:-1].split(' ',1) for line in lines[:7]] 3194 resdict = dict(header) 3195 for item in ['scale','sharp','cell']: 3196 resdict[item] = [float(val) for val in resdict[item].split(',')] 3197 General['Cell'][1:7] = resdict['cell'] 3198 for inam,name in enumerate(['delta2','delta1','sratio']): 3199 RMCPdict[name][0] = resdict['sharp'][inam] 3200 if 'shape' in resdict: 3201 if 'sphere' in resdict['shape']: 3202 RMCPdict['spdiameter'][0] = resdict['shape'][-1] 3203 else: 3204 RMCPdict['stepcut'][0] = resdict['shape'][-1] 3205 cx,ct,cs,ci = G2mth.getAtomPtrs(Phase) 3206 Atoms = Phase['Atoms'] 3207 atmBeg = 0 3208 for line in lines: 3209 atmBeg += 1 3210 if 'atoms' in line: 3211 break 3212 for atom in Atoms: 3213 atstr = lines[atmBeg][:-1].split() 3214 Uiistr = lines[atmBeg+2][:-1].split() 3215 Uijstr = lines[atmBeg+4][:-1].split() 3216 atom[cx:cx+4] = [float(atstr[1]),float(atstr[2]),float(atstr[3]),float(atstr[4])] 3217 atom[ci] = 'A' 3218 atom[ci+2:ci+5] = [float(Uiistr[0]),float(Uiistr[1]),float(Uiistr[2])] 3219 atom[ci+5:ci+8] = [float(Uijstr[0]),float(Uijstr[1]),float(Uijstr[2])] 3220 atmBeg += 6 3221 3222 fName = 'Sequential_PDFfit.res' 3223 if RMCPdict['refinement'] == 'normal': 3224 fName = General['Name']+'-PDFfit.res' 3189 3225 try: 3190 3226 res = open(fName.replace(' ','_'),'r') … … 3203 3239 break 3204 3240 resline += line[:-1] 3241 for iline,line in enumerate(lines): 3242 if 'Rw - ' in line: 3243 Rwp = float(line.split(':')[1]) 3205 3244 results = resline.replace('(','').split(')')[:-1] 3206 3245 results = ['@'+result.lstrip() for result in results] 3207 results = [item.split()[:2] for item in results] 3208 results = dict([[item[0][:-1],float(item[1])] for item in results if item[0][:-1] in RMCPdict['AtomVar']]) 3209 RMCPdict['AtomVar'].update(results) 3210 return None 3246 results = [item.split() for item in results] 3247 if RMCPdict['refinement'] == 'normal': 3248 results = dict([[item[0][:-1],float(item[1])] for item in results if item[0][:-1] in RMCPdict['AtomVar']]) 3249 RMCPdict['AtomVar'].update(results) 3250 return None 3251 else: #sequential 3252 newParms = dict([[item[0][1:-1],[float(item[1]),float(item[2])]] for item in results]) 3253 return newParms,Rwp 3211 3254 3212 3255 def MakefullrmcRun(pName,Phase,RMCPdict): -
trunk/GSASIIseqGUI.py
r5086 r5106 95 95 if 'IMG' in histNames[0]: 96 96 sampleParmDict = {'Sample load':[],} 97 elif 'PDF' in histNames[0]: 98 sampleParmDict = {'Temperature':[]} 97 99 else: 98 100 sampleParmDict = {'Temperature':[],'Pressure':[],'Time':[], … … 103 105 sampleParm = {} 104 106 for name in histNames: 105 if 'IMG' in name :107 if 'IMG' in name or 'PDF' in name: 106 108 if name not in data: 107 109 continue … … 161 163 elif rows: 162 164 name = histNames[rows[0]] #only does 1st one selected 163 G2plt.PlotCovariance(G2frame,data[name]) 165 if data.get('covMatrix',[]): 166 G2plt.PlotCovariance(G2frame,data[name]) 164 167 else: 165 168 G2frame.ErrorDialog( … … 1086 1089 data['variableLabels'] = variableLabels 1087 1090 Histograms,Phases = G2frame.GetUsedHistogramsAndPhasesfromTree() 1088 Controls = G2frame.GPXtree.GetItemPyData(G2gd.GetGPXtreeItemId(G2frame,G2frame.root,'Controls')) 1089 # create a place to store Pseudo Vars & Parametric Fit functions, if not present 1090 if 'SeqPseudoVars' not in data: data['SeqPseudoVars'] = {} 1091 if 'SeqParFitEqList' not in data: data['SeqParFitEqList'] = [] 1092 histNames = data['histNames'] 1093 foundNames = [name for name in histNames if name in data] 1094 histNames = foundNames 1091 if not Histograms and not Phases: #PDF histogrms not PWDR 1092 histNames = [name[1] for name in data['histNames']] 1093 Controls = {} 1094 else: 1095 Controls = G2frame.GPXtree.GetItemPyData(G2gd.GetGPXtreeItemId(G2frame,G2frame.root,'Controls')) 1096 # create a place to store Pseudo Vars & Parametric Fit functions, if not present 1097 if 'SeqPseudoVars' not in data: data['SeqPseudoVars'] = {} 1098 if 'SeqParFitEqList' not in data: data['SeqParFitEqList'] = [] 1099 foundNames = [name for name in histNames if name in data] 1100 histNames = foundNames 1095 1101 if G2frame.dataDisplay: 1096 1102 G2frame.dataDisplay.Destroy() -
trunk/GSASIIstrIO.py
r5067 r5106 2958 2958 pFile.write(sigstr+'\n') 2959 2959 2960 2960 global PhFrExtPOSig 2961 2961 PhFrExtPOSig = {} 2962 2962 SizeMuStrSig = {} -
trunk/GSASIIstrMain.py
r5044 r5106 50 50 ateln2 = 8.0*math.log(2.0) 51 51 DEBUG = True 52 PhFrExtPOSig = None 52 53 53 54 def ReportProblems(result,Rvals,varyList): … … 411 412 G2stIO.SetHistogramPhaseData(parmDict,sigDict,Phases,Histograms,calcControls,pFile=printFile) 412 413 G2stIO.SetHistogramData(parmDict,sigDict,Histograms,calcControls,pFile=printFile) 414 covData['depSig'] = G2stIO.PhFrExtPOSig 413 415 if len(frozen): 414 416 if 'msg' in Rvals:
Note: See TracChangeset
for help on using the changeset viewer.