Changeset 1947


Ignore:
Timestamp:
Jul 24, 2015 2:55:09 PM (8 years ago)
Author:
vondreele
Message:

do export of pole figures & inverse pole figures as csv files (can be read by Excel).
fix some errors in texture calcs. - mostly numpy/nonnumpy issues

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIlattice.py

    r1945 r1947  
    11291129    import pytexture as ptx
    11301130    if SGLaue in ['m3','m3m']:
    1131         if 'float' in str(type(phi)):
     1131        if 'array' in str(type(phi)) and np.any(phi.shape):
    11321132            Kcl = np.zeros_like(phi)
    11331133        else:
     
    11351135        for j in range(0,L+1,4):
    11361136            im = j/4
    1137             if 'float' in str(type(phi)):
     1137            if 'array' in str(type(phi)) and np.any(phi.shape):
    11381138                pcrs = ptx.pyplmpsi(L,j,len(phi),phi)[0]
    11391139            else:
    1140                 pcrs,dum = ptx.pyplmpsi(L,j,1,phi)
    1141             Kcl += BOH['L='+str(L)][N-1][im]*pcrs*cosd(j*beta)       
     1140                pcrs = ptx.pyplmpsi(L,j,1,phi)[0]
     1141            Kcl += BOH['L=%d'%(L)][N-1][im]*pcrs*cosd(j*beta)       
    11421142    else:
    1143         if 'float' in str(type(phi)):
     1143        if 'array' in str(type(phi)) and np.any(phi.shape):
    11441144            pcrs = ptx.pyplmpsi(L,N,len(phi),phi)[0]
    11451145        else:
    1146             pcrs,dum = ptx.pyplmpsi(L,N,1,phi)
     1146            pcrs = ptx.pyplmpsi(L,N,1,phi)[0]
    11471147        pcrs *= RSQ2PI
    11481148        if N:
     
    11631163    'needs doc string'
    11641164    import pytexture as ptx
    1165     if 'float' in str(type(psi)):
     1165    if 'array' in str(type(psi)) and np.any(psi.shape):
     1166        psrs,dpdps = ptx.pyplmpsi(L,M,len(psi),psi)
     1167    else:
    11661168        psrs,dpdps = ptx.pyplmpsi(L,M,1,psi)
    1167     else:
    1168         psrs,dpdps = ptx.pyplmpsi(L,M,len(psi),psi)
    11691169    psrs *= RSQ2PI
    11701170    dpdps *= RSQ2PI
     
    11951195        Kcl = 0.0
    11961196        for j in range(0,L+1,4):
    1197             im = j/4+1
     1197            im = j/4
    11981198            pcrs,dum = ptx.pyplmpsi(L,j,1,phi)
    1199             Kcl += BOH['L='+str(L)][N-1][im-1]*pcrs*cosd(j*beta)       
     1199            Kcl += BOH['L=%d'%(L)][N-1][im]*pcrs*cosd(j*beta)       
    12001200    else:
    12011201        pcrs,dum = ptx.pyplmpsi(L,N,1,phi)
     
    12501250            Kcl = 0.0
    12511251            for j in range(0,l+1,4):
    1252                 im = j/4+1
     1252                im = j/4
    12531253                pcrs,dum = ptx.pyplmpsi(l,j,1,phi)
    1254                 Kcl += BOH['L='+str(l)][n-1][im-1]*pcrs*cosd(j*beta)       
     1254                Kcl += BOH['L='+str(l)][n-1][im]*pcrs*cosd(j*beta)       
    12551255        else:                #all but cubic
    12561256            pcrs,dum = ptx.pyplmpsi(l,n,1,phi)
     
    13071307                Kcl = 0.0
    13081308                for j in range(0,l+1,4):
    1309                     im = j/4+1
     1309                    im = j/4
    13101310                    pcrs,dum = ptx.pyplmpsi(l,j,len(beta),phi)
    1311                     Kcl += BOH['L='+str(l)][n-1][im-1]*pcrs*cosd(j*beta)       
     1311                    Kcl += BOH['L=%d'%(l)][n-1][im]*pcrs*cosd(j*beta)       
    13121312            else:                #all but cubic
    13131313                pcrs,dum = ptx.pyplmpsi(l,n,len(beta),phi)
  • trunk/GSASIIphsGUI.py

    r1945 r1947  
    6666asind = lambda x: 180.*np.arcsin(x)/np.pi
    6767acosd = lambda x: 180.*np.arccos(x)/np.pi
     68atan2d = lambda x,y: 180.*np.arctan2(y,x)/np.pi
    6869
    6970def SetPhaseWindow(mainFrame,phasePage,mainSizer):
     
    37893790                print ' popLA %d %d %d pole figure saved to %s'%(PH[0],PH[1],PH[2],pfFile)
    37903791
     3792        def OnCSV(event):
     3793            pfName = PhaseName
     3794            pfFile = ''
     3795            cell = generalData['Cell'][1:7]
     3796            if 'Inverse' in textureData['PlotType']:
     3797                SHCoef = textureData['SH Coeff'][1]
     3798                PX = np.array(textureData['PFxyz'])
     3799                gam = atan2d(PX[0],PX[1])
     3800                xy = np.sqrt(PX[0]**2+PX[1]**2)
     3801                xyz = np.sqrt(PX[0]**2+PX[1]**2+PX[2]**2)
     3802                psi = asind(xy/xyz)
     3803                IODFln = G2lat.Glnh(True,SHCoef,psi,gam,SamSym[textureData['Model']])
     3804                pfName = PhaseName+'%d%d%dIPF.csv'%(int(PX[0]),int(PX[1]),int(PX[2]))
     3805                dlg = wx.FileDialog(G2frame, 'Choose CSV inverse pole figure file name', '.', pfName,
     3806                    'CSV file (*.csv)|*.csv',wx.FD_SAVE|wx.FD_OVERWRITE_PROMPT|wx.CHANGE_DIR)
     3807            else:   
     3808                PH = np.array(textureData['PFhkl'])
     3809                phi,beta = G2lat.CrsAng(PH,cell,SGData)
     3810                SHCoef = textureData['SH Coeff'][1]
     3811                ODFln = G2lat.Flnh(True,SHCoef,phi,beta,SGData)
     3812                pfName = PhaseName+'%d%d%dPF.csv'%(PH[0],PH[1],PH[2])
     3813                dlg = wx.FileDialog(G2frame, 'Choose CSV pole figure file name', '.', pfName,
     3814                    'CSV file (*.csv)|*.csv',wx.FD_SAVE|wx.FD_OVERWRITE_PROMPT|wx.CHANGE_DIR)
     3815            try:
     3816                if dlg.ShowModal() == wx.ID_OK:
     3817                    pfFile = dlg.GetPath()
     3818                    print 'CSV save '+pfFile
     3819            finally:
     3820                dlg.Destroy()
     3821            if pfFile:
     3822                pf = open(pfFile,'w')
     3823                pf.write('"%s"\n'%(PhaseName))
     3824                if 'Inverse' in textureData['PlotType']:
     3825                    pf.write('" %s %d %d %d inverse pole figure"\n'%(PhaseName,int(PX[0]),int(PX[1]),int(PX[2])))
     3826                    P,R = np.mgrid[0:19,0:72]
     3827                    pf.write('"phi/beta",')
     3828                    np.savetxt(pf,np.linspace(0.,90.,19,True),fmt='%10.4f,',newline='')
     3829                    pf.write('\n')
     3830                    P = P.flatten()*5.
     3831                    R = R.flatten()*5.
     3832                    Z = G2lat.invpolfcal(IODFln,SGData,P,R)
     3833                    Z = np.reshape(Z,(19,72)).T
     3834                    for i,row in enumerate(Z):
     3835                        pf.write('%8d,  '%(i*5))
     3836                        np.savetxt(pf,row,fmt='%10.4f,',newline='')
     3837                        pf.write('\n')               
     3838                    pf.close()
     3839                    print ' %s %d %d %d inverse pole figure saved to %s'%(PhaseName,int(PX[0]),int(PX[1]),int(PX[2]),pfFile)
     3840                else:
     3841                    pf.write('" %s %d %d %d pole figure"\n'%(PhaseName,PH[0],PH[1],PH[2]))
     3842                    Psi,Gam = np.mgrid[0:19,0:72]
     3843                    pf.write('"psi/gam",')
     3844                    np.savetxt(pf,np.linspace(0.,90.,19,True),fmt='%10.4f,',newline='')
     3845                    pf.write('\n')
     3846                    Psi = Psi.flatten()*5.
     3847                    Gam = Gam.flatten()*5.
     3848                    Z = np.array(G2lat.polfcal(ODFln,SamSym[textureData['Model']],Psi,Gam))
     3849                    Z = np.reshape(Z,(19,72)).T
     3850                    for i,row in enumerate(Z):
     3851                        pf.write('%8d, '%(i*5))
     3852                        np.savetxt(pf,row,fmt='%10.4f,',newline='')
     3853                        pf.write('\n')               
     3854                    pf.close()
     3855                    print ' %s %d %d %d pole figure saved to %s'%(PhaseName,PH[0],PH[1],PH[2],pfFile)
     3856
    37913857        def SHPenalty(Penalty):
    37923858           
     
    39183984            colorSel.Bind(wx.EVT_COMBOBOX,OnColorSel)
    39193985            PTSizer.Add(colorSel,0,WACV)
    3920             if 'Inverse' not in textureData['PlotType']:
    3921                 popLA = wx.Button(Texture,-1,"Make popLA file")
    3922                 popLA.Bind(wx.EVT_BUTTON, OnpopLA)
     3986            if 'figure' in textureData['PlotType']:
     3987                popLA = wx.Button(Texture,-1,"Make CSV file")
     3988                popLA.Bind(wx.EVT_BUTTON, OnCSV)
    39233989                PTSizer.Add(popLA,0,WACV)
    39243990        mainSizer.Add(PTSizer,0,WACV)
Note: See TracChangeset for help on using the changeset viewer.