Changeset 3757


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

fix reading of FullProf? & WinPLOTR-2006 files

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIdataGUI.py

    r3742 r3757  
    14291429                else:
    14301430                    rd.instmsg = 'default: '+dI.defaultIparm_lbl[res]
    1431                     return self.ReadPowderInstprm(dI.defaultIparms[res],bank,numbanks,rd)    #this is [Inst1,Inst2] a pair of dicts
     1431                    inst1,inst2 = self.ReadPowderInstprm(dI.defaultIparms[res],bank,numbanks,rd)
     1432                    if rd.instdict.get('wave'):
     1433                        inst1['Lam'][0] = rd.instdict.get('wave')
     1434                        inst1['Lam'][1] = rd.instdict.get('wave')
     1435                    return [inst1,inst2]
    14321436
    14331437        # stuff we might need from the reader
  • 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
  • trunk/imports/G2pwd_xye.py

    r3670 r3757  
    7878                else:
    7979                    if2theta = True
     80                    if  i == 0 and 'xydata' in S.lower():
     81                        continue   # fullprof header
    8082                    if gotCcomment and S.find('*/') > -1:
    8183                        begin = False
     
    8486                        gotCcomment = True
    8587                        continue   
    86                     if S[0] in ["'",'#']:
     88                    if S[0] in ["'",'#','!']:
    8789                        continue       #ignore comments, if any
     90                    elif S.startswith('TITLE'):
     91                        continue
    8892                    else:
    8993                        begin = False
     
    122126            # or a block of comments delimited by /* and */
    123127            # or (GSAS style) each line can begin with '#'
     128            # or WinPLOTR style, a '!'
    124129            if begin:
    125130                if self.Chi or self.Wave:
     
    137142                        gotCcomment = True
    138143                        continue   
    139                     if S[0] in ["'",'#']:
     144                    if S[0] in ["'",'#','!']:
    140145                        self.comments.append(S[:-1])
    141146                        continue       #ignore comments, if any
     147                    elif  i == 0 and 'xydata' in S.lower():
     148                        continue   # fullprof header
     149                    elif S.startswith('TITLE'):
     150                        self.comments = [S]
     151                        continue
    142152                    else:
    143153                        begin = False
Note: See TracChangeset for help on using the changeset viewer.