Changeset 2148
- Timestamp:
- Feb 13, 2016 1:56:05 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASII.py
r2147 r2148 956 956 similar to G2pwdGUI.OnLoad 957 957 If instprm file has multiple banks each with header #Bank n: ..., this 958 finds matching bank no. to load - rejects nonmatches.958 finds matching bank no. to load - problem with nonmatches? 959 959 960 960 :param list instLines: strings from GSAS-II parameter file; can be concatenated with ';' … … 964 964 965 965 ''' 966 if not instLines[0].startswith('#GSAS-II'): # not a valid file967 return None966 if 'GSAS-II' not in instLines[0]: # not a valid file 967 return 'Not a valid GSAS-II instprm file' 968 968 newItems = [] 969 969 newVals = [] 970 970 Found = False 971 for S in instLines: 971 il = 0 972 while il < len(instLines): 973 S = instLines[il] 972 974 if S[0] == '#': 973 continue 975 if Found: 976 break 977 if 'Bank' in S: 978 if bank == int(S.split(':')[0].split()[1]): 979 il += 1 980 S = instLines[il] 981 else: 982 il += 1 983 S = instLines[il] 984 while il < len(instLines) and '#Bank' not in S: 985 il += 1 986 if il == len(instLines): 987 return 'Bank %d not found in .instprm file'%(bank) 988 S = instLines[il] 989 continue 990 else: #a non #Bank file 991 il += 1 992 S = instLines[il] 993 Found = True 974 994 S = S.replace(' ','') 975 995 SS = S[:-1].split(';') … … 980 1000 newVals.append(float(val)) 981 1001 except ValueError: 982 newVals.append(val) 1002 newVals.append(val) 1003 il += 1 983 1004 return G2IO.makeInstDict(newItems,newVals,len(newVals)*[False,]),{} 984 1005 … … 1233 1254 if Lines is not None: 1234 1255 instParmList = self.ReadPowderInstprm(Lines,bank) #know Bank - see above 1235 if instParmList is not None:1256 if 'list' in str(type(instParmList)): 1236 1257 rd.instfile = instfile 1237 1258 rd.instmsg = 'GSAS-II file '+instfile 1238 1259 return instParmList 1260 else: 1261 rd.instmsg = instParmList #an error message 1262 return None 1239 1263 Iparm = self.ReadPowderIparm(instfile,bank,numbanks,rd) 1240 1264 if Iparm:
Note: See TracChangeset
for help on using the changeset viewer.