Changeset 2212


Ignore:
Timestamp:
Apr 14, 2016 3:44:39 PM (8 years ago)
Author:
vondreele
Message:

Implement 'abc*' as one of the 'Common' cell transformations.
Transformations now transforms atom positions & Uijs
Fix problem in ImageGUI where load controls didn't update the image plot correctly.

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIgrid.py

    r2211 r2212  
    342342        self.Trans = np.eye(3)
    343343        self.Vec = np.zeros(3)
    344         self.SpGrp = phase['General']['SGData']['SpGrp']
     344        self.oldSpGrp = phase['General']['SGData']['SpGrp']
     345        self.oldSGdata = phase['General']['SGData']
     346        self.newSpGrp = self.Phase['General']['SGData']['SpGrp']
    345347        self.oldCell = phase['General']['Cell'][1:8]
    346         self.newCell = copy.copy(self.oldCell)
     348        self.newCell = self.Phase['General']['Cell'][1:8]
    347349        self.Common = 'abc'
    348350        self.Draw()
     
    365367            Obj = event.GetEventObject()
    366368            self.Common = Obj.GetValue()
    367             self.Trans = commonTrans[self.Common]
     369            if '*' in self.Common:
     370                A,B = G2lat.cell2AB(self.oldCell[:6])
     371                self.newCell[2:5] = [A[2,2],90.,90.]
     372                a,b = G2lat.cell2AB(self.newCell[:6])
     373                self.Trans = np.inner(a.T,B)    #correct!
     374                self.newSpGrp = 'P 1'
     375                SGErr,SGData = G2spc.SpcGroup(self.newSpGrp)
     376                self.Phase['General']['SGData'] = SGData
     377            else:
     378                self.Trans = commonTrans[self.Common]
    368379            OnTest(event)
    369380       
     
    373384            for fld in Flds: fld = fld.strip()
    374385            SpcGp = ' '.join(Flds)
    375             if SpcGp == self.SpGrp: #didn't change it!
     386            if SpcGp == self.newSpGrp: #didn't change it!
    376387                return
    377388            # try a lookup on the user-supplied name
     
    383394            if SGErr:
    384395                text = [G2spc.SGErrors(SGErr)+'\nSpace Group set to previous']
    385                 SGTxt.SetValue(self.SpGrp)
     396                SGTxt.SetValue(self.newSpGrp)
    386397                msg = 'Space Group Error'
    387398                Style = wx.ICON_EXCLAMATION
     
    391402                text,table = G2spc.SGPrint(SGData)
    392403                self.Phase['General']['SGData'] = SGData
    393                 self.SpGrp = SpcGp
     404                self.newSpGrp = SpcGp
    394405                SGTxt.SetValue(self.Phase['General']['SGData']['SpGrp'])
    395406                msg = 'Space Group Information'
     
    454465        sgSizer = wx.BoxSizer(wx.HORIZONTAL)
    455466        sgSizer.Add(wx.StaticText(self.panel,label='  Space group: '),0,WACV)
    456         SGTxt = wx.TextCtrl(self.panel,value=self.SpGrp,style=wx.TE_PROCESS_ENTER)
     467        SGTxt = wx.TextCtrl(self.panel,value=self.newSpGrp,style=wx.TE_PROCESS_ENTER)
    457468        SGTxt.Bind(wx.EVT_TEXT_ENTER,OnSpaceGroup)
    458469        SGTxt.Bind(wx.EVT_KILL_FOCUS,OnSpaceGroup)
  • trunk/GSASIIimgGUI.py

    r2192 r2212  
    2222import math
    2323import time
    24 import copy
    2524import sys
    2625import wx
     
    173172        G2plt.PlotExposedImage(G2frame,event=event)
    174173           
     174    def ResetThresholds():
     175        Imin = max(0.,np.min(G2frame.ImageZ))
     176        Imax = np.max(G2frame.ImageZ)
     177        data['range'] = [(Imin,Imax),[Imin,Imax]]
     178        masks['Thresholds'] = [(Imin,Imax),[Imin,Imax]]
     179        MaxSizer.GetChildren()[2].Window.SetValue(str(int(Imax)))   #tricky
     180        MaxSizer.GetChildren()[5].Window.SetValue(str(int(Imin)))   #tricky
     181         
    175182    def OnIntegrate(event):
    176183        '''Integrate image in response to a menu event or from the AutoIntegrate
     
    358365        finally:
    359366            dlg.Destroy()
     367        G2frame.ImageZ = GetImageZ(G2frame,data)
     368        ResetThresholds()
    360369        G2plt.PlotExposedImage(G2frame,event=event)
    361370        wx.CallLater(100,UpdateImageControls,G2frame,data,masks)
     
    814823    def BackSizer():
    815824       
    816         def ResetThresholds():
    817             Imin = max(0.,np.min(G2frame.ImageZ))
    818             Imax = np.max(G2frame.ImageZ)
    819             data['range'] = [(Imin,Imax),[Imin,Imax]]
    820             masks['Thresholds'] = [(Imin,Imax),[Imin,Imax]]
    821             MaxSizer.GetChildren()[2].Window.SetValue(str(int(Imax)))   #tricky
    822             MaxSizer.GetChildren()[5].Window.SetValue(str(int(Imin)))   #tricky
    823        
    824825        def OnBackImage(event):
    825826            data['background image'][0] = backImage.GetValue()
  • trunk/GSASIIlattice.py

    r2154 r2212  
    3131########### SVN repository information ###################
    3232import math
     33import copy
     34import sys
     35import random as ran
    3336import numpy as np
    3437import numpy.linalg as nl
     
    225228    Uij = np.inner(Trans,np.inner(U6toUij(U6),Trans))
    226229    return UijtoU6(Uij)
    227            
     230   
     231def TransformPhase(oldPhase,newPhase,Trans,Vec):
     232    '''Transform atoms from oldPhase to newPhase by Trans & Vec
     233   
     234    :param oldPhase: dict G2 phase info for old phase
     235    :param newPhase: dict G2 phase info for new phase; with new cell & space group
     236            atoms are from oldPhase & will be transformed
     237    :param Trans: array transformation matrix
     238    :param Vec: array transformation vector
     239    '''
     240   
     241    cx,ct,cs,cia = oldPhase['General']['AtomPtrs']
     242    SGData = newPhase['General']['SGData']
     243    invTrans = nl.inv(Trans)
     244    newAtoms = FillUnitCell(oldPhase)
     245    for atom in newAtoms:
     246        atom[cx:cx+3] = TransformXYZ(atom[cx:cx+3],invTrans.T,Vec)
     247        if atom[cia] == 'A':
     248            atom[cia+2:cia+8] = TransformU6(atom[cia+2:cia+8],invTrans)
     249        atom[cs:cs+2] = G2spc.SytSym(atom[cx:cx+3],SGData)
     250        atom[cia+8] = ran.randint(0,sys.maxint)
     251    newPhase['Atoms'] = newAtoms
     252#   GetUnique(newPhase)
     253    return newPhase
     254   
     255   
     256def FillUnitCell(Phase):
     257    atomData = copy.deepcopy(Phase['Atoms'])
     258    nAtoms = len(atomData)
     259    SGData = Phase['General']['SGData']
     260    cx,ct,cs,cia = Phase['General']['AtomPtrs']
     261    for atom in atomData[:nAtoms]:
     262        XYZ = np.array(atom[cx:cx+3])
     263        if atom[cia] == 'A':
     264            Uij = atom[cia+2:cia+8]
     265            result = G2spc.GenAtom(XYZ,SGData,False,Uij,True)
     266            for item in result:
     267                atom[cx:cx+3] = item[0]
     268                atom[cia+2:cia+8] = item[1]
     269                atomData.append(atom[:cia+9])  #not SS stuff
     270        else:
     271            result = G2spc.GenAtom(XYZ,SGData,False,Move=True)
     272            for item in result:
     273                atom[cx:cx+3] = item[0]
     274                atomData.append(atom[:cia+9])  #not SS stuff
     275    return atomData
     276       
     277def GetUnique(Phase):
     278    pass
     279#    def noDuplicate(xyz,peaks,Amat):
     280#        if True in [np.allclose(np.inner(Amat,xyz),np.inner(Amat,peak),atol=0.5) for peak in peaks]:
     281#            return False
     282#        return True
     283#                           
     284#    generalData = data['General']
     285#    cell = generalData['Cell'][1:7]
     286#    Amat,Bmat = G2lat.cell2AB(generalData['Cell'][1:7])
     287#    A = G2lat.cell2A(cell)
     288#    SGData = generalData['SGData']
     289#    mapPeaks = data['Map Peaks']
     290#    Indx = {}
     291#    XYZ = {}
     292#    for ind in Ind:
     293#        XYZ[ind] = np.array(mapPeaks[ind][1:4])
     294#        Indx[ind] = True
     295#    for ind in Ind:
     296#        if Indx[ind]:
     297#            xyz = XYZ[ind]
     298#            for jnd in Ind:
     299#                if ind != jnd and Indx[jnd]:                       
     300#                    Equiv = G2spc.GenAtom(XYZ[jnd],SGData,Move=True)
     301#                    xyzs = np.array([equiv[0] for equiv in Equiv])
     302#                    Indx[jnd] = noDuplicate(xyz,xyzs,Amat)
     303#    Ind = []
     304#    for ind in Indx:
     305#        if Indx[ind]:
     306#            Ind.append(ind)
     307#    return Ind
     308
     309
     310           
    228311def calc_rVsq(A):
    229312    """Compute the square of the reciprocal lattice volume (1/V**2) from A'
  • trunk/GSASIIphsGUI.py

    r2211 r2212  
    12271227            dlg.Destroy()
    12281228        phaseName = newPhase['General']['Name']
    1229         print phaseName
     1229        newPhase = G2lat.TransformPhase(data,newPhase,Trans,Vec)
    12301230        sub = G2frame.PatternTree.AppendItem(parent=
    12311231            G2gd.GetPatternTreeItemId(G2frame,G2frame.root,'Phases'),text=phaseName)
  • trunk/GSASIIplot.py

    r2211 r2212  
    126126            attribs = (wx.glcanvas.WX_GL_DOUBLEBUFFER,)
    127127            self.canvas = wx.glcanvas.GLCanvas(self,-1,attribList=attribs,**kwargs)
    128         # create GL context for wx > 2.8
     128        # create GL context
    129129        i,j= wx.__version__.split('.')[0:2]
    130130        if int(i)+int(j)/10. > 2.8:
     
    11131113        RenderDots(HKL,RC)
    11141114        time0 = time.time()
    1115         if Page.context: Page.canvas.SetCurrent(Page.context)    # wx 2.9 fix
     1115        if Page.context: Page.canvas.SetCurrent(Page.context)
    11161116        Page.canvas.SwapBuffers()
    11171117
     
    56565656                RenderBackbone(Backbone,BackboneColor,bondR)
    56575657#        print time.time()-time0
    5658         if Page.context: Page.canvas.SetCurrent(Page.context)    # wx 2.9 fix
     5658        if Page.context: Page.canvas.SetCurrent(Page.context)
    56595659        Page.canvas.SwapBuffers()
    56605660       
     
    59635963            RenderBonds(x,y,z,Bonds[iat],0.05,color)
    59645964            RenderLabel(x,y,z,'  '+atNames[iat],matRot)
    5965         if Page.context: Page.canvas.SetCurrent(Page.context)    # wx 2.9 fix
     5965        if Page.context: Page.canvas.SetCurrent(Page.context)
    59665966        Page.canvas.SwapBuffers()
    59675967
     
    63496349            if Page.labels:
    63506350                RenderLabel(x,y,z,'  '+AtNames[iat],matRot)
    6351         if Page.context: Page.canvas.SetCurrent(Page.context)    # wx 2.9 fix
     6351        if Page.context: Page.canvas.SetCurrent(Page.context)
    63526352        Page.canvas.SwapBuffers()
    63536353
Note: See TracChangeset for help on using the changeset viewer.