Ignore:
Timestamp:
Dec 7, 2018 4:03:37 PM (4 years ago)
Author:
toby
Message:

fix reading of FullProf? & WinPLOTR-2006 files

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/imports/G2pwd_FP.py

    r3136 r3757  
    2121import GSASIIpath
    2222GSASIIpath.SetVersionNumber("$Revision: 1620 $")
    23 class xye_ReaderClass(G2obj.ImportPowderData):
     23class fp_ReaderClass(G2obj.ImportPowderData):
    2424    'Routines to import powder data from a FullProf 1-10 column .dat file'
    2525    def __init__(self):
     
    4040        fp = open(filename,'r')
    4141        for i,S in enumerate(fp):
    42             if i > 1000: break
     42            if i > 100: break
    4343            if begin:
    4444                if gotCcomment and S.find('*/') > -1:
     
    6565                else:
    6666                    self.errors += '  (binary)'
    67                 fp.close()
    68                 return False
     67                if i > 2:
     68                    fp.close()
     69                    return False
    6970        fp.close()
    7071        return True # no errors encountered
     
    101102            # valid line to read
    102103            if not steps:
    103                 vals = S.split(None,4)
    104                 if len(vals) >= 3:
    105                     steps = True
    106                     start = float(vals[0])
    107                     step = float(vals[1])
    108                     stop = float(vals[2])
    109                     if len(vals) > 3:
    110                         self.comments.append(vals[3][:-1])
     104                vals = S.replace(',',' ').split(None,4)
     105                if 'lambda' in S:
     106                    self.instdict['wave'] = float(vals[1])
     107                    continue
     108                elif len(vals) >= 3:
     109                    try:
     110                        steps = True
     111                        start = float(vals[0])
     112                        step = float(vals[1])
     113                        stop = float(vals[2])
     114                        if len(vals) > 3:
     115                            self.comments.append(vals[3][:-1])
     116                    except:
     117                        print('Skipping line ',S)
     118                    continue
     119                elif i<3:
     120                    print('Skipping header line ',S)
    111121                    continue
    112122            vals = S.split()    #data strings
Note: See TracChangeset for help on using the changeset viewer.