Changeset 2084 for trunk/GSASIImath.py


Ignore:
Timestamp:
Dec 7, 2015 1:35:58 PM (10 years ago)
Author:
vondreele
Message:

fix bug in TOF iparm reading
remove extraneous code in G2imgGUI
replace some numeric derivatives in ZigZag/Block? modulations

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified trunk/GSASIImath.py

    r2080 r2084  
    415415    def getTransMat(RXYZ,OXYZ,TXYZ,Amat):
    416416        Vec = np.inner(Amat,np.array([OXYZ-TXYZ[0],RXYZ-TXYZ[0]])).T           
    417         Vec /= np.sqrt(np.sum(Vec**2,axis=1))[:,np.newaxis]
     417        Vec /= np.sqrt(np.sum(Vec**2,axis=1))[:,nxs]
    418418        Mat2 = np.cross(Vec[0],Vec[1])      #UxV
    419419        Mat2 /= np.sqrt(np.sum(Mat2**2))
     
    447447            Vec = np.inner(Amat,TXYZ-OXYZ).T
    448448            Vec[0] += Vec[1]            #U - along bisector
    449             Vec /= np.sqrt(np.sum(Vec**2,axis=1))[:,np.newaxis]
     449            Vec /= np.sqrt(np.sum(Vec**2,axis=1))[:,nxs]
    450450            Mat2 = np.cross(Vec[0],Vec[1])      #UxV
    451451            Mat2 /= np.sqrt(np.sum(Mat2**2))
     
    996996    '''
    997997   
    998     nxs = np.newaxis
    999998    if nWaves[2]:
    1000999        if len(HP.shape) > 2:
     
    10501049                Tmm[i] += dT
    10511050                ZtauXt[iatm][i] = (Zp-Zm)[i]/(2.*dT)
    1052             for i in range(3):
    1053                 XYZmax[i] += dX
    1054                 Zp = posZigZag(glTau,Tmm,XYZmax).T
    1055                 XYZmax[i] -= 2.*dX
    1056                 Zm = posZigZag(glTau,Tmm,XYZmax).T
    1057                 XYZmax[i] += dX
    1058                 ZtauXx[iatm][i] = (Zp-Zm)[i]/(2.*dX)
     1051#            for i in range(3):
     1052#                XYZmax[i] += dX
     1053#                Zp = posZigZag(glTau,Tmm,XYZmax).T
     1054#                XYZmax[i] -= 2.*dX
     1055#                Zm = posZigZag(glTau,Tmm,XYZmax).T
     1056#                XYZmax[i] += dX
     1057#                ZtauXx[iatm][i] = (Zp-Zm)[i]/(2.*dX)
     1058            dAdX = posZigZagDerv(glTau,Tmm,XYZmax)
     1059            ZtauXx[iatm] = dAdX
    10591060        elif 'Block' in waveTypes[iatm]:
    10601061            nx = 1
     
    10681069                Tmm[i] += dT
    10691070                ZtauXt[iatm][i] = (Zp-Zm)[i]/(2.*dT)
    1070             for i in range(3):
    1071                 XYZmax[i] += dX
    1072                 Zp = posBlock(glTau,Tmm,XYZmax).T
    1073                 XYZmax[i] -= 2.*dX
    1074                 Zm = posBlock(glTau,Tmm,XYZmax).T
    1075                 XYZmax[i] += dX
    1076                 ZtauXx[iatm][i] = (Zp-Zm)[i]/(2.*dX)
     1071#            for i in range(3):
     1072#                XYZmax[i] += dX
     1073#                Zp = posBlock(glTau,Tmm,XYZmax).T
     1074#                XYZmax[i] -= 2.*dX
     1075#                Zm = posBlock(glTau,Tmm,XYZmax).T
     1076#                XYZmax[i] += dX
     1077            ZtauXx[iatm] = posBlockDerv(glTau,Tmm,XYZmax)
    10771078        tauX = np.arange(1.,nWaves[1]+1-nx)[:,nxs]*glTau  #Xwaves x ngl
    10781079        if nx:   
     
    11651166   
    11661167def posFourier(tau,psin,pcos):
    1167     A = np.array([ps[:,np.newaxis]*np.sin(2*np.pi*(i+1)*tau) for i,ps in enumerate(psin)])
    1168     B = np.array([pc[:,np.newaxis]*np.cos(2*np.pi*(i+1)*tau) for i,pc in enumerate(pcos)])
     1168    A = np.array([ps[:,nxs]*np.sin(2*np.pi*(i+1)*tau) for i,ps in enumerate(psin)])
     1169    B = np.array([pc[:,nxs]*np.cos(2*np.pi*(i+1)*tau) for i,pc in enumerate(pcos)])
    11691170    return np.sum(A,axis=0)+np.sum(B,axis=0)
    11701171   
    1171 #def posSawtooth(tau,Toff,slopes):
    1172 #    Tau = (tau-Toff)%1.
    1173 #    A = slopes[:,np.newaxis]*Tau
    1174 #    return A
    1175 #
    11761172def posZigZag(tau,Tmm,XYZmax):
    11771173    DT = Tmm[1]-Tmm[0]
     
    11801176    A = np.array([np.where(Tmm[0] < t%1. <= Tmm[1],-XYZmax+slopeUp*((t-Tmm[0])%1.),XYZmax-slopeDn*((t-Tmm[1])%1.)) for t in tau])
    11811177    return A
     1178   
     1179def posZigZagDerv(tau,Tmm,XYZmax):
     1180    DT = Tmm[1]-Tmm[0]
     1181    slopeUp = 2.*XYZmax/DT
     1182    slopeDn = 2.*XYZmax/(1.-DT)
     1183    dAdX = np.ones(3)[:,nxs]*np.array([np.where(Tmm[0] < t%1. <= Tmm[1],-1+2*(t-Tmm[0])%1./DT,1-2*(t-Tmm[1])%1./DT) for t in tau])
     1184    return dAdX
     1185   
    11821186
    11831187def posBlock(tau,Tmm,XYZmax):
    11841188    A = np.array([np.where(Tmm[0] < t%1. <= Tmm[1],-XYZmax,XYZmax) for t in tau])
    11851189    return A
     1190   
     1191def posBlockDerv(tau,Tmm,XYZmax):
     1192    dAdX = np.ones(3)[:,nxs]*np.array([np.where(Tmm[0] < t%1. <= Tmm[1],-1.,1.) for t in tau])
     1193    return dAdX
    11861194   
    11871195def fracCrenel(tau,Toff,Twid):
     
    11911199   
    11921200def fracFourier(tau,fsin,fcos):
    1193     A = np.array([fs[:,np.newaxis]*np.sin(2.*np.pi*(i+1)*tau) for i,fs in enumerate(fsin)])
    1194     B = np.array([fc[:,np.newaxis]*np.cos(2.*np.pi*(i+1)*tau) for i,fc in enumerate(fcos)])
     1201    A = np.array([fs[:,nxs]*np.sin(2.*np.pi*(i+1)*tau) for i,fs in enumerate(fsin)])
     1202    B = np.array([fc[:,nxs]*np.cos(2.*np.pi*(i+1)*tau) for i,fc in enumerate(fcos)])
    11951203    return np.sum(A,axis=0)+np.sum(B,axis=0)
    11961204   
Note: See TracChangeset for help on using the changeset viewer.