Changeset 3885
- Timestamp:
- Apr 9, 2019 3:30:40 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIstrIO.py
r3884 r3885 62 62 (gpxSize) and to index where to find each 1st-level tree item in the file. 63 63 ''' 64 tmpHistIndex = {}65 'Global variable used to index contents of .seqHist file'66 64 67 65 def GetFullGPX(GPXfile): … … 659 657 fp.close() 660 658 # create empty file for histogram info 661 tmpHistIndex.clear()662 659 GPXhist = os.path.splitext(GPXfile)[0]+'.seqHist' 663 660 fp = open(GPXhist,'wb') … … 725 722 GPXhist = os.path.splitext(GPXfile)[0]+'.seqHist' 726 723 fp = open(GPXhist,'ab') 727 tmpHistIndex[histname] = fp.tell()728 724 cPickle.dump(data,fp,1) 729 725 fp.close() 730 return 726 return 731 727 732 728 def SetSeqResult(GPXfile,Histograms,SeqResult): … … 755 751 GPXhist = os.path.splitext(GPXfile)[0]+'.seqHist' 756 752 hist = open(GPXhist,'rb') 753 # build an index to the GPXhist file 754 histIndex = {} 755 while True: 756 loc = hist.tell() 757 try: 758 datum = cPickleLoad(hist)[0] 759 except EOFError: 760 break 761 histIndex[datum[0]] = loc 762 757 763 infile = open(GPXback,'rb') 758 764 outfile = open(GPXfile,'wb') … … 775 781 elif datum[0] == 'Controls': # reset the Copy Next flag after a sequential fit 776 782 data[0][1]['Copy2Next'] = False 777 elif datum[0] in tmpHistIndex:778 hist.seek( tmpHistIndex[datum[0]])783 elif datum[0] in histIndex: 784 hist.seek(histIndex[datum[0]]) 779 785 hdata = cPickleLoad(hist) 786 if GSASIIpath.GetConfigValue('debug'): 787 print('Updating {} with {}'.format(data[0][0],hdata[0][0])) 780 788 xferItems = ['Background','Instrument Parameters','Sample Parameters','Reflection Lists'] 781 789 hItems = {name:j+1 for j,(name,val) in enumerate(hdata[1:]) if name in xferItems} … … 795 803 outfile.close() 796 804 # clean up tmp files 797 tmpHistIndex.clear()798 805 try: 799 806 os.remove(GPXphase)
Note: See TracChangeset
for help on using the changeset viewer.