- Timestamp:
- Aug 8, 2017 4:50:04 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branch/2frame/GSASIIscriptable.py
r2968 r2974 86 86 ] 87 87 ''' 88 if not ospath.exists(ProjFile): 89 print ('\n*** Error attempt to open project file that does not exist:\n '+ 90 str(ProjFile)) 91 return 88 # Let IOError be thrown if file does not exist 89 # if not ospath.exists(ProjFile): 90 # print ('\n*** Error attempt to open project file that does not exist:\n '+ 91 # str(ProjFile)) 92 # return 92 93 file = open(ProjFile,'rb') 93 print('loading from file: {}'.format(ProjFile))94 # print('loading from file: {}'.format(ProjFile)) 94 95 Project = {} 95 96 nameList = [] … … 107 108 nameList[-1].append(datus[0]) 108 109 file.close() 109 print('project load successful')110 # print('project load successful') 110 111 except: 111 print("Error reading file "+str(ProjFile)+". This is not a GSAS-II .gpx file") 112 return None 112 raise IOError("Error reading file "+str(ProjFile)+". This is not a GSAS-II .gpx file") 113 finally: 114 file.close() 113 115 return Project,nameList 114 116 … … 122 124 ''' 123 125 file = open(ProjFile,'wb') 124 print('save to file: {}'.format(ProjFile)) 125 for name in nameList: 126 data = [] 127 item = Project[name[0]] 128 data.append([name[0],item['data']]) 129 for item2 in name[1:]: 130 data.append([item2,item[item2]]) 131 cPickle.dump(data,file,1) 132 file.close() 133 print('project save successful') 126 # print('save to file: {}'.format(ProjFile)) 127 try: 128 for name in nameList: 129 data = [] 130 item = Project[name[0]] 131 data.append([name[0],item['data']]) 132 for item2 in name[1:]: 133 data.append([item2,item[item2]]) 134 cPickle.dump(data,file,1) 135 finally: 136 file.close() 137 # print('project save successful') 134 138 135 139 def ImportPowder(reader,filename): … … 880 884 phases = self.data['Phases'] 881 885 if phasename in phases: 882 return G2Phase(phases[phasename], self)886 return G2Phase(phases[phasename], phasename, self) 883 887 884 888 def phases(self): … … 1295 1299 Author: Jackson O'Donnell jacksonhodonnell@gmail.com 1296 1300 """ 1297 def __init__(self, data, proj):1301 def __init__(self, data, name, proj): 1298 1302 self.data = data 1303 self.name = name 1299 1304 self.proj = proj 1300 1305 … … 1441 1446 def dump(*args): 1442 1447 """The dump subcommand""" 1443 import IPython.lib.pretty as pretty 1444 proj, nameList = LoadDictFromProjFile(args[0]) 1445 print("names:", nameList) 1446 for key, val in proj.items(): 1447 print(key, ":", sep='') 1448 pretty.pprint(val) 1448 raw = True 1449 histograms = False 1450 phases = False 1451 filenames = [] 1452 for arg in args: 1453 if arg in ['-h', '--histograms']: 1454 histograms = True 1455 raw = False 1456 elif arg in ['-p', '--phases']: 1457 phases = True 1458 raw = False 1459 elif arg in ['-r', '--raw']: 1460 raw = True 1461 else: 1462 filenames.append(arg) 1463 if raw: 1464 import IPython.lib.pretty as pretty 1465 for fname in filenames: 1466 if raw: 1467 proj, nameList = LoadDictFromProjFile(fname) 1468 print("file:", fname) 1469 print("names:", nameList) 1470 for key, val in proj.items(): 1471 print(key, ":") 1472 pretty.pprint(val) 1473 else: 1474 proj = G2Project(fname) 1475 if histograms: 1476 hists = proj.histograms() 1477 for h in hists: 1478 print(fname, h.name) 1479 if phases: 1480 phases = proj.phases() 1481 for p in phases: 1482 print(fname, p.name) 1449 1483 1450 1484 … … 1461 1495 1462 1496 def export(*args): 1497 """The export subcommand""" 1498 # Export CIF or Structure or ... 1463 1499 pass 1464 1500
Note: See TracChangeset
for help on using the changeset viewer.