Changeset 3885 for trunk/GSASIIstrIO.py


Ignore:
Timestamp:
Apr 9, 2019 3:30:40 PM (3 years ago)
Author:
toby
Message:

correct seq ref hist error

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIstrIO.py

    r3884 r3885  
    6262(gpxSize) and to index where to find each 1st-level tree item in the file.
    6363'''
    64 tmpHistIndex = {}
    65 'Global variable used to index contents of .seqHist file'
    6664
    6765def GetFullGPX(GPXfile):
     
    659657    fp.close()
    660658    # create empty file for histogram info
    661     tmpHistIndex.clear()
    662659    GPXhist = os.path.splitext(GPXfile)[0]+'.seqHist'
    663660    fp = open(GPXhist,'wb')
     
    725722    GPXhist = os.path.splitext(GPXfile)[0]+'.seqHist'
    726723    fp = open(GPXhist,'ab')
    727     tmpHistIndex[histname] = fp.tell()
    728724    cPickle.dump(data,fp,1)
    729725    fp.close()
    730     return   
     726    return
    731727   
    732728def SetSeqResult(GPXfile,Histograms,SeqResult):
     
    755751    GPXhist = os.path.splitext(GPXfile)[0]+'.seqHist'
    756752    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
    757763    infile = open(GPXback,'rb')
    758764    outfile = open(GPXfile,'wb')
     
    775781        elif datum[0] == 'Controls': # reset the Copy Next flag after a sequential fit
    776782            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]])
    779785            hdata = cPickleLoad(hist)
     786            if GSASIIpath.GetConfigValue('debug'):
     787                print('Updating {} with {}'.format(data[0][0],hdata[0][0]))
    780788            xferItems = ['Background','Instrument Parameters','Sample Parameters','Reflection Lists']
    781789            hItems = {name:j+1 for j,(name,val) in enumerate(hdata[1:]) if name in xferItems}
     
    795803    outfile.close()
    796804    # clean up tmp files
    797     tmpHistIndex.clear()
    798805    try:
    799806        os.remove(GPXphase)
Note: See TracChangeset for help on using the changeset viewer.