Changeset 1908


Ignore:
Timestamp:
Jun 24, 2015 3:48:08 PM (8 years ago)
Author:
vondreele
Message:

Add save of pole figures in popLA format

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIphsGUI.py

    r1906 r1908  
    36283628                textureData['PFxyz'] = xyz
    36293629            wx.CallAfter(G2plt.PlotTexture,G2frame,data)
     3630           
     3631        def OnpopLA(event):
     3632            pfName = PhaseName
     3633            cell = generalData['Cell'][1:7]
     3634            PH = np.array(textureData['PFhkl'])
     3635            phi,beta = G2lat.CrsAng(PH,cell,SGData)
     3636            SHCoef = textureData['SH Coeff'][1]
     3637            ODFln = G2lat.Flnh(True,SHCoef,phi,beta,SGData)
     3638            pfName = PhaseName+'%d%d%d.gpf'%(PH[0],PH[1],PH[2])
     3639            dlg = wx.FileDialog(G2frame, 'Choose popLA pole figure file name', '.', pfName,
     3640                'popLA file (*.gpf)|*.gpf',wx.FD_SAVE|wx.FD_OVERWRITE_PROMPT|wx.CHANGE_DIR)
     3641            try:
     3642                if dlg.ShowModal() == wx.ID_OK:
     3643                    pfFile = dlg.GetPath()
     3644            finally:
     3645                dlg.Destroy()
     3646            print 'popLA save '+pfFile
     3647            if pfFile:
     3648                pf = open(pfFile,'w')
     3649                pf.write(PhaseName+'\n')
     3650                str = ' %d%d%d   5.0 90.0  5.0360.0 1 1 2 1 3  100    1'%(PH[0],PH[1],PH[2])
     3651                pf.write(str+'\n')
     3652                Psi,Gam = np.mgrid[0:19,0:72]
     3653                Psi = Psi.flatten()*5.
     3654                Gam = Gam.flatten()*5.
     3655                Z = np.array(G2lat.polfcal(ODFln,SamSym[textureData['Model']],Psi,Gam)*100.,dtype='int')
     3656                Z = np.where(Z>0,Z,0)
     3657                Z = np.where(Z<9999,Z,9999)
     3658                for i in range(76):
     3659                    iBeg = i*18
     3660                    iFin = iBeg+18
     3661                    np.savetxt(pf,Z[iBeg:iFin],fmt='%4d',newline='')
     3662                    pf.write('\n')               
     3663                pf.close()
     3664                print ' popLA %d %d %d pole figure saved to %s'%(PH[0],PH[1],PH[2],pfFile)
    36303665
    36313666        def SHPenalty(Penalty):
     
    37253760        mainSizer.Add(shSizer,0,0)
    37263761        mainSizer.Add((0,5),0)
    3727         PTSizer = wx.FlexGridSizer(0,4,5,5)
     3762        PTSizer = wx.FlexGridSizer(0,5,5,5)
    37283763        PTSizer.Add(wx.StaticText(Texture,-1,' Texture plot type: '),0,WACV)
    37293764        choices = ['Axial pole distribution','Pole figure','Inverse pole figure','3D pole distribution']           
     
    37383773            projSel.Bind(wx.EVT_COMBOBOX,OnProjSel)
    37393774            PTSizer.Add(projSel,0,WACV)
     3775            PTSizer.Add((0,5),0)
    37403776        if textureData['PlotType'] in ['Pole figure','Axial pole distribution','3D pole distribution']:
    37413777            PTSizer.Add(wx.StaticText(Texture,-1,' Pole figure HKL: '),0,WACV)
     
    37573793            colorSel.Bind(wx.EVT_COMBOBOX,OnColorSel)
    37583794            PTSizer.Add(colorSel,0,WACV)
     3795            popLA = wx.Button(Texture,-1,"Make popLA file")
     3796            popLA.Bind(wx.EVT_BUTTON, OnpopLA)
     3797            if 'Inverse' not in textureData['PlotType']:
     3798                PTSizer.Add(popLA,0,WACV)
    37593799        mainSizer.Add(PTSizer,0,WACV)
    37603800        mainSizer.Add((0,5),0)
Note: See TracChangeset for help on using the changeset viewer.