Changeset 2041


Ignore:
Timestamp:
Nov 9, 2015 1:20:47 PM (6 years ago)
Author:
vondreele
Message:

enter space group (R -3 c) for Alumina image calibrant - gives better set of lines
some revision to SS derivatives
add ImageJ format (both big & little endian) to tiff importer

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIIO.py

    r2035 r2041  
    945945            if not imageOnly:
    946946                print 'Read 11-ID-C tiff file: ',filename
    947             image = np.array(ar.array('H',File.read(2*Npix)),dtype=np.int32)           
     947            image = np.array(ar.array('H',File.read(2*Npix)),dtype=np.int32)
     948        elif IFD[273][2][0] == 168:
     949            tifType = 'ImageJ'
     950            dataType = 0
     951            pixy = [200,200]
     952            File.seek(IFD[273][2][0])
     953            if not imageOnly:
     954                print 'Read ImageJ tiff file: ',filename
     955            image = ar.array('H',File.read(2*Npix))
     956            if '>' in byteOrd:
     957                image.byteswap()
     958            image = np.array(np.asarray(image,dtype='H'),dtype=np.int32)           
     959                   
    948960    elif sizexy == [4096,4096]:
    949961        if IFD[273][2][0] == 8:
  • trunk/GSASIImath.py

    r2040 r2041  
    991991    '''
    992992    H: array ops X hklt proj to hkl
     993    HP: array nRefBlk x ops X hklt proj to hkl
    993994    FSSdata: array 2 x atoms x waves    (sin,cos terms)
     995    Hij: array 3x3
    994996    XSSdata: array 2x3 x atoms X waves (sin,cos terms)
    995997    USSdata: array 2x6 x atoms X waves (sin,cos terms)
     
    10381040    Xmod = np.sum(XmodA+XmodB+XmodZ,axis=1)                #atoms X pos X 32; sum waves
    10391041    Xmod = np.swapaxes(Xmod,1,2)
    1040     D = H[:,3][:,nxs]*glTau[nxs,:]              #m*e*tau; ops X 32
    1041     HdotX = np.inner(HP,Xmod)+D[:,nxs,:]     #refBlk X ops x atoms X 32
     1042    D = twopi*H[:,3][:,nxs]*glTau[nxs,:]              #m*e*tau; ops X 32
     1043    HdotX = twopi*np.inner(HP,Xmod)+D[:,nxs,:]        #ops x atoms X 32
     1044    HdotXD = HdotX+D[:,nxs,:]
     1045    HdotXA = HP[:,nxs,nxs,nxs,:]*np.swapaxes(XmodA,-1,-2)[nxs,:,:,:,:]+D[:,nxs,nxs,:,nxs]  #ops x atoms x waves x 32 x xyz
     1046    HdotXB = HP[:,nxs,nxs,nxs,:]*np.swapaxes(XmodB,-1,-2)[nxs,:,:,:,:]+D[:,nxs,nxs,:,nxs]
    10421047    if Af.shape[1]:
    10431048        tauF = np.arange(1.,Af.shape[1]+1-nf)[:,nxs]*glTau  #Fwaves x 32
     
    10551060        UmodA = Au[:,:,:,:,nxs]*StauU #atoms x waves x 3x3 x 32
    10561061        UmodB = Bu[:,:,:,:,nxs]*CtauU #ditto
    1057         Umod = np.swapaxes(np.sum(UmodA+UmodB,axis=1),1,3)      #atoms x 3x3 x 32; sum waves
    1058         HbH = np.exp(-np.sum(HP[:,nxs,nxs]*np.inner(HP[:],Umod),axis=-1)) # ops x atoms x 32 add Overhauser corr.?
    1059         #derivatives??
     1062        Umod = np.swapaxes((UmodA+UmodB),2,4)      #atoms x waves x 32 x 3x3 (symmetric so I can do this!)
     1063        HuH = np.sum(HP[:,nxs,nxs,nxs]*np.inner(HP[:],Umod),axis=-1)    #ops x atoms x waves x 32
     1064        HbH = np.exp(-np.sum(HuH,axis=-2)) # ops x atoms x 32; sum waves
     1065#derivs need to be ops x atoms x waves x 6uij; ops x atoms x waves x 32 x 6uij before sum
     1066        StauU = np.rollaxis(np.rollaxis(np.swapaxes(StauU,2,4),-1),-1)
     1067        CtauU = np.rollaxis(np.rollaxis(np.swapaxes(CtauU,2,4),-1),-1)
     1068        dUdAu = Hij[:,nxs,nxs,nxs,:]*np.rollaxis(G2lat.UijtoU6(StauU),0,4)[nxs,:,:,:,:]    #ops x atoms x waves x 32 x 6Uij
     1069        dUdBu = Hij[:,nxs,nxs,nxs,:]*np.rollaxis(G2lat.UijtoU6(CtauU),0,4)[nxs,:,:,:,:]    #ops x atoms x waves x 32 x 6Uij
     1070        part1 = -HuH*np.exp(-HuH)*Fmod[:,:,nxs,:]    #ops x atoms x waves x 32
     1071        dGdMuCa = np.sum(part1[:,:,:,:,nxs]*dUdAu*np.cos(HdotXD)[:,:,nxs,:,nxs]*glWt[nxs,nxs,nxs,:,nxs],axis=-2)   #ops x atoms x waves x 6uij; G-L sum
     1072        dGdMuCb = np.sum(part1[:,:,:,:,nxs]*dUdBu*np.cos(HdotXD)[:,:,nxs,:,nxs]*glWt[nxs,nxs,nxs,:,nxs],axis=-2)
     1073        dGdMuC = np.concatenate((dGdMuCa,dGdMuCb),axis=-1)   #ops x atoms x waves x 6uij; G-L sum
     1074        dGdMuSa = np.sum(part1[:,:,:,:,nxs]*dUdAu*np.sin(HdotXD)[:,:,nxs,:,nxs]*glWt[nxs,nxs,nxs,:,nxs],axis=-2)   #ops x atoms x waves x 6uij; G-L sum
     1075        dGdMuSb = np.sum(part1[:,:,:,:,nxs]*dUdBu*np.sin(HdotXD)[:,:,nxs,:,nxs]*glWt[nxs,nxs,nxs,:,nxs],axis=-2)
     1076        dGdMuS = np.concatenate((dGdMuSa,dGdMuSb),axis=-1)   #ops x atoms x waves x 6uij; G-L sum
    10601077    else:
    10611078        HbH = np.ones_like(HdotX)
    1062     HdotXA = HP[:,nxs,nxs,nxs,:]*np.swapaxes(XmodA,-1,-2)[nxs,:,:,:,:]+D[:,nxs,nxs,:,nxs]  #ops x atoms x waves x 32 x xyz
    1063     HdotXB = HP[:,nxs,nxs,nxs,:]*np.swapaxes(XmodB,-1,-2)[nxs,:,:,:,:]+D[:,nxs,nxs,:,nxs]
    10641079    dHdXA = HP[:,nxs,nxs,nxs,:]*np.swapaxes(StauX,-1,-2)[nxs,:,:,:,:]    #ops x atoms x waves x 32 x xyz
    10651080    dHdXB = HP[:,nxs,nxs,nxs,:]*np.swapaxes(CtauX,-1,-2)[nxs,:,:,:,:]              #ditto
  • trunk/GSASIIstrMath.py

    r2040 r2041  
    912912                dFdui[iref] = 2.*SA*(dfadui[0]+dfadui[1])+2.*SB*(dfbdui[0]+dfbdui[1])
    913913                dFdua[iref] = 2.*SA*(dfadua[0]+dfadua[1])+2.*SB*(dfbdua[0]+dfbdua[1])
    914                 dFdfl[iref] = -(fas[0]+fbs[1])*dfadfl-(fbs[0]+fas[1])*dfbdfl  #array(nRef,)
     914                dFdfl[iref] = -SA*dfadfl-SB*dfbdfl  #array(nRef,)
    915915        dFdbab[iref] = 2.*fas[0]*np.array([np.sum(dfadba*dBabdA),np.sum(-dfadba*parmDict[phfx+'BabA']*SQfactor*dBabdA)]).T+ \
    916916            2.*fbs[0]*np.array([np.sum(dfbdba*dBabdA),np.sum(-dfbdba*parmDict[phfx+'BabA']*SQfactor*dBabdA)]).T
     
    12201220        fbg = fb*GfpuA[0]+fa*GfpuA[1]
    12211221       
    1222         fas = np.sum(np.sum(fag,axis=1),axis=1)
     1222        fas = np.sum(np.sum(fag,axis=1),axis=1)     # 2 x twin
    12231223        fbs = np.sum(np.sum(fbg,axis=1),axis=1)
    12241224        fax = np.array([-fot*sinp,-fotp*cosp])   #positions; 2 x twin x ops x atoms
     
    12381238            dfadua = np.array([np.sum(-Hij[it]*np.swapaxes(fag,-2,-1)[:,it,:,:,nxs],axis=-2) for it in range(nTwin)])
    12391239            dfbdua = np.array([np.sum(-Hij[it]*np.swapaxes(fbg,-2,-1)[:,it,:,:,nxs],axis=-2) for it in range(nTwin)])
    1240             # array(nTwin,2,nAtom,3) & array(2,nTwin,nAtom,6)
     1240            # array(nTwin,2,nAtom,3) & array(2,nTwin,nAtom,6) & array(2,nTwin,nAtom,12)
     1241            dfadGf = np.sum(fa[:,it,:,:,nxs,nxs]*dGdf[0][nxs,nxs,:,:,:,:]-fb[:,it,:,:,nxs,nxs]*dGdf[1][nxs,nxs,:,:,:,:],axis=1)
     1242            dfbdGf = np.sum(fb[:,it,:,:,nxs,nxs]*dGdf[0][nxs,nxs,:,:,:,:]+fa[:,it,:,:,nxs,nxs]*dGdf[1][nxs,nxs,:,:,:,:],axis=1)
    12411243            dfadGx = np.sum(fa[:,it,:,:,nxs,nxs]*dGdx[0][nxs,nxs,:,:,:,:]-fb[:,it,:,:,nxs,nxs]*dGdx[1][nxs,nxs,:,:,:,:],axis=1)
    12421244            dfbdGx = np.sum(fb[:,it,:,:,nxs,nxs]*dGdx[0][nxs,nxs,:,:,:,:]+fa[:,it,:,:,nxs,nxs]*dGdx[1][nxs,nxs,:,:,:,:],axis=1)
    1243             dfadGx = np.sum(fa[:,it,:,:,nxs,nxs]*dGdu[0][nxs,nxs,:,:,:,:]-fb[:,it,:,:,nxs,nxs]*dGdu[1][nxs,nxs,:,:,:,:],axis=1)
    1244             dfbdGx = np.sum(fb[:,it,:,:,nxs,nxs]*dGdu[0][nxs,nxs,:,:,:,:]+fa[:,it,:,:,nxs,nxs]*dGdu[1][nxs,nxs,:,:,:,:],axis=1)
    1245             # array (2,nAtom,wave,3)
     1245            dfadGu = np.sum(fa[:,it,:,:,nxs,nxs]*dGdu[0][nxs,nxs,:,:,:,:]-fb[:,it,:,:,nxs,nxs]*dGdu[1][nxs,nxs,:,:,:,:],axis=1)
     1246            dfbdGu = np.sum(fb[:,it,:,:,nxs,nxs]*dGdu[0][nxs,nxs,:,:,:,:]+fa[:,it,:,:,nxs,nxs]*dGdu[1][nxs,nxs,:,:,:,:],axis=1)
    12461247        else:
    12471248            dfadx = np.sum(twopi*Uniq[:,:3]*np.swapaxes(fax,-2,-1)[:,:,:,nxs],axis=-2)
     
    12491250            dfadua = np.sum(-Hij*np.swapaxes(fag,-2,-1)[:,:,:,nxs],axis=-2)
    12501251            dfbdua = np.sum(-Hij*np.swapaxes(fbg,-2,-1)[:,:,:,nxs],axis=-2)
    1251             # array(2,nAtom,3) & array(2,nAtom,6)
     1252            # array(2,nAtom,3) & array(2,nAtom,6) & array(2,nAtom,12)
     1253            dfadGf = np.sum(fa[:,:,:,nxs,nxs]*dGdf[0][nxs,:,:,:,:]-fb[:,:,:,nxs,nxs]*dGdf[1][nxs,:,:,:,:],axis=1)
     1254            dfbdGf = np.sum(fb[:,:,:,nxs,nxs]*dGdf[0][nxs,:,:,:,:]+fa[:,:,:,nxs,nxs]*dGdf[1][nxs,:,:,:,:],axis=1)
    12521255            dfadGx = np.sum(fa[:,:,:,nxs,nxs]*dGdx[0][nxs,:,:,:,:]-fb[:,:,:,nxs,nxs]*dGdx[1][nxs,:,:,:,:],axis=1)
    12531256            dfbdGx = np.sum(fb[:,:,:,nxs,nxs]*dGdx[0][nxs,:,:,:,:]+fa[:,:,:,nxs,nxs]*dGdx[1][nxs,:,:,:,:],axis=1)
    12541257            dfadGu = np.sum(fa[:,:,:,nxs,nxs]*dGdu[0][nxs,:,:,:,:]-fb[:,:,:,nxs,nxs]*dGdu[1][nxs,:,:,:,:],axis=1)
    12551258            dfbdGu = np.sum(fb[:,:,:,nxs,nxs]*dGdu[0][nxs,:,:,:,:]+fa[:,:,:,nxs,nxs]*dGdu[1][nxs,:,:,:,:],axis=1)   
    1256             # array (2,nAtom,wave,3)
    1257         #NB: the above have been checked against PA(1:10,1:2) in strfctr.for for al2O3!   
    12581259#        GSASIIpath.IPyBreak()
    12591260        if not SGData['SGInv'] and len(TwinLaw) == 1:   #Flack derivative
     
    12781279                2.*(fbs[0]*dfbdGu[0]+fbs[1]*dfbdGu[1])
    12791280        else:
    1280             SA = fas[0]+fas[1]
    1281             SB = fbs[0]+fbs[1]
     1281            SA = fas[0]+fas[1]      #float = A+A' (might be array[nTwin])
     1282            SB = fbs[0]+fbs[1]      #float = B+B' (might be array[nTwin])
    12821283            if nTwin > 1:
    12831284                dFdfr[iref] = [2.*TwMask[it]*(SA[it]*dfadfr[0][it]+SA[it]*dfadfr[1][it]+SB[it]*dfbdfr[0][it]+SB[it]*dfbdfr[1][it])*Mdata/len(Uniq[it]) for it in range(nTwin)]
     
    12851286                dFdui[iref] = [2.*TwMask[it]*(SA[it]*dfadui[it][0]+SA[it]*dfadui[it][1]+SB[it]*dfbdui[it][0]+SB[it]*dfbdui[it][1]) for it in range(nTwin)]
    12861287                dFdua[iref] = [2.*TwMask[it]*(SA[it]*dfadua[it][0]+SA[it]*dfadua[it][1]+SB[it]*dfbdua[it][0]+SB[it]*dfbdua[it][1]) for it in range(nTwin)]
    1287                 dFdGx[iref] = [2.*TwMask[it]*(SA[it]*dfadGx[0]+SA[it]*dfadGx[1]+SB[it]*dfbdGx[0]+SB[it]*dfbdGx[1]) for it in range(nTwin)]
    1288                 dFdGu[iref] = [2.*TwMask[it]*(SA[it]*dfadGu[0]+SA[it]*dfadGu[1]+SB[it]*dfbdGu[0]+SB[it]*dfbdGu[1]) for it in range(nTwin)]
     1288                dFdGf[iref] = [2.*TwMask[it]*(fas[0][it]*dfadGf[0]+fas[1][it]*dfadGf[1]+fbs[0][it]*dfbdGf[0]+fbs[1][it]*dfbdGf[1]) for it in range(nTwin)]
     1289                dFdGx[iref] = [2.*TwMask[it]*(fas[0][it]*dfadGx[0]+fas[1][it]*dfadGx[1]+fbs[0][it]*dfbdGx[0]+fbs[1][it]*dfbdGx[1]) for it in range(nTwin)]
     1290                dFdGu[iref] = [2.*TwMask[it]*(fas[0][it]*dfadGu[0]+fas[1][it]*dfadGu[1]+fbs[0][it]*dfbdGu[0]+fbs[1][it]*dfbdGu[1]) for it in range(nTwin)]
    12891291                dFdtw[iref] = np.sum(TwMask*fas,axis=0)**2+np.sum(TwMask*fbs,axis=0)**2
    12901292               
    12911293            else:   #these are good for no twin single crystals
    12921294                dFdfr[iref] = 2.*(SA*dfadfr[0]+SA*dfadfr[1]+SB*dfbdfr[0]+SB*dfbdfr[1])*Mdata/len(Uniq) #array(nRef,nAtom)
    1293                 dFdx[iref] = 2.*(SA*dfadx[0]+SB*dfbdx[1]+SB*dfbdx[0]+SA*dfadx[1])    #array(nRef,nAtom,3)
    1294                 dFdui[iref] = 2.*(SA*dfadui[0]+SB*dfbdui[1]+SB*dfbdui[0]+SA*dfadui[1])   #array(nRef,nAtom)
    1295                 dFdua[iref] = 2.*(SA*dfadua[0]+SB*dfbdua[1]+SB*dfbdua[0]+SA*dfadua[1])    #array(nRef,nAtom,6)
    1296                 dFdfl[iref] = -(fas[0]-SB)*dfadfl-(fbs[0]+fas[1])*dfbdfl                  #array(nRef,)
    1297                 dFdGx[iref] = 2.*(SA*dfadGx[0]+SA*dfadGx[1]+SB*dfbdGx[0]+SB*dfbdGx[1])      #array(nRef,natom,nwave,6)
    1298                 dFdGu[iref] = 2.*(SA*dfadGu[0]+SA*dfadGu[1]+SB*dfbdGu[0]+SB*dfbdGu[1])      #array(nRef,natom,nwave,6)
     1295                dFdx[iref] = 2.*(SA*dfadx[0]+SA*dfadx[1]+SB*dfbdx[0]+SB*dfbdx[1])    #array(nRef,nAtom,3)
     1296                dFdui[iref] = 2.*(SA*dfadui[0]+SA*dfadui[1]+SB*dfbdui[0]+SB*dfbdui[1])   #array(nRef,nAtom)
     1297                dFdua[iref] = 2.*(SA*dfadua[0]+SA*dfadua[1]+SB*dfbdua[0]+SB*dfbdua[1])    #array(nRef,nAtom,6)
     1298                dFdfl[iref] = -SA*dfadfl-SB*dfbdfl                  #array(nRef,)               
     1299                dFdGf[iref] = 2.*(fas[0]*dfadGf[0]+fas[1]*dfadGf[1]+fbs[0]*dfbdGf[0]+SB*dfbdGf[1])      #array(nRef,natom,nwave,2)
     1300                dFdGx[iref] = 2.*(fas[0]*dfadGx[0]+fas[1]*dfadGx[1]+fbs[0]*dfbdGx[0]+SB*dfbdGx[1])      #array(nRef,natom,nwave,6)
     1301                dFdGu[iref] = 2.*(fas[0]*dfadGu[0]+fas[1]*dfadGu[1]+fbs[0]*dfbdGu[0]+SB*dfbdGu[1])      #array(nRef,natom,nwave,6)
    12991302        dFdbab[iref] = 2.*fas[0]*np.array([np.sum(dfadba*dBabdA),np.sum(-dfadba*parmDict[phfx+'BabA']*SQfactor*dBabdA)]).T+ \
    13001303            2.*fbs[0]*np.array([np.sum(dfbdba*dBabdA),np.sum(-dfbdba*parmDict[phfx+'BabA']*SQfactor*dBabdA)]).T
     
    13141317        dFdvDict[pfx+'AU13:'+str(i)] = 2.*dFdua.T[4][i]
    13151318        dFdvDict[pfx+'AU23:'+str(i)] = 2.*dFdua.T[5][i]
    1316         for j in range(XSSdata.shape[1]):
     1319        for j in range(FSSdata.shape[1]):        #loop over waves Fzero & Fwid?
     1320            dFdvDict[pfx+'Fsin:'+str(i)+':'+str(j)] = dFdGf.T[0][j][i]
     1321            dFdvDict[pfx+'Fcos:'+str(i)+':'+str(j)] = dFdGf.T[1][j][i]
     1322        for j in range(XSSdata.shape[1]):       #loop over waves 'Tzero','Xslope','Yslope','Zslope'?
    13171323            dFdvDict[pfx+'Xsin:'+str(i)+':'+str(j)] = dFdGx.T[0][j][i]
    13181324            dFdvDict[pfx+'Ysin:'+str(i)+':'+str(j)] = dFdGx.T[1][j][i]
     
    13211327            dFdvDict[pfx+'Ycos:'+str(i)+':'+str(j)] = dFdGx.T[4][j][i]
    13221328            dFdvDict[pfx+'Zcos:'+str(i)+':'+str(j)] = dFdGx.T[5][j][i]
    1323         for j in range(USSdata.shape[1]):
     1329        for j in range(USSdata.shape[1]):       #loop over waves
    13241330            dFdvDict[pfx+'U11sin:'+str(i)+':'+str(j)] = dFdGu.T[0][j][i]
    13251331            dFdvDict[pfx+'U22sin:'+str(i)+':'+str(j)] = dFdGu.T[1][j][i]
  • trunk/ImageCalibrants.py

    r1360 r2041  
    4242'Si    SRM640c':([0,],[''],[(5.4311946,5.4311946,5.4311946,90,90,90),],0,(1.,10,10)),
    4343'CeO2  SRM674b':([0,],[''],[(5.411651,5.411651,5.411651,90,90,90),],0,(1.0,2,1)),
    44 'Al2O3 SRM676a':([3,],[''],[(4.759091,4.759091,12.991779,90,90,120),],0,(1.0,5,5)),
     44'Al2O3 SRM676a':([3,],['R -3 c'],[(4.759091,4.759091,12.991779,90,90,120),],0,(1.0,5,5)),
    4545'Ni   @ 298K':([0,],[''],[(3.52475,3.52475,3.52475,90,90,90),],0,(1.0,10,10)),
    4646'NaCl @ 298K':([0,],[''],[(5.6402,5.6402,5.6402,90,90,90),],0,(1.0,10,10)),
Note: See TracChangeset for help on using the changeset viewer.