Changeset 3893


Ignore:
Timestamp:
Apr 12, 2019 3:35:08 PM (3 years ago)
Author:
vondreele
Message:

remove commented lines & "improve" getRhos - more numpy oriented - not faster than original despite elegance

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIImath.py

    r3888 r3893  
    36513651       
    36523652def getRhos(XYZ,rho):
    3653     ''' get scattering density at a point by 8-point interpolation
     3653    ''' get scattering density at an array of point by 8-point interpolation
    36543654    param xyz:  array coordinates to be probed Nx3
    36553655    param: rho: array copy of map (NB: don't use original!)
     
    36573657    :returns: density at xyz
    36583658    '''
    3659     rollMap = lambda rho,roll: np.roll(np.roll(np.roll(rho,roll[0],axis=0),roll[1],axis=1),roll[2],axis=2)
     3659    rollMap = lambda rho,roll: np.roll(np.roll(np.roll(rho,roll[0],axis=0),roll[1],axis=1),roll[2],axis=2)[:2,:2,:2]
    36603660    mapShape = np.array(rho.shape)
    36613661    mapStep = 1./mapShape
    36623662    X = XYZ%1.    #get into unit cell
    36633663    I = np.array(np.rint(X*mapShape),dtype='int')
    3664     R = []
     3664    R = np.zeros(len(XYZ))
    36653665    for i,x in enumerate(X):
    36663666        D = x-I[i]*mapStep         #position inside map cell
    3667         D12 = D[0]*D[1]
    3668         D13 = D[0]*D[2]
    3669         D23 = D[1]*D[2]
    3670         D123 = np.prod(D)
    36713667        Rho = rollMap(rho,-I[i])    #shifts map so point is in corner
    3672         R.append(Rho[0,0,0]*(1.-np.sum(D))+Rho[1,0,0]*D[0]+Rho[0,1,0]*D[1]+Rho[0,0,1]*D[2]+  \
    3673             Rho[1,1,1]*D123+Rho[0,1,1]*(D23-D123)+Rho[1,0,1]*(D13-D123)+Rho[1,1,0]*(D12-D123)+  \
    3674             Rho[0,0,0]*(D12+D13+D23-D123)-Rho[0,0,1]*(D13+D23-D123)-    \
    3675             Rho[0,1,0]*(D23+D12-D123)-Rho[1,0,0]*(D13+D12-D123))
     3668        RIJ = Rho[0,:2,:2]*(1.-D[0])
     3669        RI = RIJ[0]*(1.-D[1])+RIJ[1]*D[1]
     3670        R[i] = RI[0]*(1.-D[2])+RI[1]*D[2]
    36763671    return R
    36773672       
  • trunk/GSASIIplot.py

    r3892 r3893  
    87078707                img, (width, height) = agg.print_to_buffer()
    87088708                Zimg = np.frombuffer(img, np.uint8).reshape((height, width, 4))
    8709 #                Zimg[:,:,3] = 128           #sets alpha to 25%
    87108709                RenderViewPlane(msize*eplane,Zimg,width,height)
    87118710               
    8712 #        print time.time()-time0
    87138711        try:
    87148712            if Page.context: Page.canvas.SetCurrent(Page.context)
Note: See TracChangeset for help on using the changeset viewer.