Ignore:
Timestamp:
Dec 10, 2018 12:27:04 PM (4 years ago)
Author:
toby
Message:

more fullprof .dat fiddling

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/imports/G2pwd_FP.py

    r3757 r3758  
    4040        fp = open(filename,'r')
    4141        for i,S in enumerate(fp):
    42             if i > 100: break
     42            if i > 50: break
    4343            if begin:
    4444                if gotCcomment and S.find('*/') > -1:
     
    5656            try:    #look for start,step,stop card
    5757                for j,val in enumerate(vals):
    58                     num = float(val)
     58                    float(val)
    5959                    if j == 2:
    6060                        break
     
    8484        for i,S in enumerate(fp):
    8585            self.errors = 'Error reading line: '+str(i+1)
    86             # or a block of comments delimited by /* and */
    87             # or (GSAS style) each line can begin with '#' or '!'
     86            # Allow a block of comments delimited by /* and */
     87            # or (GSAS style) each comment line can begin with '#' or '!'
     88            if S.lstrip()[0] in ["'",'#','!',]:
     89                self.comments.append(S[:-1])
     90                continue       # store comments, if any
    8891            if begin:
    8992                if gotCcomment and S.find('*/') > -1:
     
    9598                    gotCcomment = True
    9699                    continue   
    97                 if S.lstrip()[0] in ["'",'#','!',]:
    98                     self.comments.append(S[:-1])
    99                     continue       #ignore comments, if any
    100                 else:
    101                     begin = False
    102             # valid line to read
     100            # look for a line with start, steps etc. in 1st 4 lines
    103101            if not steps:
    104102                vals = S.replace(',',' ').split(None,4)
     
    108106                elif len(vals) >= 3:
    109107                    try:
    110                         steps = True
    111108                        start = float(vals[0])
    112109                        step = float(vals[1])
    113110                        stop = float(vals[2])
     111                        steps = True
     112                        begin = False
    114113                        if len(vals) > 3:
    115114                            self.comments.append(vals[3][:-1])
     
    120119                    print('Skipping header line ',S)
    121120                    continue
     121            # should be a valid line to read
    122122            vals = S.split()    #data strings
    123123            try:
Note: See TracChangeset for help on using the changeset viewer.