Ignore:
Timestamp:
May 5, 2017 2:40:25 PM (5 years ago)
Author:
vondreele
Message:

revisions to GSASIIscriptable - now works for reading PWDR data

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIscriptable.py

    r2820 r2821  
    1414import cPickle
    1515import imp
     16import copy
    1617import GSASIIpath
    1718import GSASIIobj as G2obj
     
    9798    print('project save successful')
    9899   
    99 def ImportPowder(reader,filename,bankNo=0):
     100def ImportPowder(reader,filename):
     101    readerlist = ['G2pwd_fxye','G2pwd_xye','G2pwd_BrukerRAW','G2pwd_csv','G2pwd_FP',
     102        'G2pwd_Panalytical','G2pwd_rigaku']
     103    if reader not in readerlist:
     104        print '**** ERROR: unrecognized reader ',reader
     105        return None
    100106    rdfile,rdpath,descr = imp.find_module(reader)
    101107    rdclass = imp.load_module(reader,rdfile,rdpath,descr)
    102108    rd = rdclass.GSAS_ReaderClass()   
    103     fl = open(filename)
     109    fl = open(filename,'rb')
     110    rdlist = []
    104111    if rd.ContentsValidator(fl):
    105112        fl.seek(0)
    106         rd.selections = [bankNo,]
    107         if rd.Reader(filename,fl):
    108             return rd
     113        repeat = True
     114        rdbuffer = {} # create temporary storage for file reader
     115        block = 0
     116        while repeat: # loop if the reader asks for another pass on the file
     117            block += 1
     118            repeat = False
     119            rd.objname = ospath.basename(filename)
     120            flag = rd.Reader(filename,fl,None,buffer=rdbuffer,blocknum=block,)
     121            if flag:
     122                rdlist.append(copy.deepcopy(rd)) # save the result before it is written over
     123                if rd.repeat:
     124                    repeat = True
     125        return rdlist
    109126    print rd.errors
    110127    return None
Note: See TracChangeset for help on using the changeset viewer.