@@ -5740,7 +5740,7 @@ def OnReplacePhase(event):
57405740 Constraints = G2frame.GPXtree.GetItemPyData(consId)
57415741 # TODO: would be cleaner to just delete constraints w/phase data['pId']
57425742 Constraints['Phase'] = []
5743- del data['magPhases']
5743+ if 'magPhases' in data: del data['magPhases']
57445744 data['MCSA'] = {'Models':
57455745 [{'Type': 'MD', 'Coef': [1.0, False, [0.8, 1.2]], 'axis': [0, 0, 1]}],
57465746 'Results': [], 'AtInfo': {}}
@@ -7716,11 +7716,13 @@ def AtomVarSizer():
77167716 RMCmisc['RMCnote'].SetLabel('Note that fullrmc is not installed or was not located')
77177717
77187718 def OnSetupRMC(event):
7719+ written = lambda fil: print(f' {fil} written')
77197720 generalData = data['General']
77207721 if not G2frame.GSASprojectfile: #force a project save
77217722 G2frame.OnFileSaveas(event)
77227723 dName = G2frame.LastGPXdir
77237724 os.chdir(dName)
7725+ print(f'Writing input files in directory {dName!r}')
77247726 if G2frame.RMCchoice == 'fullrmc':
77257727 RMCPdict = data['RMC']['fullrmc']
77267728 pName = G2frame.GSASprojectfile.split('.')[0] + '-' + generalData['Name']
@@ -7755,7 +7757,7 @@ def OnSetupRMC(event):
77557757 Size = data['Histograms'][histoName]['Size']
77567758 Mustrain = data['Histograms'][histoName]['Mustrain']
77577759 reset = False
7758- print (G2pwd.MakeInst(PWDdata,pName,Size,Mustrain,RMCPdict['UseSampBrd'])+ ' written' )
7760+ written (G2pwd.MakeInst(PWDdata,pName,Size,Mustrain,RMCPdict['UseSampBrd']))
77597761 backfile = G2pwd.MakeBack(PWDdata,pName)
77607762 if backfile is None:
77617763 print(' Chebyschev-1 background not used; no .back file written')
@@ -7764,20 +7766,20 @@ def OnSetupRMC(event):
77647766 G2frame.dataWindow.FRMCDataEdit.Enable(G2G.wxID_RUNRMC,False)
77657767 return
77667768 else:
7767- print (backfile+ ' written' )
7768- print (G2pwd.MakeBragg(PWDdata,pName,data)+ ' written' )
7769+ written (backfile)
7770+ written (G2pwd.MakeBragg(PWDdata,pName,data))
77697771 if RMCPdict['ReStart'][0]:
77707772 if os.path.isfile(pName+'.his6f'):
77717773 os.remove(pName+'.his6f')
77727774 RMC6f,reset = G2pwd.MakeRMC6f(PWDdata,pName,data,RMCPdict)
7773- print (RMC6f+ ' written' )
7775+ written (RMC6f)
77747776 fname = G2pwd.MakeRMCPdat(PWDdata,pName,data,RMCPdict)
77757777 if 'Error' in fname:
77767778 print(fname)
77777779 wx.MessageDialog(G2frame,fname,'Missing reflection list',wx.OK).ShowModal()
77787780 G2frame.dataWindow.FRMCDataEdit.Enable(G2G.wxID_RUNRMC,False)
77797781 return
7780- print (fname+ ' written' )
7782+ written (fname)
77817783 print('RMCProfile file build completed')
77827784 RMCPdict['ReStart'] = [False,False]
77837785 if reset:
@@ -7802,7 +7804,7 @@ def OnSetupRMC(event):
78027804 if fname is None:
78037805 wx.MessageDialog(G2frame,'ERROR: failure to setup PDFfit; check console','PDFfit setup failure',wx.ICON_ERROR).ShowModal()
78047806 else:
7805- print (fname+ ' written' )
7807+ written (fname)
78067808 print('PDFfit file build completed')
78077809
78087810 def RunPDFfit(event):
@@ -8122,22 +8124,8 @@ def Runfullrmc(event):
81228124 def RunRMCProfile(event):
81238125 generalData = data['General']
81248126 pName = generalData['Name'].replace(' ','_')
8125- rmcfile = G2fil.find('rmcprofile.exe',GSASIIpath.path2GSAS2)
8126- os_name = platform.system()
8127- if os_name == "Darwin":
8128- rmcexe = os.path.join(
8129- "/Applications/RMCProfile.app/Contents/MacOS/exe/",
8130- "rmcprofile.x"
8131- )
8132- else:
8133- if rmcfile is None:
8134- wx.MessageBox(''' RMCProfile is not correctly installed for use in GSAS-II
8135- Obtain the zip file distribution from www.rmcprofile.org,
8136- unzip it and place the RMCProfile main directory in the main GSAS-II directory ''',
8137- caption='RMCProfile',style=wx.ICON_INFORMATION)
8138- return
8139- rmcexe = os.path.split(rmcfile)[0]
8140- #print(rmcexe)
8127+ rmcfile = G2pwd.findrmcprofile()
8128+
81418129 wx.MessageBox(
81428130 ' For use of RMCProfile, please cite:\n\n'+
81438131 G2G.GetCite("RMCProfile"),
@@ -8169,32 +8157,40 @@ def RunRMCProfile(event):
81698157 break
81708158
81718159 G2frame.OnFileSave(event)
8172- print (' GSAS-II project saved')
8160+ print ('GSAS-II project saved')
81738161 pName = generalData['Name'].replace(' ','_')
81748162
8175- if os_name == "Darwin":
8176- with open('runrmc.sh', 'w') as f:
8163+ if rmcfile is None:
8164+ wx.MessageBox('''RMCProfile is not correctly installed for use in GSAS-II
8165+ This software must be downloaded separately (from
8166+ https://rmcprofile.ornl.gov/download). Install the rmcprofile or
8167+ rmcprofile.exe file in a location where GSAS-II can find it
8168+ (see config variable rmcprofile_exec in preferences.)''',
8169+ caption='RMCProfile',style=wx.ICON_INFORMATION)
8170+ return
8171+
8172+ if sys.platform == "darwin":
8173+ script_file = os.path.join(os.getcwd(), "runrmc.sh")
8174+ with open(script_file, 'w') as f:
81778175 f.write("#!/bin/bash\n")
8178- f.write(" cd " + os.getcwd() + "\n" )
8179- f.write(rmcexe + " " + pName + "\n" )
8176+ f.write(f' cd "{ os.getcwd()} "\n' )
8177+ f.write(f'"{rmcfile}" "{ pName} "\n' )
81808178 os.system("chmod +x runrmc.sh")
8181- script_file = os.path.join(os.getcwd(), "runrmc.sh")
8182- applescript_command = 'tell app "Terminal"\n'
8183- applescript_command += "if not (exists window 1) then\n"
8184- applescript_command += f'do script "source {script_file}"\n'
8185- applescript_command += "else\n"
8186- applescript_command += f'do script "source {script_file}"'
8187- applescript_command += " in window 1\n"
8188- applescript_command += "end if\nactivate\nend tell"
8189- subp.Popen(['osascript', '-e', applescript_command])
8179+ ascript_file = os.path.join(os.getcwd(), "runrmc.script")
8180+ with open(ascript_file, 'w') as f:
8181+ f.write('tell application "Terminal"\n')
8182+ f.write(f''' do script "echo 'Running RMCprofile'"\n''')
8183+ f.write(f' do script "bash {script_file}" in window 1\n')
8184+ f.write("end tell\n")
8185+ subp.Popen(['osascript', ascript_file])
81908186 else:
8191- exstr = rmcexe+'\\rmcprofile.exe '+pName
8192- batch = open('runrmc.bat' ,'w')
8193- batch.write('Title RMCProfile\n')
8194- batch.write(exstr+' \n')
8195- batch.write('pause\n')
8196- batch.close()
8197- subp.Popen('runrmc.bat' ,creationflags=subp.CREATE_NEW_CONSOLE)
8187+ script_file = os.path.join(os.getcwd(), "runrmc.bat")
8188+ with open(script_file ,'w') as batch:
8189+ batch.write('Title RMCProfile\n') # BHT: is Title a Windows command?
8190+ batch.write(f'"{rmcfile}" "{pName}" \n')
8191+ batch.write('pause\n')
8192+ batch.close()
8193+ subp.Popen(script_file ,creationflags=subp.CREATE_NEW_CONSOLE)
81988194# Proc.wait() #for it to finish before continuing on
81998195 UpdateRMC()
82008196
0 commit comments