Changeset 44


Ignore:
Timestamp:
Mar 24, 2010 3:14:08 PM (14 years ago)
Author:
vondreel
Message:

make numpy arrays for powder patterns, etc.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIIO.py

    r38 r44  
    1111# needed for MAR345
    1212import os.path as ospath
    13 # determine a binary path pased on the host OS and the python version, path is relative to
     13# determine a binary path passed on the host OS and the python version, path is relative to
    1414# location of this file
    1515if sys.platform == "win32":
     
    206206                data = S.split()
    207207                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
    211210                    Fosq = float(data[Fosqpos])
    212211                    if sigpos != -1:
     
    224223                    HKLmax = [max(h,HKLmax[0]),max(k,HKLmax[1]),max(l,HKLmax[2])]
    225224                    FoMax = max(FoMax,Fosq)
    226                     HKLref.append([h,k,l,Fosq,sigFosq,Fcsq,0,0,0])                 #room for Fc, Fcp, Fcpp & phase
     225                    HKLref.append([HKL,Fosq,sigFosq,Fcsq,0,0,0])                 #room for Fc, Fcp, Fcpp & phase
    227226            S = File.readline()
    228227    else:                   #dumb h,k,l,Fo,sigFo .hkl file
    229228        while S:
    230229            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
    234232            Fo = float(Fo)
    235233            sigFo = float(sigFo)
     
    237235            HKLmax = [max(h,HKLmax[0]),max(k,HKLmax[1]),max(l,HKLmax[2])]
    238236            FoMax = max(FoMax,Fo)
    239             HKLref.append([h,k,l,Fo**2,2.*Fo*sigFo,0,0,0,0])                 #room for Fc, Fcp, Fcpp & phase
     237            HKLref.append([HKL,Fo**2,2.*Fo*sigFo,0,0,0,0])                 #room for Fc, Fcp, Fcpp & phase
    240238            S = File.readline()
    241239    File.close()
     
    250248    DataType: powder data type, e.g. "PXC" for Powder X-ray CW data
    251249    returns: list [x,y,e,yc,yb]
    252     x: array of x-axis values
    253     y: array of powder pattern intensities
    254     w: array of w=sig(intensity)^2 values
    255     yc: array of calc. intensities (zero)
    256     yb: array of calc. background (zero)
    257     yd: array of obs-calc profiles
     250    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
    258256    '''
    259257    print 'Reading: '+filename
     
    277275    y = []
    278276    w = []
    279     yc = []
    280     yb = []
    281     yd = []
    282277    S = File.readline()
    283278    while S and S[:4] != 'BANK':
     
    294289            y.append(float(vals[1]))
    295290            w.append(1.0/float(vals[2])**2)
    296         yc.append(0.0)
    297         yb.append(0.0)
    298         yd.append(0.0)
    299291        S = File.readline()
    300292    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)]
    302295   
    303296def GetFXYdata(filename,Pos,Bank,DataType):
     
    307300    y = []
    308301    w = []
    309     yc = []
    310     yb = []
    311     yd = []
    312302    S = File.readline()
    313303    while S and S[:4] != 'BANK':
     
    325315            w.append(1.0)
    326316        S = File.readline()
    327         yc.append(0.0)
    328         yb.append(0.0)
    329         yd.append(0.0)
    330317    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)]
    332320   
    333321def GetESDdata(filename,Pos,Bank,DataType):
     
    344332    y = []
    345333    w = []
    346     yc = []
    347     yb = []
    348     yd = []
    349334    S = File.readline()
    350335    j = 0
     
    361346                y.append(0.0)
    362347                w.append(1.0)
    363             yc.append(0.0)
    364             yb.append(0.0)
    365             yd.append(0.0)
    366348            j += 1
    367349        S = File.readline()
    368350    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)]
    370353
    371354def GetSTDdata(filename,Pos,Bank,DataType):
     
    383366    y = []
    384367    w = []
    385     yc = []
    386     yb = []
    387     yd = []
    388368    S = File.readline()
    389369    j = 0
     
    403383                y.append(yi)
    404384                w.append(1.0/ei**2)
    405                 yc.append(0.0)
    406                 yb.append(0.0)
    407                 yd.append(0.0)
    408385        S = File.readline()
    409386    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)]
    411389   
    412390def GetGEsumData(filename):
     
    559537        row += 1
    560538        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]}
    562540    return head,data,size,image
     541   
    563542    File.close()   
    564543
     
    575554            datum = data[0]
    576555            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'
    577561            if 'PKS' not in datum[0]:
    578562                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.