Changeset 484


Ignore:
Timestamp:
Feb 15, 2012 2:36:53 PM (12 years ago)
Author:
vondreele
Message:

change authorship
split GSASIIelem into a GUI & non-GUI parts
replace MsgDialogs? in GSASIIElem.py with simple prints
cleanup & refactor distance/angle/torsion calcs.

Location:
trunk
Files:
1 added
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/G2importphase.py

    r475 r484  
     1########### SVN repository information ###################
     2# $Date: 2012-02-13 11:33:35 -0600 (Mon, 13 Feb 2012) $
     3# $Author: vondreele & toby $
     4# $Revision: 482 $
     5# $URL: https://subversion.xor.aps.anl.gov/pyGSAS/trunk/G2importphase.py $
     6# $Id: G2importphase.py 482 2012-02-13 17:33:35Z vondreele $
     7########### SVN repository information ###################
    18# a set of short routines to read in phases from various file formats
    29#
  • trunk/G2importphase_CIF.py

    r469 r484  
     1########### SVN repository information ###################
     2# $Date: 2012-02-13 11:33:35 -0600 (Mon, 13 Feb 2012) $
     3# $Author: vondreele & toby $
     4# $Revision: 482 $
     5# $URL: https://subversion.xor.aps.anl.gov/pyGSAS/trunk/G2importphase_CIF.py $
     6# $Id: G2importphase_CIF.py 482 2012-02-13 17:33:35Z vondreele $
     7########### SVN repository information ###################
    18# Routines to import Phase information from CIF files
    29import sys
  • trunk/G2importphase_GPX.py

    r469 r484  
     1########### SVN repository information ###################
     2# $Date: 2012-02-13 11:33:35 -0600 (Mon, 13 Feb 2012) $
     3# $Author: vondreele & toby $
     4# $Revision: 482 $
     5# $URL: https://subversion.xor.aps.anl.gov/pyGSAS/trunk/G2importphase_GPX.py $
     6# $Id: G2importphase_GPX.py 482 2012-02-13 17:33:35Z vondreele $
     7########### SVN repository information ###################
    18# Routines to import Phase information from GSAS-II .gpx files
    29import cPickle
  • trunk/GSASIIElem.py

    r456 r484  
    11"""Element: functions for element types
    2    Copyright: 2008, Robert B. Von Dreele (Argonne National Laboratory)
     2   Copyright: 2008, Robert B. Von Dreele & Brian H. Toby (Argonne National Laboratory)
    33"""
    44########### SVN repository information ###################
     
    1010########### SVN repository information ###################
    1111
    12 import wx
    1312import math
    14 import sys
    1513import os.path
    16 import wx.lib.colourselect as wscs
    1714import GSASIIpath
    1815import numpy as np
     
    3936        FFdata = open(filename,'Ur')
    4037    except:
    41         wx.MessageBox(message="File atmdata.dat not found in directory %s" % sys.path[0],
    42             caption="No atmdata.dat file",style=wx.OK | wx.ICON_EXCLAMATION | wx.STAY_ON_TOP)
     38        print "**** ERROR - File atmdata.dat not found in directory %s" % sys.path[0]
    4339        sys.exit()
    4440    S = '1'
     
    8985        FFdata = open(filename,'Ur')
    9086    except:
    91         wx.MessageBox(message="File atmdata.dat not found in directory %s" % sys.path[0],
    92             caption="No atmdata.dat file",style=wx.OK | wx.ICON_EXCLAMATION | wx.STAY_ON_TOP)
     87        print '**** ERROR - File atmdata.dat not found in directory %s' % sys.path[0]
    9388        sys.exit()
    9489    S = '1'
     
    151146        xsec = open(filename,'Ur')
    152147    except:
    153         wx.MessageBox(message="File Xsect.dat not found in directory %s" % sys.path[0],
    154             caption="No Xsect.dat file",style=wx.OK | wx.ICON_EXCLAMATION |wx.STAY_ON_TOP)
     148        print '**** ERROR - File Xsect.dat not found in directory %s' % sys.path[0]
    155149        sys.exit()
    156150    S = '1'
     
    226220        FFdata = open(filename,'Ur')
    227221    except:
    228         wx.MessageBox(message="File atmdata.dat not found in directory %s" % sys.path[0],
    229             caption="No atmdata.dat file",style=wx.OK | wx.ICON_EXCLAMATION |wx.STAY_ON_TOP)
     222        print '**** ERROR - File atmdata.dat not found in directory %s' % sys.path[0]
    230223        sys.exit()
    231224    S = '1'
     
    387380   
    388381
    389 class PickElement(wx.Dialog):
    390     "Makes periodic table widget for picking element - caller maintains element list"
    391     Elem=None
    392     def _init_ctrls(self, prnt,oneOnly):
    393         wx.Dialog.__init__(self, id=-1, name='PickElement',
    394               parent=prnt, pos=wx.DefaultPosition,
    395               style=wx.DEFAULT_DIALOG_STYLE, title='Pick Element')
    396         import ElementTable as ET
    397         self.SetClientSize(wx.Size(770, 250))
    398        
    399         i=0
    400         for E in ET.ElTable:
    401             if oneOnly:
    402                 color=E[4]
    403             else:
    404                 color=E[6]
    405             PickElement.ElButton(self,name=E[0],
    406                pos=wx.Point(E[1]*40+25,E[2]*24+24),tip=E[3],color=color,oneOnly=oneOnly)
    407             i+=1
    408 
    409     def __init__(self, parent,oneOnly=False):
    410         self._init_ctrls(parent,oneOnly)
    411        
    412     def ElButton(self, name, pos, tip, color, oneOnly):
    413         Black = wx.Colour(0,0,0)
    414         if oneOnly:
    415             El = wscs.ColourSelect(label=name[0], parent=self,colour=color,
    416                 pos=pos, size=wx.Size(40,23), style=wx.RAISED_BORDER)
    417 #            El.SetLabel(name)
    418             El.Bind(wx.EVT_BUTTON, self.OnElButton)
    419         else:
    420             El = wx.ComboBox(choices=name, parent=self, pos=pos, size=wx.Size(40,23),
    421                 style=wx.CB_READONLY, value=name[0])
    422             El.Bind(wx.EVT_COMBOBOX,self.OnElButton)
    423        
    424         El.SetBackgroundColour(color)
    425         El.SetToolTipString(tip)
    426 
    427     def OnElButton(self, event):
    428         El = event.GetEventObject().GetLabel()
    429         self.Elem = El
    430         self.EndModal(wx.ID_OK)       
    431        
    432 class DeleteElement(wx.Dialog):
    433     "Delete element from selected set widget"
    434     def _init_ctrls(self, parent,choice):
    435         l = len(choice)-1
    436         wx.Dialog.__init__(self, id=-1, name='Delete', parent=parent,
    437               pos=wx.DefaultPosition, size=wx.Size(max(128,64+l*24), 87),
    438               style=wx.DEFAULT_DIALOG_STYLE, title='Delete Element')
    439         self.Show(True)
    440         self.SetAutoLayout(True)
    441         self.SetHelpText('Select element to delete')
    442         self.SetWindowVariant(wx.WINDOW_VARIANT_SMALL)
    443 
    444         i = 0
    445         Elem = []
    446         for Elem in choice:
    447             self.ElButton(id=-1,name=Elem,pos=wx.Point(16+i*24, 16))
    448             i+=1
    449              
    450     def __init__(self, parent,choice):
    451         DeleteElement.El = ' '
    452         self._init_ctrls(parent,choice)
    453 
    454     def ElButton(self, id, name, pos):
    455         White = wx.Colour(255, 255, 255)
    456         El = wscs.ColourSelect(label=name, parent=self, colour = White,
    457             pos=pos, size=wx.Size(24, 23), style=wx.RAISED_BORDER)
    458         El.Bind(wx.EVT_BUTTON, self.OnDeleteButton)
    459    
    460     def OnDeleteButton(self, event):
    461         DeleteElement.El=event.GetEventObject().GetLabel()
    462         self.EndModal(wx.ID_OK)
    463        
    464     def GetDeleteElement(self):
    465         return DeleteElement.El
    466        
    467 
  • trunk/GSASIIgrid.py

    r483 r484  
    4747[ wxID_DRAWATOMSTYLE, wxID_DRAWATOMLABEL, wxID_DRAWATOMCOLOR, wxID_DRAWATOMRESETCOLOR,
    4848    wxID_DRAWVIEWPOINT, wxID_DRAWTRANSFORM, wxID_DRAWDELETE, wxID_DRAWFILLCELL,
    49     wxID_DRAWADDEQUIV, wxID_DRAWFILLCOORD, wxID_DRAWDISAGL, wxID_DRAWTORSION, wxID_DRAWPLANE,
    50 ] = [wx.NewId() for _init_coll_DrawAtom_Items in range(13)]
     49    wxID_DRAWADDEQUIV, wxID_DRAWFILLCOORD, wxID_DRAWDISAGLTOR, wxID_DRAWPLANE,
     50] = [wx.NewId() for _init_coll_DrawAtom_Items in range(12)]
    5151
    5252[ wxID_IMCALIBRATE,wxID_IMRECALIBRATE,wxID_IMINTEGRATE, wxID_IMCLEARCALIB, 
     
    169169        info.Version = __version__
    170170        info.Copyright = '''
    171 Robert B. Von Dreele
     171Robert B. Von Dreele & Brian H. Toby
    172172Argonne National Laboratory(C)
    173173This product includes software developed
     
    175175Operator of Argonne National Laboratory.         '''
    176176        info.Description = '''
    177 General Structure Analysis System - II
     177General Structure Analysis System - GSAS-II
    178178'''
    179179        wx.AboutBox(info)
     
    519519        self.DrawAtomEdit.Append(id=wxID_DRAWDELETE, kind=wx.ITEM_NORMAL,text='Delete atoms',
    520520            help='Delete atoms from drawing set')
    521         self.DrawAtomCompute.Append(id=wxID_DRAWDISAGL, kind=wx.ITEM_NORMAL,text='Distances & Angles',
    522             help='Compute distances & angles for selected atoms')   
    523         self.DrawAtomCompute.Append(id=wxID_DRAWTORSION, kind=wx.ITEM_NORMAL,text='Torsion angle',
    524             help='Compute torsion angle for 4 selected atoms')   
     521        self.DrawAtomCompute.Append(id=wxID_DRAWDISAGLTOR, kind=wx.ITEM_NORMAL,text='Dist. Ang. Tors.',
     522            help='Compute distance, angle or torsion for 2-4 selected atoms')   
    525523        self.DrawAtomCompute.Append(id=wxID_DRAWPLANE, kind=wx.ITEM_NORMAL,text='Best plane',
    526             help='Compute best plane for 3+ selected atoms')   
     524            help='Compute best plane for 4+ selected atoms')   
    527525           
    528526# end of GSAS-II menu definitions
  • trunk/GSASIImapvars.py

    r425 r484  
     1########### SVN repository information ###################
    12# $Date: 2011-01-07 13:27:24 -0600 (Fri, 07 Jan 2011) $
    2 # $Author: toby $
     3# $Author: vondreele & toby $
    34# $Revision: 230 $
    45# $URL: https://subversion.xor.aps.anl.gov/pyGSAS/trunk/GSASIImapvars.py $
  • trunk/GSASIImath.py

    r477 r484  
    22########### SVN repository information ###################
    33# $Date: 2012-01-13 11:48:53 -0600 (Fri, 13 Jan 2012) $
    4 # $Author: vondreele $
     4# $Author: vondreele & toby $
    55# $Revision: 451 $
    66# $URL: https://subversion.xor.aps.anl.gov/pyGSAS/trunk/GSASIImath.py $
     
    234234    else:
    235235        return calcAngle(OxA,TxA,TxB,unitA,unitB,invA,CA,MA,TA,invB,CB,MB,TB,Amat),0.0
    236        
     236
     237def GetDistSig(Oatoms,Atoms,Amat,SGData,covData={}):
     238
     239    def calcDist(Atoms,SyOps,Amat):
     240        XYZ = []
     241        for i,atom in enumerate(Atoms):
     242            Inv,M,T,C,U = SyOps[i]
     243            XYZ.append(np.array(atom[1:4]))
     244            XYZ[-1] = Inv*(np.inner(M,np.array(XYZ[-1]))+T)+C+U
     245            XYZ[-1] = np.inner(Amat,XYZ[-1]).T
     246        V1 = XYZ[1]-XYZ[0]
     247        return np.sqrt(np.sum(V1**2))
     248       
     249    Inv = []
     250    SyOps = []
     251    names = []
     252    for i,atom in enumerate(Oatoms):
     253        names += atom[-1]
     254        Op,unit = Atoms[i][-1]
     255        inv = Op/abs(Op)
     256        m,t = SGData['SGOps'][abs(Op)%100-1]
     257        c = SGData['SGCen'][abs(Op)/100]
     258        SyOps.append([inv,m,t,c,unit])
     259    Dist = calcDist(Oatoms,SyOps,Amat)
     260   
     261    sig = -0.001
     262    if 'covMatrix' in covData:
     263        parmNames = []
     264        dx = .00001
     265        dadx = np.zeros(6)
     266        for i in range(6):
     267            ia = i/3
     268            ix = i%3
     269            Oatoms[ia][ix+1] += dx
     270            a0 = calcDist(Oatoms,SyOps,Amat)
     271            Oatoms[ia][ix+1] -= 2*dx
     272            dadx[i] = (calcDist(Oatoms,SyOps,Amat)-a0)/(2.*dx)
     273        covMatrix = covData['covMatrix']
     274        varyList = covData['varyList']
     275        DistVcov = getVCov(names,varyList,covMatrix)
     276        sig = np.sqrt(np.inner(dadx,np.inner(DistVcov,dadx)))
     277        if sig < 0.001:
     278            sig = -0.001
     279   
     280    return Dist,sig
     281
     282def GetAngleSig(Oatoms,Atoms,Amat,SGData,covData={}):
     283       
     284    def calcAngle(Atoms,SyOps,Amat):
     285        XYZ = []
     286        for i,atom in enumerate(Atoms):
     287            Inv,M,T,C,U = SyOps[i]
     288            XYZ.append(np.array(atom[1:4]))
     289            XYZ[-1] = Inv*(np.inner(M,np.array(XYZ[-1]))+T)+C+U
     290            XYZ[-1] = np.inner(Amat,XYZ[-1]).T
     291        V1 = XYZ[1]-XYZ[0]
     292        V1 /= np.sqrt(np.sum(V1**2))
     293        V2 = XYZ[1]-XYZ[2]
     294        V2 /= np.sqrt(np.sum(V2**2))
     295        V3 = V2-V1
     296        cang = min(1.,max((2.-np.sum(V3**2))/2.,-1.))
     297        return acosd(cang)
     298
     299    Inv = []
     300    SyOps = []
     301    names = []
     302    for i,atom in enumerate(Oatoms):
     303        names += atom[-1]
     304        Op,unit = Atoms[i][-1]
     305        inv = Op/abs(Op)
     306        m,t = SGData['SGOps'][abs(Op)%100-1]
     307        c = SGData['SGCen'][abs(Op)/100]
     308        SyOps.append([inv,m,t,c,unit])
     309    Angle = calcAngle(Oatoms,SyOps,Amat)
     310   
     311    sig = -0.01
     312    if 'covMatrix' in covData:
     313        parmNames = []
     314        dx = .00001
     315        dadx = np.zeros(9)
     316        for i in range(9):
     317            ia = i/3
     318            ix = i%3
     319            Oatoms[ia][ix+1] += dx
     320            a0 = calcAngle(Oatoms,SyOps,Amat)
     321            Oatoms[ia][ix+1] -= 2*dx
     322            dadx[i] = (calcAngle(Oatoms,SyOps,Amat)-a0)/(2.*dx)
     323        covMatrix = covData['covMatrix']
     324        varyList = covData['varyList']
     325        AngVcov = getVCov(names,varyList,covMatrix)
     326        sig = np.sqrt(np.inner(dadx,np.inner(AngVcov,dadx)))
     327        if sig < 0.01:
     328            sig = -0.01
     329   
     330    return Angle,sig
     331
    237332def GetTorsionSig(Oatoms,Atoms,Amat,SGData,covData={}):
    238333   
     
    277372        dx = .00001
    278373        dadx = np.zeros(12)
    279         ang = calcTorsion(Oatoms,SyOps,Amat)
    280374        for i in range(12):
    281375            ia = i/3
     
    294388    return Tors,sig
    295389       
     390def GetDATSig(Oatoms,Atoms,Amat,SGData,covData={}):
     391   
     392    def calcDist(Atoms,SyOps,Amat):
     393        XYZ = []
     394        for i,atom in enumerate(Atoms):
     395            Inv,M,T,C,U = SyOps[i]
     396            XYZ.append(np.array(atom[1:4]))
     397            XYZ[-1] = Inv*(np.inner(M,np.array(XYZ[-1]))+T)+C+U
     398            XYZ[-1] = np.inner(Amat,XYZ[-1]).T
     399        V1 = XYZ[1]-XYZ[0]
     400        return np.sqrt(np.sum(V1**2))
     401       
     402    def calcAngle(Atoms,SyOps,Amat):
     403        XYZ = []
     404        for i,atom in enumerate(Atoms):
     405            Inv,M,T,C,U = SyOps[i]
     406            XYZ.append(np.array(atom[1:4]))
     407            XYZ[-1] = Inv*(np.inner(M,np.array(XYZ[-1]))+T)+C+U
     408            XYZ[-1] = np.inner(Amat,XYZ[-1]).T
     409        V1 = XYZ[1]-XYZ[0]
     410        V1 /= np.sqrt(np.sum(V1**2))
     411        V2 = XYZ[1]-XYZ[2]
     412        V2 /= np.sqrt(np.sum(V2**2))
     413        V3 = V2-V1
     414        cang = min(1.,max((2.-np.sum(V3**2))/2.,-1.))
     415        return acosd(cang)
     416
     417    def calcTorsion(Atoms,SyOps,Amat):
     418       
     419        XYZ = []
     420        for i,atom in enumerate(Atoms):
     421            Inv,M,T,C,U = SyOps[i]
     422            XYZ.append(np.array(atom[1:4]))
     423            XYZ[-1] = Inv*(np.inner(M,np.array(XYZ[-1]))+T)+C+U
     424            XYZ[-1] = np.inner(Amat,XYZ[-1]).T
     425        V1 = XYZ[1]-XYZ[0]
     426        V2 = XYZ[2]-XYZ[1]
     427        V3 = XYZ[3]-XYZ[2]
     428        V1 /= np.sqrt(np.sum(V1**2))
     429        V2 /= np.sqrt(np.sum(V2**2))
     430        V3 /= np.sqrt(np.sum(V3**2))
     431        M = np.array([V1,V2,V3])
     432        D = nl.det(M)
     433        Ang = 1.0
     434        P12 = np.dot(V1,V2)
     435        P13 = np.dot(V1,V3)
     436        P23 = np.dot(V2,V3)
     437        Tors = acosd((P12*P23-P13)/(np.sqrt(1.-P12**2)*np.sqrt(1.-P23**2)))*D/abs(D)
     438        return Tors
     439           
     440    Inv = []
     441    SyOps = []
     442    names = []
     443    for i,atom in enumerate(Oatoms):
     444        names += atom[-1]
     445        Op,unit = Atoms[i][-1]
     446        inv = Op/abs(Op)
     447        m,t = SGData['SGOps'][abs(Op)%100-1]
     448        c = SGData['SGCen'][abs(Op)/100]
     449        SyOps.append([inv,m,t,c,unit])
     450    M = len(Oatoms)
     451    if M == 2:
     452        Val = calcDist(Oatoms,SyOps,Amat)
     453    elif M == 3:
     454        Val = calcAngle(Oatoms,SyOps,Amat)
     455    else:
     456        Val = calcTorsion(Oatoms,SyOps,Amat)
     457   
     458    sigVals = [-0.001,-0.01,-0.01]
     459    if 'covMatrix' in covData:
     460        parmNames = []
     461        dx = .00001
     462        N = M*3
     463        sig = sigVals[M-3]
     464        dadx = np.zeros(N)
     465        for i in range(N):
     466            ia = i/3
     467            ix = i%3
     468            Oatoms[ia][ix+1] += dx
     469            if M == 2:
     470                a0 = calcDist(Oatoms,SyOps,Amat)
     471            elif M == 3:
     472                a0 = calcAngle(Oatoms,SyOps,Amat)
     473            else:
     474                a0 = calcTorsion(Oatoms,SyOps,Amat)
     475            Oatoms[ia][ix+1] -= 2*dx
     476            if M == 2:
     477                dadx[i] = (calcDist(Oatoms,SyOps,Amat)-a0)/(2.*dx)               
     478            elif M == 3:
     479                dadx[i] = (calcAngle(Oatoms,SyOps,Amat)-a0)/(2.*dx)               
     480            else:
     481                dadx[i] = (calcTorsion(Oatoms,SyOps,Amat)-a0)/(2.*dx)
     482        covMatrix = covData['covMatrix']
     483        varyList = covData['varyList']
     484        Vcov = getVCov(names,varyList,covMatrix)
     485        sig = np.sqrt(np.inner(dadx,np.inner(Vcov,dadx)))
     486        if sig < sigVals[M-3]:
     487            sig = sigVals[M-3]
     488   
     489    return Val,sig
     490       
    296491   
    297492def ValEsd(value,esd=0,nTZ=False):                  #NOT complete - don't use
  • trunk/GSASIIphsGUI.py

    r483 r484  
    2020import GSASIIspc as G2spc
    2121import GSASIIElem as G2elem
     22import GSASIIElemGUI as G2elemGUI
    2223import GSASIIplot as G2plt
    2324import GSASIIgrid as G2gd
     
    818819            r,c =  event.GetRow(),event.GetCol()
    819820            if Atoms.GetColLabelValue(c) == 'Type':
    820                 PE = G2elem.PickElement(G2frame)
     821                PE = G2elemGUI.PickElement(G2frame)
    821822                if PE.ShowModal() == wx.ID_OK:
    822823                    atomData[r][c] = PE.Elem.strip()
     
    18311832            atomData[ind][col] = value
    18321833               
    1833     def OnDrawTorsion(event):
    1834         indx = drawAtoms.GetSelectedRows()
    1835         if len(indx) != 4:
    1836             print '**** ERROR - need 4 atoms for torsion calculation'
    1837             return
    1838         TorsionData = {}
    1839         ocx,oct,ocs,cia = data['General']['AtomPtrs']
    1840         drawingData = data['Drawing']
    1841         atomData = data['Atoms']
    1842 #        for atom in atomData: print atom
    1843         atomDData = drawingData['Atoms']
    1844 #        for atom in atomDData: print atom
    1845         colLabels = [drawAtoms.GetColLabelValue(c) for c in range(drawAtoms.GetNumberCols())]
    1846         cx = colLabels.index('x')
    1847         cn = colLabels.index('Name')
    1848         cid = colLabels.index('I/A')+8
    1849         xyz = []
    1850         Oxyz = []
    1851         for i,atom in enumerate(atomDData):
    1852             if i in indx:
    1853                 xyz.append([i,]+atom[cn:cn+2]+atom[cx:cx+4]) #also gets Sym Op
    1854                 id = FindAtomIndexByIDs(atomData,[atom[cid],],False)[0]
    1855                 Oxyz.append([id,]+atomData[id][cx+1:cx+4])
    1856         TorsionData['Datoms'] = xyz
    1857         TorsionData['Oatoms'] = Oxyz
    1858         generalData = data['General']
    1859         TorsionData['Name'] = generalData['Name']
    1860         TorsionData['SGData'] = generalData['SGData']
    1861         TorsionData['Cell'] = generalData['Cell'][1:] #+ volume
    1862         if 'pId' in data:
    1863             TorsionData['pId'] = data['pId']
    1864             TorsionData['covData'] = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,G2frame.root, 'Covariance'))
    1865         G2str.Torsion(TorsionData)
    1866        
    18671834    def OnDrawPlane(event):
    18681835        indx = drawAtoms.GetSelectedRows()
    1869         if len(indx) < 3:
    1870             print '**** ERROR - need 3+ atoms for plane calculation'
     1836        if len(indx) < 4:
     1837            print '**** ERROR - need 4+ atoms for plane calculation'
    18711838            return
    18721839        PlaneData = {}
     
    18861853        G2str.BestPlane(PlaneData)
    18871854   
    1888     def OnDrawDistAngle(event):
     1855    def OnDrawDAT(event):
     1856        #distance, angle, torsion
    18891857        indx = drawAtoms.GetSelectedRows()
    1890         print 'Future bond dist/angles for atoms',indx
     1858        if len(indx) not in [2,3,4]:
     1859            print '**** ERROR - wrong number of atoms for distance, angle or torsion calculation'
     1860            return
     1861        DATData = {}
     1862        ocx,oct,ocs,cia = data['General']['AtomPtrs']
     1863        drawingData = data['Drawing']
     1864        atomData = data['Atoms']
     1865        atomDData = drawingData['Atoms']
     1866        colLabels = [drawAtoms.GetColLabelValue(c) for c in range(drawAtoms.GetNumberCols())]
     1867        cx = colLabels.index('x')
     1868        cn = colLabels.index('Name')
     1869        cid = colLabels.index('I/A')+8
     1870        xyz = []
     1871        Oxyz = []
     1872        DATData['Natoms'] = len(indx)
     1873        for i in indx:
     1874            atom = atomDData[i]
     1875            xyz.append([i,]+atom[cn:cn+2]+atom[cx:cx+4]) #also gets Sym Op
     1876            id = FindAtomIndexByIDs(atomData,[atom[cid],],False)[0]
     1877            Oxyz.append([id,]+atomData[id][cx+1:cx+4])
     1878        DATData['Datoms'] = xyz
     1879        DATData['Oatoms'] = Oxyz
     1880        generalData = data['General']
     1881        DATData['Name'] = generalData['Name']
     1882        DATData['SGData'] = generalData['SGData']
     1883        DATData['Cell'] = generalData['Cell'][1:] #+ volume
     1884        if 'pId' in data:
     1885            DATData['pId'] = data['pId']
     1886            DATData['covData'] = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,G2frame.root, 'Covariance'))
     1887        G2str.DisAglTor(DATData)
    18911888               
    18921889    def UpdateDrawOptions():
     
    31473144            G2frame.dataFrame.Bind(wx.EVT_MENU, FillUnitCell, id=G2gd.wxID_DRAWFILLCELL)
    31483145            G2frame.dataFrame.Bind(wx.EVT_MENU, DrawAtomsDelete, id=G2gd.wxID_DRAWDELETE)
    3149             G2frame.dataFrame.Bind(wx.EVT_MENU, OnDrawDistAngle, id=G2gd.wxID_DRAWDISAGL)
    3150             G2frame.dataFrame.Bind(wx.EVT_MENU, OnDrawTorsion, id=G2gd.wxID_DRAWTORSION)
     3146            G2frame.dataFrame.Bind(wx.EVT_MENU, OnDrawDAT, id=G2gd.wxID_DRAWDISAGLTOR)
    31513147            G2frame.dataFrame.Bind(wx.EVT_MENU, OnDrawPlane, id=G2gd.wxID_DRAWPLANE)
    31523148            UpdateDrawAtoms()
  • trunk/GSASIIplot.py

    r483 r484  
    26942694                RenderLabel(x,y,z,atom[ct-1],radius)
    26952695            elif atom[cs+1] == 'number':
    2696                 RenderLabel(x,y,z,str(iat+1),radius)
     2696                RenderLabel(x,y,z,str(iat),radius)
    26972697            elif atom[cs+1] == 'residue' and atom[ct-1] == 'CA':
    26982698                RenderLabel(x,y,z,atom[ct-4],radius)
  • trunk/GSASIIsolve.py

    r230 r484  
    2222    print 80*'*'
    2323    print '    General Structure Analysis System-II Crystal Structure Solution'
    24     print '     by Robert B. Von Dreele, Argonne National Laboratory(C), 2010'
     24    print '              by Robert B. Von Dreele & Brian H. Toby'
     25    print '                Argonne National Laboratory(C), 2010'
    2526    print ' This product includes software developed by the UChicago Argonne, LLC,'
    2627    print '            as Operator of Argonne National Laboratory.'
  • trunk/GSASIIstruct.py

    r482 r484  
    371371    print 80*'*'
    372372    print '   General Structure Analysis System-II Crystal Structure Refinement'
    373     print '     by Robert B. Von Dreele, Argonne National Laboratory(C), 2010'
     373    print '              by Robert B. Von Dreele & Brian H. Toby'
     374    print '                Argonne National Laboratory(C), 2010'
    374375    print ' This product includes software developed by the UChicago Argonne, LLC,'
    375376    print '            as Operator of Argonne National Laboratory.'
     
    30123013            print '  %8s%10s+(%4d) %12s'%(dist[1].ljust(8),dist[2].ljust(10),dist[3],val.center(12)),line
    30133014
    3014 def Torsion(TorsionData):
    3015 
    3016     def ShowBanner(name):
    3017         print 80*'*'
    3018         print '   Torsion angle for phase '+name
    3019         print 80*'*'
    3020 
    3021     ShowBanner(TorsionData['Name'])
    3022     SGData = TorsionData['SGData']
    3023     Cell = TorsionData['Cell']
     3015def DisAglTor(DATData):
     3016    SGData = DATData['SGData']
     3017    Cell = DATData['Cell']
    30243018   
    30253019    Amat,Bmat = G2lat.cell2AB(Cell[:6])
    30263020    covData = {}
    30273021    pfx = ''
    3028     if 'covData' in TorsionData:   
    3029         covData = TorsionData['covData']
     3022    if 'covData' in DATData:   
     3023        covData = DATData['covData']
    30303024        covMatrix = covData['covMatrix']
    30313025        varyList = covData['varyList']
    3032         pfx = str(TorsionData['pId'])+'::'
    3033     #find one end of 4 atom string - involved in longest distance
    3034     dist = {}
    3035     for i,X1 in enumerate(TorsionData['Datoms']):
    3036         for j,X2 in enumerate(TorsionData['Datoms'][:i]):
    3037             dist[np.sqrt(np.sum(np.inner(Amat,np.array(X2[3:6])-np.array(X1[3:6]))**2))] = [i,j]
    3038     sortdist = dist.keys()
    3039     sortdist.sort()
    3040     end = dist[sortdist[-1]][0]
    3041     #order atoms in distance from end - defines sequence of atoms for the torsion angle
    3042     dist = {}
    3043     X1 = TorsionData['Datoms'][end]
    3044     for i,X2 in enumerate(TorsionData['Datoms']):
    3045         dist[np.sqrt(np.sum(np.inner(Amat,np.array(X2[3:6])-np.array(X1[3:6]))**2))] = i
    3046     sortdist = dist.keys()
    3047     sortdist.sort()
     3026        pfx = str(DATData['pId'])+'::'
    30483027    Datoms = []
    30493028    Oatoms = []
    3050     for d in sortdist:
    3051         atom = TorsionData['Datoms'][dist[d]]
     3029    for i,atom in enumerate(DATData['Datoms']):
    30523030        symop = atom[-1].split('+')
    30533031        if len(symop) == 1:
     
    30553033        symop[0] = int(symop[0])
    30563034        symop[1] = eval(symop[1])
    3057         atom[-1] = symop
     3035        atom.append(symop)
    30583036        Datoms.append(atom)
    3059         oatom = TorsionData['Oatoms'][dist[d]]
     3037        oatom = DATData['Oatoms'][i]
    30603038        names = ['','','']
    30613039        if pfx:
     
    30633041        oatom += [names,]
    30643042        Oatoms.append(oatom)
    3065     Tors,sig = G2mth.GetTorsionSig(Oatoms,Datoms,Amat,SGData,covData)
    3066     print ' Torsion angle for atom sequence: ',[Datoms[i][1] for i in range(4)],'=',G2mth.ValEsd(Tors,sig)
    3067     print ' NB: Atom sequence determined by interatomic distances'
     3043    atmSeq = [atom[1]+'('+atom[-2]+')' for atom in Datoms]
     3044    if DATData['Natoms'] == 4:  #torsion
     3045        Tors,sig = G2mth.GetDATSig(Oatoms,Datoms,Amat,SGData,covData)
     3046        print ' Torsion angle for '+DATData['Name']+' atom sequence: ',atmSeq,'=',G2mth.ValEsd(Tors,sig)
     3047        print ' NB: Atom sequence determined by selection order'
     3048        return      # done with torsion
     3049    elif DATData['Natoms'] == 3:  #angle
     3050        Ang,sig = G2mth.GetDATSig(Oatoms,Datoms,Amat,SGData,covData)
     3051        print ' Angle in '+DATData['Name']+' for atom sequence: ',atmSeq,'=',G2mth.ValEsd(Ang,sig)
     3052        print ' NB: Atom sequence determined by selection order'
     3053    else:   #2 atoms - distance
     3054        Dist,sig = G2mth.GetDATSig(Oatoms,Datoms,Amat,SGData,covData)
     3055        print ' Distance in '+DATData['Name']+' for atom sequence: ',atmSeq,'=',G2mth.ValEsd(Dist,sig)
    30683056               
    30693057def BestPlane(PlaneData):
Note: See TracChangeset for help on using the changeset viewer.