Changeset 44
- Timestamp:
- Mar 24, 2010 3:14:08 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIIO.py
r38 r44 11 11 # needed for MAR345 12 12 import os.path as ospath 13 # determine a binary path pas ed on the host OS and the python version, path is relative to13 # determine a binary path passed on the host OS and the python version, path is relative to 14 14 # location of this file 15 15 if sys.platform == "win32": … … 206 206 data = S.split() 207 207 if data: #avoid blank lines 208 h = int(data[hpos]) 209 k = int(data[kpos]) 210 l = int(data[lpos]) 208 HKL = np.array([int(data[hpos]),int(data[kpos]),int(data[lpos])]) 209 h,k,l = HKL 211 210 Fosq = float(data[Fosqpos]) 212 211 if sigpos != -1: … … 224 223 HKLmax = [max(h,HKLmax[0]),max(k,HKLmax[1]),max(l,HKLmax[2])] 225 224 FoMax = max(FoMax,Fosq) 226 HKLref.append([ h,k,l,Fosq,sigFosq,Fcsq,0,0,0]) #room for Fc, Fcp, Fcpp & phase225 HKLref.append([HKL,Fosq,sigFosq,Fcsq,0,0,0]) #room for Fc, Fcp, Fcpp & phase 227 226 S = File.readline() 228 227 else: #dumb h,k,l,Fo,sigFo .hkl file 229 228 while S: 230 229 h,k,l,Fo,sigFo = S.split() 231 h = int(h) 232 k = int(k) 233 l = int(l) 230 HKL = np.array([int(h),int(k),int(l)]) 231 h,k,l = HKL 234 232 Fo = float(Fo) 235 233 sigFo = float(sigFo) … … 237 235 HKLmax = [max(h,HKLmax[0]),max(k,HKLmax[1]),max(l,HKLmax[2])] 238 236 FoMax = max(FoMax,Fo) 239 HKLref.append([ h,k,l,Fo**2,2.*Fo*sigFo,0,0,0,0]) #room for Fc, Fcp, Fcpp & phase237 HKLref.append([HKL,Fo**2,2.*Fo*sigFo,0,0,0,0]) #room for Fc, Fcp, Fcpp & phase 240 238 S = File.readline() 241 239 File.close() … … 250 248 DataType: powder data type, e.g. "PXC" for Powder X-ray CW data 251 249 returns: list [x,y,e,yc,yb] 252 x: array of x-axis values253 y: array of powder pattern intensities254 w: array of w=sig(intensity)^2 values255 yc: array of calc. intensities (zero)256 yb: array of calc. background (zero)257 yd: array of obs-calc profiles250 x: np.array of x-axis values 251 y: np.array of powder pattern intensities 252 w: np.array of w=sig(intensity)^2 values 253 yc: np.array of calc. intensities (zero) 254 yb: np.array of calc. background (zero) 255 yd: np.array of obs-calc profiles 258 256 ''' 259 257 print 'Reading: '+filename … … 277 275 y = [] 278 276 w = [] 279 yc = []280 yb = []281 yd = []282 277 S = File.readline() 283 278 while S and S[:4] != 'BANK': … … 294 289 y.append(float(vals[1])) 295 290 w.append(1.0/float(vals[2])**2) 296 yc.append(0.0)297 yb.append(0.0)298 yd.append(0.0)299 291 S = File.readline() 300 292 File.close() 301 return [x,y,w,yc,yb,yd] 293 N = len(x) 294 return [np.array(x),np.array(y),np.array(w),np.zeros(N),np.zeros(N),np.zeros(N)] 302 295 303 296 def GetFXYdata(filename,Pos,Bank,DataType): … … 307 300 y = [] 308 301 w = [] 309 yc = []310 yb = []311 yd = []312 302 S = File.readline() 313 303 while S and S[:4] != 'BANK': … … 325 315 w.append(1.0) 326 316 S = File.readline() 327 yc.append(0.0)328 yb.append(0.0)329 yd.append(0.0)330 317 File.close() 331 return [x,y,w,yc,yb,yd] 318 N = len(x) 319 return [np.array(x),np.array(y),np.array(w),np.zeros(N),np.zeros(N),np.zeros(N)] 332 320 333 321 def GetESDdata(filename,Pos,Bank,DataType): … … 344 332 y = [] 345 333 w = [] 346 yc = []347 yb = []348 yd = []349 334 S = File.readline() 350 335 j = 0 … … 361 346 y.append(0.0) 362 347 w.append(1.0) 363 yc.append(0.0)364 yb.append(0.0)365 yd.append(0.0)366 348 j += 1 367 349 S = File.readline() 368 350 File.close() 369 return [x,y,w,yc,yb,yd] 351 N = len(x) 352 return [np.array(x),np.array(y),np.array(w),np.zeros(N),np.zeros(N),np.zeros(N)] 370 353 371 354 def GetSTDdata(filename,Pos,Bank,DataType): … … 383 366 y = [] 384 367 w = [] 385 yc = []386 yb = []387 yd = []388 368 S = File.readline() 389 369 j = 0 … … 403 383 y.append(yi) 404 384 w.append(1.0/ei**2) 405 yc.append(0.0)406 yb.append(0.0)407 yd.append(0.0)408 385 S = File.readline() 409 386 File.close() 410 return [x,y,w,yc,yb,yd] 387 N = len(x) 388 return [np.array(x),np.array(y),np.array(w),np.zeros(N),np.zeros(N),np.zeros(N)] 411 389 412 390 def GetGEsumData(filename): … … 559 537 row += 1 560 538 pos += 4*size 561 data = {'pixelSize':(200,200),'wavelength':0.10,'distance':100.0,'center':[204.8,204.8]} 539 data = {'pixelSize':(200,200),'wavelength':0.10,'distance':100.0,'center':[204.8,204.8]} 562 540 return head,data,size,image 541 563 542 File.close() 564 543 … … 575 554 datum = data[0] 576 555 print 'load: ',datum[0] 556 if 'PWDR' in datum[0] and 'list' in str(type(datum[1][1][0])): #fix to convert old style list arrays to numpy arrays 557 X = datum[1][1] 558 X = [np.array(X[0]),np.array(X[1]),np.array(X[2]),np.array(X[3]),np.array(X[4]),np.array(X[5])] 559 datum[1] = [datum[1][0],X] 560 print 'powder data converted to numpy arrays' 577 561 if 'PKS' not in datum[0]: 578 562 if datum[0] not in ['Notebook','Controls','Phases'] and 'PWDR' not in datum[0]: #temporary fix
Note: See TracChangeset
for help on using the changeset viewer.