- Timestamp:
- May 16, 2022 2:05:08 PM (3 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 4 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified trunk/GSASIIctrlGUI.py ¶
r5269 r5278 2489 2489 def G2MessageBox(parent,msg,title='Error'): 2490 2490 '''Simple code to display a error or warning message 2491 2492 TODO: replace wx.MessageDialog with one derived from wx.Dialog because 2493 on most platforms wx.MessageDialog is a native widget and CentreOnParent 2494 will not function. 2491 2495 ''' 2492 2496 dlg = wx.MessageDialog(parent,StripIndents(msg), title, wx.OK|wx.CENTRE) -
TabularUnified trunk/GSASIIphsGUI.py ¶
r5272 r5278 6350 6350 G2frame.dataWindow.FRMCDataEdit.Enable(G2G.wxID_RUNRMC,True) 6351 6351 RMCPdict = data['RMC']['PDFfit'] 6352 G2pwd.MakePDFfitAtomsFile(data,RMCPdict) 6352 msg = G2pwd.MakePDFfitAtomsFile(data,RMCPdict) 6353 if msg: 6354 G2G.G2MessageBox(G2frame,'ERROR: '+msg,'PDFfit setup failure') 6355 return 6353 6356 fname = G2pwd.MakePDFfitRunFile(data,RMCPdict) 6354 6357 if fname is None: … … 6361 6364 generalData = data['General'] 6362 6365 ISOdict = data['ISODISTORT'] 6363 PDFfit_exec = G2pwd.findPDFfit() #returns location of python (not pdffit!)6366 PDFfit_exec,_ = G2pwd.findPDFfit() #returns location of python with PDFfit installed and path(s) for pdffit 6364 6367 if not PDFfit_exec: 6365 6368 wx.MessageBox(''' PDFfit2 is not currently installed for this platform. -
TabularUnified trunk/GSASIIpwd.py ¶
r5273 r5278 74 74 sateln2 = np.sqrt(ateln2) 75 75 nxs = np.newaxis 76 is_exe = lambda fpath: os.path.isfile(fpath) and os.access(fpath, os.X_OK) 76 77 77 78 #### Powder utilities ################################################################################ … … 3164 3165 have fullrmc installed or None, if it was not found. 3165 3166 ''' 3166 is_exe = lambda fpath: os.path.isfile(fpath) and os.access(fpath, os.X_OK)3167 3167 if GSASIIpath.GetConfigValue('fullrmc_exec') is not None and is_exe( 3168 3168 GSASIIpath.GetConfigValue('fullrmc_exec')): … … 3189 3189 if len(fl) > 0: 3190 3190 return os.path.abspath(sorted(fl)[0]) 3191 3191 3192 3192 def findPDFfit(): 3193 3193 '''Find if PDFfit2 is installed (may be local to GSAS-II). Does the following: 3194 :returns: the full path to a python executable or None, if it was not found. 3194 :returns: two items: (1) the full path to a python executable or None, if 3195 it was not found and (2) path(s) to the PDFfit2 location(s) as a list. 3196 3195 3197 ''' 3196 3198 if GSASIIpath.GetConfigValue('pdffit2_exec') is not None and is_exe( 3197 3199 GSASIIpath.GetConfigValue('pdffit2_exec')): 3198 return GSASIIpath.GetConfigValue('pdffit2_exec') 3200 return GSASIIpath.GetConfigValue('pdffit2_exec'),None 3201 pdffitloc = os.path.join(GSASIIpath.path2GSAS2,'PDFfit2') 3202 if not os.path.exists(pdffitloc): 3203 print('PDFfit2 not found in GSAS-II \n\t(expected in '+pdffitloc+')') 3204 return None,[] 3205 if pdffitloc not in sys.path: sys.path.append(pdffitloc) 3199 3206 try: 3200 if GSASIIpath.path2GSAS2 not in sys.path:3201 sys.path.insert(0,GSASIIpath.path2GSAS2)3202 3207 from diffpy.pdffit2 import PdfFit 3203 return sys.executable 3208 import diffpy 3209 import inspect 3210 pdffitloc = [os.path.dirname(os.path.dirname(inspect.getfile(diffpy)))] 3211 # is this the original version of diffpy (w/pdffit2.py) 3212 try: 3213 from diffpy.pdffit2 import pdffit2 3214 except ImportError: 3215 # or the GSAS-II version w/o; for this we need to find the binary's location 3216 try: 3217 import pdffit2 # added for GSAS-II to relocate binary file 3218 except ImportError: 3219 print('\nError: pdffit2 failed to load with this python\n') 3220 return None,[] 3221 except ModuleNotFoundError: 3222 print('\nGSAS-II does not have a PDFfit2 module compatible\nwith this Python interpreter\n') 3223 return None,[] 3224 pdffitloc += [os.path.dirname(inspect.getfile(pdffit2))] 3225 return sys.executable,pdffitloc 3204 3226 except Exception as msg: 3205 print('Error from PDFfit2 access:\n',msg)3206 return None 3227 print('Error importing PDFfit2:\n',msg) 3228 return None,[] 3207 3229 3208 3230 def GetPDFfitAtomVar(Phase,RMCPdict): … … 3238 3260 ''' 3239 3261 General = Phase['General'] 3262 if General['SGData']['SpGrp'] != 'P 1': 3263 return 'Space group symmetry must be lowered to P 1 for PDFfit' 3240 3264 fName = General['Name']+'-PDFfit.stru' 3241 3265 fName = fName.replace(' ','_') … … 3298 3322 General = Phase['General'] 3299 3323 Cell = General['Cell'][1:7] 3300 G2path = GSASIIpath.path2GSAS2 3301 rundata = ''' 3302 #!/usr/bin/env python 3324 rundata = '''#!/usr/bin/env python 3303 3325 # -*- coding: utf-8 -*- 3304 3326 import sys 3305 sys.path.append('%s') 3306 from diffpy.pdffit2 import PdfFit 3307 pf = PdfFit() 3308 '''%G2path 3327 ''' 3328 PDFfit_exe,PDFfit_path = findPDFfit() # returns python loc and path(s) for pdffit 3329 if not PDFfit_exe: 3330 GSASIIpath.IPyBreak() 3331 return None 3332 for p in PDFfit_path: 3333 rundata += "sys.path.append('{:}')\n".format(p) 3334 rundata += 'from diffpy.pdffit2 import PdfFit\n' 3335 rundata += 'pf = PdfFit()\n' 3309 3336 Nd = 0 3310 3337 Np = 0 … … 3315 3342 rundata += '#sequential data here\n' 3316 3343 else: 3317 for file in RMCPdict['files']: 3318 if 'Select' in RMCPdict['files'][file][0]: 3344 for fil in RMCPdict['files']: 3345 filNam = RMCPdict['files'][fil][0] 3346 if 'Select' in filNam: 3319 3347 continue 3320 if 'Neutron' in fil e:3348 if 'Neutron' in fil: 3321 3349 Nd += 1 3322 3350 dType = 'Ndata' … … 3324 3352 Nd += 1 3325 3353 dType = 'Xdata' 3326 rundata += "pf.read_data('%s', '%s', 30.0, %.4f)\n"%(RMCPdict['files'][file][0],dType[0],RMCPdict[dType]['qdamp'][0]) 3354 filNam = os.path.abspath(filNam) 3355 rundata += "pf.read_data('%s', '%s', 30.0, %.4f)\n"%(filNam,dType[0],RMCPdict[dType]['qdamp'][0]) 3327 3356 rundata += 'pf.setdata(%d)\n'%Nd 3328 3357 rundata += 'pf.pdfrange(%d, %6.2f, %6.2f)\n'%(Nd,RMCPdict[dType]['Fitrange'][0],RMCPdict[dType]['Fitrange'][1]) … … 3338 3367 fName = 'Sequential_PDFfit.stru' 3339 3368 Np = 9 3340 rundata += "pf.read_struct(' %s')\n"%(fName)3369 rundata += "pf.read_struct('{:}')\n".format(os.path.abspath(fName)) 3341 3370 for item in ['delta1','delta2','sratio']: 3342 3371 if RMCPdict[item][1]: -
TabularUnified trunk/PDFfit2/diffpy/pdffit2/pdffit.py ¶
r5096 r5278 27 27 # crash with AttributeError when executed during imports of 28 28 # parent packages. 29 from diffpy.pdffit2 import pdffit2 29 try: 30 from diffpy.pdffit2 import pdffit2 31 except: 32 import pdffit2 # added for GSAS-II to relocate binary file 30 33 from diffpy.pdffit2 import output 31 34
Note: See TracChangeset
for help on using the changeset viewer.