Changeset 721


Ignore:
Timestamp:
Aug 19, 2012 2:13:13 PM (13 years ago)
Author:
vondreele
Message:

add dist/angle calc for map peaks
unique peaks selects unique set from selected map PeaksUnique?
peaks falling near special positions are corrected to be on special position

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified trunk/GSASIIgrid.py

    r715 r721  
    3939
    4040[ wxID_FOURCALC, wxID_FOURSEARCH, wxID_FOURCLEAR, wxID_PEAKSMOVE, wxID_PEAKSCLEAR,
    41     wxID_CHARGEFLIP, wxID_PEAKSUNIQUE, wxID_PEAKSDELETE,
    42 ] = [wx.NewId() for item in range(8)]
     41    wxID_CHARGEFLIP, wxID_PEAKSUNIQUE, wxID_PEAKSDELETE, wxID_PEAKSDA,
     42] = [wx.NewId() for item in range(9)]
    4343
    4444[ wxID_PWDRADD, wxID_HKLFADD, wxID_DATADELETE,
     
    614614        self.MapPeaksEdit.Append(id=wxID_PEAKSMOVE, kind=wx.ITEM_NORMAL,text='Move peaks',
    615615            help='Move selected peaks to atom list')
     616        self.MapPeaksEdit.Append(id=wxID_PEAKSDA, kind=wx.ITEM_NORMAL,text='Calc dist/ang',
     617            help='Calculate distance or angle for selection')
    616618        self.MapPeaksEdit.Append(id=wxID_PEAKSUNIQUE, kind=wx.ITEM_NORMAL,text='Unique peaks',
    617             help='Reduce map peak list to unique set')
     619            help='Select unique set')
    618620        self.MapPeaksEdit.Append(id=wxID_PEAKSDELETE, kind=wx.ITEM_NORMAL,text='Delete peaks',
    619621            help='Delete selected peaks')
     
    624626       
    625627    def _init_ctrls(self, parent,name=None,size=None,pos=None):
    626         wx.Frame.__init__(self,parent=parent,style=wx.DEFAULT_FRAME_STYLE ^ wx.CLOSE_BOX,
     628        wx.Frame.__init__(self,parent=parent,
     629            style=wx.DEFAULT_FRAME_STYLE | wx.FRAME_FLOAT_ON_PARENT ^ wx.CLOSE_BOX,
    627630            size=size,pos=pos,title='GSAS-II data display')
    628631        self._init_menus()
  • TabularUnified trunk/GSASIImath.py

    r709 r721  
    796796            Rcf = 100.
    797797            break
     798    del MEhkl,Emask,DEhkl,CErho,CEsig
    798799    np.seterr(**old)
    799800    print ' Charge flip time: %.4f'%(time.time()-time0),'no. elements: %d'%(Ehkl.size)
     801    CErho = np.real(fft.fftn(fft.fftshift(CEhkl)))
    800802    print ' No.cycles = ',Ncyc,'Residual Rcf =%8.3f%s'%(Rcf,'%')+' Map size:',CErho.shape
    801     CErho = np.real(fft.fftn(fft.fftshift(CEhkl)))
    802803    roll = findOffset(SGData,CEhkl)
    803804       
     
    821822       
    822823    def noDuplicate(xyz,peaks,Amat):
    823         if True in [np.allclose(np.inner(Amat,xyz),np.inner(Amat,peak),atol=0.5) for peak in peaks]:
     824        XYZ = np.inner(Amat,xyz)
     825        if True in [np.allclose(XYZ,np.inner(Amat,peak),atol=0.5) for peak in peaks]:
    824826            print ' Peak',xyz,' <0.5A from another peak'
    825827            return False
    826828        return True
    827                        
     829                           
     830    def fixSpecialPos(xyz,SGData,Amat):
     831        equivs = G2spc.GenAtom(xyz,SGData,Move=True)
     832        X = []
     833        xyzs = [equiv[0] for equiv in equivs]
     834        for x in xyzs:
     835            if np.sqrt(np.sum(np.inner(Amat,xyz-x)**2,axis=0))<0.5:
     836                X.append(x)
     837        if len(X) > 1:
     838            return np.average(X,axis=0)
     839        else:
     840            return xyz
     841       
    828842    def findRoll(rhoMask,mapHalf):
    829843        indx = np.array(ma.nonzero(rhoMask)).T
     
    906920            if keepDup:
    907921                if noDuplicate(peak,peaks,Amat):
     922                    peak = fixSpecialPos(peak,SGData,Amat)
    908923                    peaks.append(peak)
    909924                    mags.append(x1[0])
     
    912927                mags.append(x1[0])
    913928            GoOn = Pgbar.Update(len(peaks),newmsg='%s%d'%('No. Peaks found =',len(peaks)))[0]
    914             if not GoOn or len(peaks) > 300:
     929            if not GoOn or len(peaks) > 500:
    915930                break
    916931        rho[rMM[0]:rMP[0],rMM[1]:rMP[1],rMM[2]:rMP[2]] = peakFunc(x1,rX,rY,rZ,rhoPeak,res,SGData['SGLaue'])
     
    919934
    920935def PeaksUnique(data,Ind):
     936
     937    def noDuplicate(xyz,peaks,Amat):
     938        if True in [np.allclose(np.inner(Amat,xyz),np.inner(Amat,peak),atol=0.5) for peak in peaks]:
     939            return False
     940        return True
     941                           
    921942    generalData = data['General']
    922943    cell = generalData['Cell'][1:7]
     
    925946    SGData = generalData['SGData']
    926947    mapPeaks = data['Map Peaks']
     948    Indx = {}
     949    XYZ = {}
    927950    for ind in Ind:
    928         XYZ = np.array(mapPeaks[ind][1:])                       
    929         Equiv = G2spc.GenAtom(XYZ,SGData,Move=True)[1:]     #remove self
    930         for equiv in Equiv:                                 #special position fixer
    931                 Dx = XYZ-np.array(equiv[0])
    932                 dist = np.sqrt(np.sum(np.inner(Amat,Dx)**2,axis=0))
    933                 if dist < 0.5:
    934                     print equiv[0],Dx,dist
    935                     mapPeaks[ind][1:] -= Dx/2.
     951        XYZ[ind] = np.array(mapPeaks[ind][1:])
     952        Indx[ind] = True
     953    for ind in Ind:
     954        if Indx[ind]:
     955            xyz = XYZ[ind]
     956            for jnd in Ind:
     957                if ind != jnd and Indx[jnd]:                       
     958                    Equiv = G2spc.GenAtom(XYZ[jnd],SGData,Move=True)
     959                    xyzs = np.array([equiv[0] for equiv in Equiv])
     960                    Indx[jnd] = noDuplicate(xyz,xyzs,Amat)
     961    Ind = []
     962    for ind in Indx:
     963        if Indx[ind]:
     964            Ind.append(ind)
     965    return Ind
  • TabularUnified trunk/GSASIIphsGUI.py

    r719 r721  
    4545
    4646class SymOpDialog(wx.Dialog):
    47     def __init__(self,parent,SGData,New=True):
     47    def __init__(self,parent,SGData,New=True,ForceUnit=False):
    4848        wx.Dialog.__init__(self,parent,-1,'Select symmetry operator',
    4949            pos=wx.DefaultPosition,style=wx.DEFAULT_DIALOG_STYLE)
     
    5151        self.SGData = SGData
    5252        self.New = New
    53         self.OpSelected = [0,0,0,[0,0,0],False]
     53        self.Force = ForceUnit
     54        self.OpSelected = [0,0,0,[0,0,0],False,False]
    5455        mainSizer = wx.BoxSizer(wx.VERTICAL)
     56        if ForceUnit:
     57            choice = ['No','Yes']
     58            self.force = wx.RadioBox(panel,-1,'Force to unit cell?',choices=choice)
     59            self.force.Bind(wx.EVT_RADIOBOX, self.OnOpSelect)
     60            mainSizer.Add(self.force,0,wx.ALIGN_CENTER_VERTICAL)
    5561        mainSizer.Add((5,5),0)
    5662        if SGData['SGInv']:
     
    124130        if self.New:
    125131            self.OpSelected[4] = self.new.GetSelection()
     132        if self.Force:
     133            self.OpSelected[5] = self.force.GetSelection()
    126134
    127135    def GetSelection(self):
     
    14291437            try:
    14301438                if dlg.ShowModal() == wx.ID_OK:
    1431                     Inv,Cent,Opr,Cell,New = dlg.GetSelection()
     1439                    Inv,Cent,Opr,Cell,New,Force = dlg.GetSelection()
    14321440                    Cell = np.array(Cell)
    14331441                    cent = SGData['SGCen'][Cent]
     
    19651973            try:
    19661974                if dlg.ShowModal() == wx.ID_OK:
    1967                     Inv,Cent,Opr,Cell,New = dlg.GetSelection()
     1975                    Inv,Cent,Opr,Cell,New,Force = dlg.GetSelection()
    19681976                    Cell = np.array(Cell)
    19691977                    cent = SGData['SGCen'][Cent]
     
    20102018            try:
    20112019                if dlg.ShowModal() == wx.ID_OK:
    2012                     Inv,Cent,Opr,Cell,New = dlg.GetSelection()
     2020                    Inv,Cent,Opr,Cell,New,Force = dlg.GetSelection()
    20132021                    Cell = np.array(Cell)
    20142022                    cent = SGData['SGCen'][Cent]
     
    39243932            Ind = MapPeaks.GetSelectedRows()
    39253933            if Ind:
    3926                 G2mth.PeaksUnique(data,Ind)
    3927                 FillMapPeaksGrid()
     3934                Ind = G2mth.PeaksUnique(data,Ind)
     3935                for r in range(MapPeaks.GetNumberRows()):
     3936                    if r in Ind:
     3937                        MapPeaks.SelectRow(r,addToSelected=True)
     3938                    else:
     3939                        MapPeaks.DeselectRow(r)
    39283940                G2plt.PlotStructure(G2frame,data)
    39293941   
     3942    def OnPeaksDA(event):
     3943        #distance, angle
     3944        indx = MapPeaks.GetSelectedRows()
     3945        if len(indx) not in [2,3]:
     3946            print '**** ERROR - wrong number of atoms for distance or angle calculation'
     3947            return
     3948        generalData = data['General']
     3949        Amat,Bmat = G2lat.cell2AB(generalData['Cell'][1:7])           
     3950        mapPeaks = data['Map Peaks']
     3951        xyz = []
     3952        for i in indx:
     3953            xyz.append(mapPeaks[i][1:4])
     3954        if len(indx) == 2:
     3955            print ' distance for atoms %s = %.3f'%(str(indx),G2mth.getRestDist(xyz,Amat))
     3956        else:
     3957            print ' angle for atoms %s = %.2f'%(str(indx),G2mth.getRestAngle(xyz,Amat))
     3958                   
     3959               
    39303960    def OnFourierMaps(event):
    39313961        generalData = data['General']
     
    39924022        mapData = generalData['Map']
    39934023        if len(mapData['rho']):
    3994             pgbar = wx.ProgressDialog('Map search','No. Peaks found =',301.0,
     4024            pgbar = wx.ProgressDialog('Map search','No. Peaks found =',501.0,
    39954025                style = wx.PD_ELAPSED_TIME|wx.PD_AUTO_HIDE|wx.PD_CAN_ABORT)
    39964026            screenSize = wx.ClientDisplayRect()
     
    40114041            G2frame.dataFrame.SetMenuBar(G2frame.dataFrame.MapPeaksMenu)
    40124042            G2frame.dataFrame.Bind(wx.EVT_MENU, OnPeaksMove, id=G2gd.wxID_PEAKSMOVE)
     4043            G2frame.dataFrame.Bind(wx.EVT_MENU, OnPeaksDA, id=G2gd.wxID_PEAKSDA)
    40134044            G2frame.dataFrame.Bind(wx.EVT_MENU, OnPeaksUnique, id=G2gd.wxID_PEAKSUNIQUE)
    40144045            G2frame.dataFrame.Bind(wx.EVT_MENU, OnPeaksDelete, id=G2gd.wxID_PEAKSDELETE)
     
    41364167            G2frame.dataFrame.SetMenuBar(G2frame.dataFrame.MapPeaksMenu)
    41374168            G2frame.dataFrame.Bind(wx.EVT_MENU, OnPeaksMove, id=G2gd.wxID_PEAKSMOVE)
     4169            G2frame.dataFrame.Bind(wx.EVT_MENU, OnPeaksDA, id=G2gd.wxID_PEAKSDA)
    41384170            G2frame.dataFrame.Bind(wx.EVT_MENU, OnPeaksUnique, id=G2gd.wxID_PEAKSUNIQUE)
    41394171            G2frame.dataFrame.Bind(wx.EVT_MENU, OnPeaksDelete, id=G2gd.wxID_PEAKSDELETE)
  • TabularUnified trunk/GSASIIplot.py

    r720 r721  
    23362336        [uBox[2],uBox[3]],[uBox[1],uBox[5]],[uBox[2],uBox[6]],[uBox[3],uBox[7]],
    23372337        [uBox[4],uBox[5]],[uBox[5],uBox[6]],[uBox[6],uBox[7]],[uBox[7],uBox[4]]])
     2338    mD = 0.1
     2339    mV = np.array([[[-mD,0,0],[mD,0,0]],[[0,-mD,0],[0,mD,0]],[[0,0,-mD],[0,0,mD]]])
     2340    mapPeakVecs = np.inner(mV,Bmat)
     2341
    23382342    uColors = [Rd,Gr,Bl,Wt, Wt,Wt,Wt,Wt, Wt,Wt,Wt,Wt]
    23392343    altDown = False
     
    24092413       
    24102414    def OnMouseMove(event):
     2415        if event.ShiftDown():           #don't want any inadvertant moves when picking
     2416            return
    24112417        newxy = event.GetPosition()
    24122418        page = getSelection()
     
    27812787
    27822788    def RenderMapPeak(x,y,z,color):
    2783         vecs = np.array([[[-.1/cell[0],0,0],[.1/cell[0],0,0]],
    2784             [[0,-.1/cell[1],0],[0,.1/cell[1],0]],
    2785             [[0,0,-.1/cell[2]],[0,0,.1/cell[2]]]])
    27862789        xyz = np.array([x,y,z])
    27872790        glEnable(GL_COLOR_MATERIAL)
     
    27902793        glPushMatrix()
    27912794        glBegin(GL_LINES)
    2792         for vec in vecs:
     2795        for vec in mapPeakVecs:
    27932796            glVertex3fv(vec[0]+xyz)
    27942797            glVertex3fv(vec[1]+xyz)
Note: See TracChangeset for help on using the changeset viewer.