- Timestamp:
- Nov 10, 2020 11:24:39 AM (3 years ago)
- Location:
- trunk
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIIO.py
r4635 r4654 677 677 wx.BeginBusyCursor() 678 678 try: 679 if GSASIIpath.GetConfigValue('show_gpxSize'): 680 posPrev = 0 681 sizeList = {} 679 682 while True: 680 683 try: … … 683 686 break 684 687 datum = data[0] 688 if GSASIIpath.GetConfigValue('show_gpxSize'): 689 sizeList[datum[0]] = filep.tell()-posPrev 690 posPrev = filep.tell() 685 691 # scan the GPX file for unexpected objects 686 692 if GSASIIpath.GetConfigValue('debug'): … … 761 767 else: 762 768 print('project load successful') 769 if GSASIIpath.GetConfigValue('show_gpxSize'): 770 print(50*'=') 771 print('File section sizes (Kb)') 772 for item in sizeList: 773 print(' {:20s} {:10.3f}'.format( 774 item[:20],sizeList[item]/1024.)) 775 print(50*'=') 763 776 G2frame.NewPlot = True 764 777 except Exception as errmsg: -
trunk/GSASIIctrlGUI.py
r4647 r4654 1278 1278 if self.onChoice: 1279 1279 self.onChoice() 1280 def setByString(self,string): 1281 'Find an entry matching string and select it' 1282 num = self.FindString(string) 1283 if num >= 0: self.SetSelection(num) 1280 1284 1281 1285 ############################################################## -
trunk/GSASIIfiles.py
r4635 r4654 28 28 import inspect 29 29 import numpy as np 30 import imp31 30 32 31 import GSASIIpath … … 388 387 389 388 readerlist = [] 390 pathlist = sys.path[:] 391 if '.' not in pathlist: 392 pathlist.append('.') 393 394 potential_files = [] 395 for path in pathlist: 389 import_files = {} 390 if '.' not in sys.path: sys.path.append('.') 391 for path in sys.path: 396 392 for filename in glob.iglob(os.path.join(path, 'G2'+prefix+'*.py')): 397 potential_files.append(filename) 398 399 potential_files = sorted(list(set(potential_files))) 400 for filename in potential_files: 401 path, rootname = os.path.split(filename) 402 pkg = os.path.splitext(rootname)[0] 403 393 pkg = os.path.splitext(os.path.split(filename)[1])[0] 394 if pkg in import_files: 395 G2Print('Warning: file {} hidden by {}' 396 .format(os.path.abspath(filename),import_files[pkg])) 397 else: 398 import_files[pkg] = filename 399 400 for pkg in sorted(import_files.keys()): 404 401 try: 405 fp = None 406 fp, fppath, desc = imp.find_module(pkg, [path]) 407 pkg = imp.load_module(pkg, fp, fppath, desc) 408 for name, value in inspect.getmembers(pkg): 402 exec('import '+pkg) 403 for name, value in inspect.getmembers(eval(pkg)): 409 404 if name.startswith('_'): 410 405 continue … … 420 415 readerlist.append(reader) 421 416 except AttributeError: 422 G2Print ('Import_' + errprefix + ': Attribute Error ' + filename)417 G2Print ('Import_' + errprefix + ': Attribute Error ' + import_files[pkg]) 423 418 if traceback: 424 419 traceback.print_exc(file=sys.stdout) 425 420 except Exception as exc: 426 G2Print ('\nImport_' + errprefix + ': Error importing file ' + filename)421 G2Print ('\nImport_' + errprefix + ': Error importing file ' + import_files[pkg]) 427 422 G2Print (u'Error message: {}\n'.format(exc)) 428 423 if traceback: 429 424 traceback.print_exc(file=sys.stdout) 430 finally:431 if fp:432 fp.close()433 434 425 return readerlist 435 426 … … 438 429 ''' 439 430 exporterlist = [] 440 pathlist = sys.path441 filelist = []442 for path in pathlist:431 import_files = {} 432 if '.' not in sys.path: sys.path.append('.') 433 for path in sys.path: 443 434 for filename in glob.iglob(os.path.join(path,"G2export*.py")): 444 filelist.append(filename) 445 filelist = sorted(list(set(filelist))) # remove duplicates 435 pkg = os.path.splitext(os.path.split(filename)[1])[0] 436 if pkg in import_files: 437 G2Print('Warning: file {} hidden by {}' 438 .format(os.path.abspath(filename),import_files[pkg])) 439 else: 440 import_files[pkg] = filename 446 441 # go through the routines and import them, saving objects that 447 442 # have export routines (method Exporter) 448 for filename in filelist: 449 path,rootname = os.path.split(filename) 450 pkg = os.path.splitext(rootname)[0] 443 for pkg in sorted(import_files.keys()): 451 444 try: 452 fp = None 453 fp, fppath,desc = imp.find_module(pkg,[path,]) 454 pkg = imp.load_module(pkg,fp,fppath,desc) 455 for clss in inspect.getmembers(pkg): # find classes defined in package 445 exec('import '+pkg) 446 for clss in inspect.getmembers(eval(pkg)): # find classes defined in package 456 447 if clss[0].startswith('_'): continue 457 448 if not inspect.isclass(clss[1]): continue … … 484 475 if traceback: 485 476 traceback.print_exc(file=sys.stdout) 486 finally:487 if fp:488 fp.close()489 477 return exporterlist 490 478 -
trunk/GSASIIobj.py
r4643 r4654 1243 1243 import platform 1244 1244 import re 1245 import imp1246 1245 import random as ran 1247 1246 import sys … … 2884 2883 df = f.split('.') 2885 2884 pkgdict = {} 2886 # no listed package, try in current namespace2885 # no listed module name, try in current namespace 2887 2886 if len(df) == 1: 2888 2887 try: … … 2891 2890 except (AttributeError, NameError): 2892 2891 return None,None 2893 else: 2894 try: 2895 fxnobj = eval(f) 2896 pkgdict[df[0]] = eval(df[0]) 2897 return pkgdict,fxnobj 2898 except (AttributeError, NameError): 2899 pass 2900 # includes a package, lets try to load the packages 2901 pkgname = '' 2902 path = sys.path+['./',] 2903 for pkg in f.split('.')[:-1]: # if needed, descend down the tree 2904 if pkgname: 2905 pkgname += '.' + pkg 2906 else: 2907 pkgname = pkg 2908 fp = None 2909 try: 2910 fp, fppath,desc = imp.find_module(pkg,path) 2911 pkgobj = imp.load_module(pkg,fp,fppath,desc) 2912 pkgdict[pkgname] = pkgobj 2913 path = [fppath] 2914 except Exception as msg: 2915 print('load of '+pkgname+' failed with error='+str(msg)) 2916 return {},None 2917 finally: 2918 if fp: fp.close() 2919 try: 2920 #print 'before',pkgdict.keys() 2921 fxnobj = eval(f,globals(),pkgdict) 2922 #print 'after 1',pkgdict.keys() 2923 #fxnobj = eval(f,pkgdict) 2924 #print 'after 2',pkgdict.keys() 2925 return pkgdict,fxnobj 2926 except: 2927 continue 2928 return None # not found 2892 2893 # includes a package, see if package is already imported 2894 pkgnam = '.'.join(df[:-1]) 2895 try: 2896 fxnobj = eval(f) 2897 pkgdict[pkgnam] = eval(pkgnam) 2898 return pkgdict,fxnobj 2899 except (AttributeError, NameError): 2900 pass 2901 # package not yet imported, so let's try 2902 if '.' not in sys.path: sys.path.append('.') 2903 pkgnam = '.'.join(df[:-1]) 2904 #for pkg in f.split('.')[:-1]: # if needed, descend down the tree 2905 # if pkgname: 2906 # pkgname += '.' + pkg 2907 # else: 2908 # pkgname = pkg 2909 try: 2910 exec('import '+pkgnam) 2911 pkgdict[pkgnam] = eval(pkgnam) 2912 fxnobj = eval(f) 2913 except Exception as msg: 2914 print('load of '+pkgnam+' failed with error='+str(msg)) 2915 return {},None 2916 # can we access the function? I am not exactly sure what 2917 # I intended this to test originally (BHT) 2918 try: 2919 fxnobj = eval(f,globals(),pkgdict) 2920 return pkgdict,fxnobj 2921 except Exception as msg: 2922 print('call to',f,' failed with error=',str(msg)) 2923 return None,None # not found 2929 2924 def ASTtransverse(node,fxn=False): 2930 2925 '''Transverse a AST-parsed expresson, compiling a list of variables -
trunk/GSASIIphsGUI.py
r4647 r4654 7770 7770 drawingData['selectedAtoms'] = drawAtoms.GetSelectedRows() 7771 7771 G2plt.PlotStructure(G2frame,data) 7772 7772 G2frame.Raise() 7773 7773 7774 def RowSelect(event): 7774 7775 r,c = event.GetRow(),event.GetCol() … … 10666 10667 i for i,a in enumerate(data['Atoms']) if a[0] == cryatom] 10667 10668 G2plt.PlotStructure(G2frame,data,False,UpdateTable) 10668 misc['showSelect'].SetLabelText(cryatom) 10669 misc['showSelect'].setByString(cryatom) 10670 G2frame.Raise() 10671 #RigidBodies.atomsGrid.SetFocus() 10669 10672 10670 10673 def OnSymRadioSet(event): … … 12940 12943 def rbKeyPress(event): 12941 12944 '''Respond to a Tab to highlight the next RB or crystal atom 12945 TODO: this is not getting called in Windows. Is a bind needed elsewhere? 12942 12946 ''' 12943 12947 if 'testRBObj' not in data: return … … 12981 12985 if data['Atoms'][I][0] in data['testRBObj']['availAtoms']: 12982 12986 data['testRBObj']['CRYhighLight'] = [I] 12983 misc['showSelect']. SetLabelText(data['Atoms'][I][0])12987 misc['showSelect'].setByString(data['Atoms'][I][0]) 12984 12988 break 12985 12989 G2plt.PlotStructure(G2frame,data,False,misc['UpdateTable']) 12990 G2frame.Raise() 12991 return 12992 12986 12993 if data['General']['Type'] not in ['faulted',] and not data['General']['Modulated']: 12987 12994 RigidBodies = wx.ScrolledWindow(G2frame.phaseDisplay) 12988 12995 G2frame.phaseDisplay.AddPage(RigidBodies,'RB Models') 12996 # note the bind is here so that it is only done once, but 12997 # TODO: might need to be on a different widget for Windows 12989 12998 RigidBodies.Bind(wx.EVT_CHAR,rbKeyPress) 12990 12999 Pages.append('RB Models') -
trunk/GSASIIscriptable.py
r4636 r4654 1345 1345 file.close() 1346 1346 G2fil.G2Print('gpx file saved as %s'%ProjFile) 1347 1348 # def ImportPowder(reader,filename):1349 # '''Use a reader to import a powder diffraction data file1350 1351 # :param str reader: a scriptable reader1352 # :param str filename: full name of powder data file; can be "multi-Bank" data1353 1354 # :returns: list rdlist: list of reader objects containing powder data, one for each1355 # "Bank" of data encountered in file. Items in reader object of interest are:1356 1357 # * rd.comments: list of str: comments found on powder file1358 # * rd.dnames: list of str: data nammes suitable for use in GSASII data tree NB: duplicated in all rd entries in rdlist1359 # * rd.powderdata: list of numpy arrays: pos,int,wt,zeros,zeros,zeros as needed for a PWDR entry in GSASII data tree.1360 # '''1361 # rdfile,rdpath,descr = imp.find_module(reader)1362 # rdclass = imp.load_module(reader,rdfile,rdpath,descr)1363 # rd = rdclass.GSAS_ReaderClass()1364 # if not rd.scriptable:1365 # G2fil.G2Print(u'**** ERROR: '+reader+u' is not a scriptable reader')1366 # return None1367 # rdlist = []1368 # if rd.ContentsValidator(filename):1369 # repeat = True1370 # rdbuffer = {} # create temporary storage for file reader1371 # block = 01372 # while repeat: # loop if the reader asks for another pass on the file1373 # block += 11374 # repeat = False1375 # rd.objname = ospath.basename(filename)1376 # flag = rd.Reader(filename,None,buffer=rdbuffer,blocknum=block,)1377 # if flag:1378 # rdlist.append(copy.deepcopy(rd)) # save the result before it is written over1379 # if rd.repeat:1380 # repeat = True1381 # return rdlist1382 # G2fil.G2Print(rd.errors)1383 # return None1384 1347 1385 1348 def SetDefaultDData(dType,histoName,NShkl=0,NDij=0): -
trunk/config_example.py
r4617 r4654 234 234 ''' 235 235 236 show_gpxSize = False 237 '''When True, the sizes of the sections of the GPX file are listed 238 when the GPX file is opened. Default is False. 239 ''' -
trunk/help/Tutorials.html
r4632 r4654 48 48 <blockquote><I>Shows how to set lower and upper limits on selected parameters to keep refinements from refining unreasonably.</I></blockquote> 49 49 <LI><A href="https://subversion.xray.aps.anl.gov/pyGSAS/Tutorials/RigidBody/RigidBodyRef.html">Rietveld Fitting with Rigid Bodies</A> 50 [link :<A href="https://subversion.xray.aps.anl.gov/pyGSAS/Tutorials/RigidBody/data">Exercise files</A>].50 [links: <A href="https://anl.box.com/v/RigidBodyRef">video</A>, <A href="https://subversion.xray.aps.anl.gov/pyGSAS/Tutorials/RigidBody/data">Exercise files</A>]. 51 51 <blockquote><I>Shows how to set up and refine with rigid bodies to simplify and improve the crystal structure model.</I></blockquote> 52 52 </UL><h4>Magnetic Structure Analysis</H4><UL> … … 222 222 <LI><A href="https://anl.box.com/v/SimTutorial-">Simulating Powder Diffraction with GSAS-II</A></LI> 223 223 <LI><A href="https://anl.box.com/v/FitBkgTut---">Fitting the Starting Background using Fixed Points</A></LI> 224 <LI><A href="https://anl.box.com/v/RigidBodyRef">Rietveld Fitting with Rigid Bodies</A></LI> 224 225 <LI><A href="https://anl.box.com/v/SimpleMagnetic">Simple Magnetic Structure Analysis</A></LI> 225 226 <LI><A href="https://anl.box.com/v/SequentialTutorial">Sequential refinement of multiple datasets</A></LI> -
trunk/makeTutorial.py
r4131 r4654 52 52 onlineVideos.append('https://anl.box.com/v/Textureanalysisof2DdatainGSAS-') 53 53 onlineVideos.append('https://anl.box.com/v/TOFSequentialSinglePeakFit') 54 onlineVideos.append('https://anl.box.com/v/RigidBodyRef') 54 55 #onlineVideos.append(' 55 56
Note: See TracChangeset
for help on using the changeset viewer.