Changeset 2544


Ignore:
Timestamp:
Nov 21, 2016 4:40:02 PM (7 years ago)
Author:
vondreele
Message:

major cleanup of unused variables, etc.

Location:
trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASII.py

    r2542 r2544  
    11031103
    11041104        ibanks = int(Iparm.get('INS   BANK  ','1').strip())
    1105         hType = Iparm['INS   HTYPE '].strip()
    11061105        if ibanks == 1: # there is only one bank here, return it
    11071106            rd.instbank = 1
     
    16511650        while item: # loop over (new) phases
    16521651            iph += 1
    1653             phaseName = self.PatternTree.GetItemText(item)
    16541652            data = self.PatternTree.GetItemPyData(item)
    16551653            item, cookie = self.PatternTree.GetNextChild(sub, cookie)
     
    18181816        while item: # loop over (new) phases
    18191817            iph += 1
    1820             phaseName = self.PatternTree.GetItemText(item)
    18211818            data = self.PatternTree.GetItemPyData(item)
    18221819            item, cookie = self.PatternTree.GetNextChild(sub, cookie)
     
    18881885        if len(rdlist) == 0: return
    18891886        self.CheckNotebook()
    1890         Iparm = None
    1891         lastdatafile = ''
    18921887        newHistList = []
    18931888        self.EnablePlot = False
    18941889        for rd in rdlist:
    1895             lastdatafile = rd.smallangleentry[0]
    18961890            HistName = rd.idstring
    18971891            HistName = 'SASD '+HistName
     
    21232117                path,rootname = os.path.split(filename)
    21242118                pkg = os.path.splitext(rootname)[0]
    2125                 try:
    2126                     fp = None
    2127                     fp, fppath,desc = imp.find_module(pkg,[path,])
    2128                     pkg = imp.load_module(pkg,fp,fppath,desc)
    2129                     for clss in inspect.getmembers(pkg): # find classes defined in package
    2130                         if clss[0].startswith('_'): continue
    2131                         if inspect.isclass(clss[1]):
    2132                             # check if we have the required methods
    2133                             for m in 'Exporter','loadParmDict':
    2134                                 if not hasattr(clss[1],m): break
    2135                                 if not callable(getattr(clss[1],m)): break
    2136                             else:
    2137                                 exporter = clss[1](self) # create an export instance
    2138                                 self.exporterlist.append(exporter)
    2139                 except AttributeError:
    2140                     print 'Import_'+errprefix+': Attribute Error'+str(filename)
    2141                     pass
    2142                 except ImportError:
    2143                     print 'Import_'+errprefix+': Error importing file'+str(filename)
    2144                     pass
     2119#                try:
     2120                fp = None
     2121                fp, fppath,desc = imp.find_module(pkg,[path,])
     2122                pkg = imp.load_module(pkg,fp,fppath,desc)
     2123                for clss in inspect.getmembers(pkg): # find classes defined in package
     2124                    if clss[0].startswith('_'): continue
     2125                    if inspect.isclass(clss[1]):
     2126                        # check if we have the required methods
     2127                        for m in 'Exporter','loadParmDict':
     2128                            if not hasattr(clss[1],m): break
     2129                            if not callable(getattr(clss[1],m)): break
     2130                        else:
     2131                            exporter = clss[1](self) # create an export instance
     2132                            self.exporterlist.append(exporter)
     2133#                except AttributeError:
     2134#                    print 'Import_'+errprefix+': Attribute Error'+str(filename)
     2135#                    pass
     2136#                except ImportError:
     2137#                    print 'Import_'+errprefix+': Error importing file'+str(filename)
     2138#                    pass
    21452139                if fp: fp.close()
    21462140        # Add submenu item(s) for each Exporter by its self-declared type (can be more than one)
     
    24682462            if pltNum >= 0:                         #to avoid the startup with no plot!
    24692463                pltPage = self.G2plotNB.nb.GetPage(pltNum)
    2470                 pltPlot = pltPage.figure
    24712464            item = event.GetItem()
    24722465            G2gd.MovePatternTreeToGrid(self,item)
     
    25642557    def OnReadPowderPeaks(self,event):
    25652558        'Bound to menu Data/Read Powder Peaks'
    2566         Cuka = 1.54052
    25672559        self.CheckNotebook()
    25682560        pth = G2G.GetImportPath(self)
     
    27772769        TextList = []
    27782770        DataList = []
    2779         SumList = []
    27802771        Names = []
    27812772        Inst = None
    2782         SumItemList = []
    27832773        Comments = ['Sum equals: \n']
    27842774        if self.PatternTree.GetCount():
     
    28812871        TextList = []
    28822872        DataList = []
    2883         SumList = []
    28842873        Names = []
    2885         Inst = []
    2886         SumItemList = []
    28872874        Comments = ['Sum equals: \n']
    28882875        if self.PatternTree.GetCount():
     
    31013088        DelItemList = []
    31023089        nItems = {'PWDR':0,'SASD':0,'IMG':0,'HKLF':0,'PDF':0}
    3103         ifPWDR = False
    3104         ifSASD = False
    3105         ifIMG = False
    3106         ifHKLF = False
    3107         ifPDF = False
    31083090        if self.PatternTree.GetCount():
    31093091            item, cookie = self.PatternTree.GetFirstChild(self.root)
     
    31123094                if name not in ['Notebook','Controls','Covariance','Constraints',
    31133095                    'Restraints','Phases','Rigid bodies'] or 'Sequential' not in name:
    3114                     if 'PWDR' in name: ifPWDR = True; nItems['PWDR'] += 1
    3115                     if 'SASD' in name: ifSASD = True; nItems['SASD'] += 1
    3116                     if 'IMG' in name: ifIMG = True; nItems['IMG'] += 1
    3117                     if 'HKLF' in name: ifHKLF = True; nItems['HKLF'] += 1
    3118                     if 'PDF' in name: ifPDF = True; nItems['PDF'] += 1
     3096                    if 'PWDR' in name: nItems['PWDR'] += 1
     3097                    if 'SASD' in name: nItems['SASD'] += 1
     3098                    if 'IMG' in name: nItems['IMG'] += 1
     3099                    if 'HKLF' in name: nItems['HKLF'] += 1
     3100                    if 'PDF' in name: nItems['PDF'] += 1
    31193101                    TextList.append(name)
    31203102                item, cookie = self.PatternTree.GetNextChild(self.root, cookie)
     
    34493431        '''Calculates PDFs
    34503432        '''
    3451         sind = lambda x: math.sin(x*math.pi/180.)
    3452         tth2q = lambda t,w:4.0*math.pi*sind(t/2.0)/w
    34533433        TextList = []
    34543434        PDFlist = []
     
    39663946                'Python version error',  wx.OK)
    39673947            try:
    3968                 result = dlg.ShowModal()
     3948                dlg.ShowModal()
    39693949            finally:
    39703950                dlg.Destroy()
  • trunk/GSASIIIO.py

    r2532 r2544  
    289289    G2frame.PatternTree.SetItemPyData(G2frame.PatternTree.AppendItem(Id,text='Comments'),Comments)
    290290    Imax = np.amax(Image)
    291     Imin = max(0.0,np.amin(Image))          #force positive
    292291    if G2frame.imageDefault:
    293292        Data = copy.copy(G2frame.imageDefault)
     
    387386                errorReport += ': '+rd.errors
    388387                continue
    389         rdbuffer = {} # create temporary storage for file reader
    390388        if imageOnly:
    391389            ParentFrame = None # prevent GUI access on reread
     
    540538def GetEdfData(filename,imageOnly=False):   
    541539    'Read European detector data edf file'
    542     import struct as st
    543     import array as ar
    544540    if not imageOnly:
    545541        print 'Read European detector data edf file: ',filename
     
    600596def GetRigaku(filename,imageOnly=False):
    601597    'Read Rigaku R-Axis IV image file'
    602     import struct as st
    603598    import array as ar
    604599    if not imageOnly:
     
    632627def GetImgData(filename,imageOnly=False):
    633628    'Read an ADSC image file'
    634     import struct as st
    635629    import array as ar
    636630    if not imageOnly:
     
    663657    data = {'pixelSize':pixel,'wavelength':wave,'distance':distance,'center':center,'size':[size,size]}
    664658    image = []
    665     row = 0
    666659    pos = 512
    667660    File.seek(pos)
    668661    image = np.array(ar.array('H',File.read(2*Npix)),dtype=np.int32)
    669     image = np.reshape(image,(sizexy[1],sizexy[0]))
     662    image = np.reshape(image,(size,size))
    670663#    image = np.zeros(shape=(size,size),dtype=np.int32)   
    671664#    while row < size:
     
    684677def GetMAR345Data(filename,imageOnly=False):
    685678    'Read a MAR-345 image plate image'
    686     import array as ar
    687     import struct as st
    688679    try:
    689680        import pack_f as pf
     
    699690    File = open(filename,'rb')
    700691    head = File.read(4095)
    701     numbers = st.unpack('<iiiiiiiiii',head[:40])
    702692    lines = head[128:].split('\n')
    703693    head = []
     
    870860        X = 4.*np.pi*npsind(X/2.)/data['wavelength']    #convert to q
    871861    Xminmax = [X[0],X[-1]]
    872     LRazm = data['LRazimuth']
    873862    Azms = []
    874863    dazm = 0.
     
    10191008        dlg = wx.MessageDialog(G2frame, 'No peaks!', 'Nothing to save!', wx.OK)
    10201009        try:
    1021             result = dlg.ShowModal()
     1010            dlg.ShowModal()
    10221011        finally:
    10231012            dlg.Destroy()
     
    10371026            dlg = wx.MessageDialog(G2frame, 'No peaks!', 'Nothing to save!', wx.OK)
    10381027            try:
    1039                 result = dlg.ShowModal()
     1028                dlg.ShowModal()
    10401029            finally:
    10411030                dlg.Destroy()
     
    25762565        Layer['Layers'].append({'Name':Struct[N],'SameAs':'','Symm':Symm,'Atoms':[]})
    25772566        N += 2
    2578         iatm = 0
    25792567        while 'layer' not in Struct[N]:
    25802568            atom = Struct[N][4:].split()
  • trunk/GSASIIconstrGUI.py

    r2520 r2544  
    458458                l2 = max(l2,len(i2))
    459459            fmt = "{:"+str(l1)+"s} {:"+str(l2)+"s} {:s}"
    460             atchoice = [fmt.format(*i) for i in choices]
     460            atchoice = [fmt.format(*i1) for i1 in choices]
    461461            dlg = G2G.G2MultiChoiceDialog(
    462462                G2frame.dataFrame,legend,
     
    688688                                parent=G2frame.dataFrame)
    689689            return
    690         legend = "Select variables to make equivalent (only one of the variables will be varied when all are set to be varied)"
     690#        legend = "Select variables to make equivalent (only one of the variables will be varied when all are set to be varied)"
    691691        GetAddVars(page,title1,title2,varList,constrDictEnt,'equivalence')
    692692       
     
    701701                                parent=G2frame.dataFrame)
    702702            return
    703         legend = "Select atoms to make equivalent (only one of the atom variables will be varied when all are set to be varied)"
     703#        legend = "Select atoms to make equivalent (only one of the atom variables will be varied when all are set to be varied)"
    704704        GetAddAtomVars(page,title1,title2,varList,constrDictEnt,'equivalence')
    705705       
     
    714714                                parent=G2frame.dataFrame)
    715715            return
    716         legend = "Select atoms to ride (only one of the atom variables will be varied when all are set to be varied)"
     716#        legend = "Select atoms to ride (only one of the atom variables will be varied when all are set to be varied)"
    717717        GetAddAtomVars(page,title1,title2,varList,constrDictEnt,'riding')
    718718   
     
    727727                                parent=G2frame.dataFrame)
    728728            return
    729         legend = "Select variables to include in a new variable (the new variable will be varied when all included variables are varied)"
     729#        legend = "Select variables to include in a new variable (the new variable will be varied when all included variables are varied)"
    730730        GetAddVars(page,title1,title2,varList,constrDictEnt,'function')
    731731                       
     
    740740                                parent=G2frame.dataFrame)
    741741            return
    742         legend = "Select variables to include in a constraint equation (the values will be constrainted to equal a specified constant)"
     742#        legend = "Select variables to include in a constraint equation (the values will be constrainted to equal a specified constant)"
    743743        GetAddVars(page,title1,title2,varList,constrDictEnt,'constraint')
    744744
     
    13981398        if dlg.ShowModal() == wx.ID_OK:
    13991399            nAtoms,nTrans = dlg.GetValues()
    1400             vectorRB = data['Vector']
    14011400            rbId = ran.randint(0,sys.maxint)
    14021401            vecMag = [1.0 for i in range(nTrans)]
     
    14671466        rbTypes = []
    14681467        rbXYZ = []
    1469         rbSeq = []
    14701468        atNames = []
    14711469        txtStr = text.readline()
     
    15891587        if dlg.ShowModal() == wx.ID_OK:
    15901588            Orig = dlg.GetSelection()
    1591             xyz = XYZ[Orig]
    15921589            TargList = neighDict[atNames[Orig]]
    15931590        dlg.Destroy()
     
    16181615                event.Skip()
    16191616                Obj = event.GetEventObject()
    1620                 rbId = Indx[Obj.GetId()]
    16211617                rbData['RBname'] = Obj.GetValue()
    16221618               
     
    16311627            def OnPlotRB(event):
    16321628                Obj = event.GetEventObject()
    1633                 rbId = Indx[Obj.GetId()]
    16341629                Obj.SetValue(False)
    16351630                G2plt.PlotRigidBody(G2frame,'Vector',AtInfo,rbData,plotDefaults)
     
    17271722
    17281723            def TypeSelect(event):
    1729                 Obj = event.GetEventObject()
    17301724                AtInfo = data['Vector']['AtInfo']
    17311725                r,c = event.GetRow(),event.GetCol()
     
    17441738
    17451739            def ChangeCell(event):
    1746                 Obj = event.GetEventObject()
    17471740                r,c =  event.GetRow(),event.GetCol()
    17481741                if r >= 0 and (0 <= c < 3):
     
    18321825            def OnRBName(event):
    18331826                Obj = event.GetEventObject()
    1834                 rbId = Indx[Obj.GetId()]
    18351827                rbData['RBname'] = Obj.GetValue()
    18361828               
     
    18441836            def OnPlotRB(event):
    18451837                Obj = event.GetEventObject()
    1846                 rbId = Indx[Obj.GetId()]
    18471838                Obj.SetValue(False)
    18481839                G2plt.PlotRigidBody(G2frame,'Residue',AtInfo,rbData,plotDefaults)
  • trunk/GSASIIgrid.py

    r2538 r2544  
    22492249        self.AtomsMenu.Append(menu=self.AtomCompute, title='Compute')
    22502250        submenu = wx.Menu()
    2251         self.AtomEdit.AppendMenu(wx.ID_ANY, 'Atoms selection...', submenu,
     2251        self.AtomEdit.AppendMenu(wx.ID_ANY, 'On selected atoms...', submenu,
    22522252            help='Set/Act on selected atoms')
    22532253        submenu.Append(wxID_ATOMSSETSEL,
  • trunk/GSASIImath.py

    r2522 r2544  
    1515
    1616'''
    17 import sys
    18 import os
    19 import os.path as ospath
    2017import random as rn
    2118import numpy as np
    2219import numpy.linalg as nl
    2320import numpy.ma as ma
    24 import cPickle
    2521import time
    2622import math
     
    213209
    214210    def getNeighbors(atom,radius):
    215         neighList = [] 
    216211        Dx = UAtoms-np.array(atom[cx:cx+3])
    217212        dist = ma.masked_less(np.sqrt(np.sum(np.inner(Amat,Dx)**2,axis=0)),0.5) #gets rid of disorder "bonds" < 0.5A
     
    495490    Tatoms = GetAtomsById(Atoms,AtLookUp,AddHydId[1])
    496491    TXYZ = np.array([tatom[cx:cx+3] for tatom in Tatoms]) #3 x xyz
    497     DX = np.inner(Amat,TXYZ-OXYZ).T
    498492    if nBonds == 4:
    499493        if AddHydId[-1] == 1:
     
    633627        XYZ = np.inner(Amat,atom[cx:cx+3])
    634628        Axyz = np.array([ 0,XYZ[2],-XYZ[1], -XYZ[2],0,XYZ[0], XYZ[1],-XYZ[0],0],ndmin=2 )
    635         if 'U' in TSLtype:
     629        if 'U' in TLStype:
    636630            atom[cia+1] = TLS[0]
    637631            atom[cia] = 'I'
     
    11321126    '''
    11331127    glTau,glWt = pwd.pygauleg(0.,1.,ngl)         #get Gauss-Legendre intervals & weights
    1134     dT = 2./ngl
    1135     dX = 0.0001
    11361128    waveShapes = [FSSdata.T.shape,XSSdata.T.shape,USSdata.T.shape]
    11371129    Af = np.array(FSSdata[0]).T    #sin frac mods x waves x atoms
     
    14291421#          area += w[i]*f(x[i])                                   
    14301422
    1431 import math
    14321423def gaulegf(a, b, n):
    14331424  x = range(n+1) # x[0] unused
     
    15101501        return 0.
    15111502    pId = distance_dict['pId']
    1512     pfx = '%d::'%(pId)
    15131503    A = [parmDict['%s::A%d'%(pId,i)] for i in range(6)]
    15141504    Amat = G2lat.cell2AB(G2lat.A2cell(A))[0]
     
    15341524        return None
    15351525    pId = distance_dict['pId']
    1536     pfx = '%d::'%(pId)
    15371526    A = [parmDict['%s::A%d'%(pId,i)] for i in range(6)]
    15381527    Amat = G2lat.cell2AB(G2lat.A2cell(A))[0]
     
    15491538        return 0.
    15501539    pId = angle_dict['pId']
    1551     pfx = '%d::'%(pId)
    15521540    A = [parmDict['%s::A%d'%(pId,i)] for i in range(6)]
    15531541    Amat = G2lat.cell2AB(G2lat.A2cell(A))[0]
     
    15811569        return None
    15821570    pId = angle_dict['pId']
    1583     pfx = '%d::'%(pId)
    15841571    A = [parmDict['%s::A%d'%(pId,i)] for i in range(6)]
    15851572    Amat = G2lat.cell2AB(G2lat.A2cell(A))[0]
     
    20342021        return np.sqrt(np.sum(V1**2))
    20352022       
    2036     Inv = []
    20372023    SyOps = []
    20382024    names = []
     
    20482034    sig = -0.001
    20492035    if 'covMatrix' in covData:
    2050         parmNames = []
    20512036        dx = .00001
    20522037        dadx = np.zeros(6)
     
    20912076        return acosd(cang)
    20922077
    2093     Inv = []
    20942078    SyOps = []
    20952079    names = []
     
    21052089    sig = -0.01
    21062090    if 'covMatrix' in covData:
    2107         parmNames = []
    21082091        dx = .00001
    21092092        dadx = np.zeros(9)
     
    21492132        M = np.array([V1,V2,V3])
    21502133        D = nl.det(M)
    2151         Ang = 1.0
    21522134        P12 = np.dot(V1,V2)
    21532135        P13 = np.dot(V1,V3)
     
    21562138        return Tors
    21572139           
    2158     Inv = []
    21592140    SyOps = []
    21602141    names = []
     
    21702151    sig = -0.01
    21712152    if 'covMatrix' in covData:
    2172         parmNames = []
    21732153        dx = .00001
    21742154        dadx = np.zeros(12)
     
    22402220        M = np.array([V1,V2,V3])
    22412221        D = nl.det(M)
    2242         Ang = 1.0
    22432222        P12 = np.dot(V1,V2)
    22442223        P13 = np.dot(V1,V3)
     
    22472226        return Tors
    22482227           
    2249     Inv = []
    22502228    SyOps = []
    22512229    names = []
     
    22682246    sig = sigVals[M-3]
    22692247    if 'covMatrix' in covData:
    2270         parmNames = []
    22712248        dx = .00001
    22722249        N = M*3
     
    26002577                phasep = complex(a,b)
    26012578                phasem = complex(a,-b)
    2602                 Fo = np.sqrt(Fosq)
    26032579                if '2Fo-Fc' in mapData['MapType']:
    26042580                    F = 2.*np.sqrt(Fosq)-np.sqrt(Fcsq)
     
    28282804    DH = []
    28292805    Dphi = []
    2830     SGMT = np.array([ops[0].T for ops in SGData['SGOps']])
    2831     SGT = np.array([ops[1] for ops in SGData['SGOps']])
    28322806    Hmax = 2*np.asarray(G2lat.getHKLmax(3.5,SGData,A),dtype='i')
    28332807    for F in Flist:
     
    30553029    SGData = generalData['SGData']
    30563030    SSGData = generalData['SSGData']
    3057     SGMT = np.array([ops[0].T for ops in SGData['SGOps']])
    3058     SGT = np.array([ops[1] for ops in SGData['SGOps']])
    30593031    SSGMT = np.array([ops[0].T for ops in SSGData['SSGOps']])
    30603032    SSGT = np.array([ops[1] for ops in SSGData['SSGOps']])
     
    32403212        return Vec,Hess
    32413213       
    3242     phaseName = generalData['Name']
    32433214    SGData = generalData['SGData']
    32443215    Amat,Bmat = G2lat.cell2AB(generalData['Cell'][1:7])
     
    32833254        x1 = result[0]
    32843255        if not np.any(x1 < 0):
    3285             mag = x1[0]
    32863256            peak = (np.array(x1[1:4])-ind)/incre
    32873257        peak = fixSpecialPos(peak,SGData,Amat)
     
    33303300                           
    33313301    generalData = data['General']
    3332     cell = generalData['Cell'][1:7]
    33333302    Amat,Bmat = G2lat.cell2AB(generalData['Cell'][1:7])
    3334     A = G2lat.cell2A(cell)
    33353303    SGData = generalData['SGData']
    33363304    mapPeaks = data['Map Peaks']
     
    33653333                           
    33663334    generalData = data['General']
    3367     cell = generalData['Cell'][1:7]
    33683335    Amat,Bmat = G2lat.cell2AB(generalData['Cell'][1:7])
    3369     A = G2lat.cell2A(cell)
    33703336    SGData = generalData['SGData']
    33713337    mapPeaks = data['Map Peaks']
     
    35853551
    35863552import numpy
    3587 from numpy import asarray, tan, exp, ones, squeeze, sign, \
    3588      all, log, sqrt, pi, shape, array, minimum, where
     3553from numpy import asarray, tan, exp, squeeze, sign, \
     3554     all, log, pi, shape, array, where
    35893555from numpy import random
    35903556
     
    42674233    MCSA = generalData['MCSA controls']
    42684234    reflName = MCSA['Data source']
    4269     phaseName = generalData['Name']
    42704235    MCSAObjs = data['MCSA']['Models']               #list of MCSA models
    42714236    upper = []
  • trunk/GSASIIphsGUI.py

    r2530 r2544  
    2424import wx
    2525import wx.grid as wg
    26 import wx.lib.gridmovers as wgmove
    27 import wx.wizard as wz
    2826import wx.lib.scrolledpanel as wxscroll
    2927import matplotlib as mpl
     
    3230import sys
    3331import random as ran
    34 import cPickle
    3532import GSASIIpath
    3633GSASIIpath.SetVersionNumber("$Revision$")
     
    5148import GSASIIctrls as G2G
    5249import GSASIIconstrGUI as G2cnstG
    53 import atmdata
    5450import numpy as np
    5551import numpy.linalg as nl
    56 import numpy.ma as ma
    5752
    5853VERY_LIGHT_GREY = wx.Colour(235,235,235)
     
    565560                except ValueError:
    566561                    if ObjId < 3:               #bad cell edge - reset
    567                         value = controls[6+ObjId]
     562                        value = cell[ObjId+1]
    568563                    else:                       #bad angle
    569564                        value = 90.
     
    944939            modS = G2spc.splitSSsym(generalData['SuperSg'])[0]
    945940            generalData['SuperVec'][0],ifShow = G2spc.SSGModCheck(generalData['SuperVec'][0],modS)
    946             vec = generalData['SuperVec'][0]
    947941            for i,[val,show] in enumerate(zip(generalData['SuperVec'][0],ifShow)):
    948942                if show:
     
    11541148           
    11551149        def MCSASizer():
    1156             Ind = {}
    11571150           
    11581151            def OnRefList(event):
     
    12021195                MCSAdata['ranStart'] = ranStart.GetValue()
    12031196               
    1204             def OnAutoRan(event):
    1205                 MCSAdata['autoRan'] = autoRan.GetValue()
     1197#            def OnAutoRan(event):
     1198#                MCSAdata['autoRan'] = autoRan.GetValue()
    12061199               
    12071200            def OnRanRange(event):
     
    18001793        generalData = data['General']
    18011794        SpnFlp = generalData['SGData'].get('SpnFlp',[])
    1802         OprNames = generalData['SGData'].get('OprNames',[])
     1795#        OprNames = generalData['SGData'].get('OprNames',[])
    18031796#        print OprNames
    18041797#        print SpnFlp
    18051798#        print generalData['SGData'].get('MagMom',[])
    18061799        atomData = data['Atoms']
    1807         DData = data['Drawing']
    18081800        resRBData = data['RBModels'].get('Residue',[])
    18091801        vecRBData = data['RBModels'].get('Vector',[])
     
    18941886        atomData = data['Atoms']
    18951887        generalData = data['General']
    1896         Ncol = Atoms.GetNumberCols()
    18971888        atId = ran.randint(0,sys.maxint)
    18981889        E,SGData = G2spc.SpcGroup(generalData['SGData']['SpGrp'])
     
    20382029               
    20392030    def OnHydAtomUpdate(event):
    2040         Error = ''
    20412031        generalData = data['General']
    20422032        cx,ct,cs,cia = generalData['AtomPtrs']
     
    21342124        atomData = data['Atoms']
    21352125        generalData = data['General']
    2136         Ncol = Atoms.GetNumberCols()
    21372126        E,SGData = G2spc.SpcGroup(generalData['SGData']['SpGrp'])
    21382127        Sytsym,Mult = G2spc.SytSym([x,y,z],SGData)[:2]
     
    23922381        G2plt.PlotStructure(G2frame,data)
    23932382           
    2394     def AtomRotate(event):
    2395         '''Currently not used - Bind commented out below
    2396         '''
    2397         Units = {'':np.zeros(3),
    2398             'xy':np.array([[i,j,0] for i in range(3) for j in range(3)])-np.array([1,1,0]),
    2399             'xz':np.array([[i,0,j] for i in range(3) for j in range(3)])-np.array([1,1,0]),
    2400             'yz':np.array([[0,i,j] for i in range(3) for j in range(3)])-np.array([1,1,0]),
    2401             'xyz':np.array([[i,j,k] for i in range(3) for j in range(3) for k in range(3)])-np.array([1,1,1])}
    2402         indx = GetSelectedAtoms()
    2403         if indx:
    2404             generalData = data['General']
    2405             A,B = G2lat.cell2AB(generalData['Cell'][1:7])
    2406             colLabels = [Atoms.GetColLabelValue(c) for c in range(Atoms.GetNumberCols())]
    2407             cx = colLabels.index('x')
    2408             cuia = colLabels.index('I/A')   #need to not do aniso atoms - stop with error? or force isotropic?
    2409             css = colLabels.index('site sym')
    2410             atomData = data['Atoms']
    2411             SGData = generalData['SGData']
    2412             dlg = G2gd.RotationDialog(G2frame)
    2413             try:
    2414                 if dlg.ShowModal() == wx.ID_OK:
    2415                     M,T,Expand = dlg.GetSelection()
    2416                     Unit = Units[Expand]
    2417                     for ind in indx:
    2418                         XYZ = np.array(atomData[ind][cx:cx+3])
    2419                         XYZS = XYZ+Unit
    2420                         XYZS -= T
    2421                         XYZS = np.inner(A,XYZS).T   #to Cartesian
    2422                         XYZS = np.inner(M,XYZS).T   #rotate
    2423                         XYZS = np.inner(B,XYZS).T+T #back to crystal & translate
    2424                         GSASIIpath.IPyBreak()
    2425                         atomData[ind][cx:cx+3] = XYZ
     2383#    def AtomRotate(event):
     2384#        '''Currently not used - Bind commented out below
     2385#        '''
     2386#        Units = {'':np.zeros(3),
     2387#            'xy':np.array([[i,j,0] for i in range(3) for j in range(3)])-np.array([1,1,0]),
     2388#            'xz':np.array([[i,0,j] for i in range(3) for j in range(3)])-np.array([1,1,0]),
     2389#            'yz':np.array([[0,i,j] for i in range(3) for j in range(3)])-np.array([1,1,0]),
     2390#            'xyz':np.array([[i,j,k] for i in range(3) for j in range(3) for k in range(3)])-np.array([1,1,1])}
     2391#        indx = GetSelectedAtoms()
     2392#        if indx:
     2393#            generalData = data['General']
     2394#            A,B = G2lat.cell2AB(generalData['Cell'][1:7])
     2395#            colLabels = [Atoms.GetColLabelValue(c) for c in range(Atoms.GetNumberCols())]
     2396#            cx = colLabels.index('x')
     2397#            cuia = colLabels.index('I/A')   #need to not do aniso atoms - stop with error? or force isotropic?
     2398#            css = colLabels.index('site sym')
     2399#            atomData = data['Atoms']
     2400#            SGData = generalData['SGData']
     2401#            dlg = G2gd.RotationDialog(G2frame)
     2402#            try:
     2403#                if dlg.ShowModal() == wx.ID_OK:
     2404#                    M,T,Expand = dlg.GetSelection()
     2405#                    Unit = Units[Expand]
     2406#                    for ind in indx:
     2407#                        XYZ = np.array(atomData[ind][cx:cx+3])
     2408#                        XYZS = XYZ+Unit
     2409#                        XYZS -= T
     2410#                        XYZS = np.inner(A,XYZS).T   #to Cartesian
     2411#                        XYZS = np.inner(M,XYZS).T   #rotate
     2412#                        XYZS = np.inner(B,XYZS).T+T #back to crystal & translate
     2413#                        GSASIIpath.IPyBreak()
     2414#                        atomData[ind][cx:cx+3] = XYZ
    24262415#                        for unit in Unit:
    24272416#                            XYZ = np.copy(np.array(atomData[ind][cx:cx+3]))
     
    24352424##                                atom[css:css+2] = G2spc.SytSym(XYZ,SGData)[:2]
    24362425#                                break
    2437             finally:
    2438                 dlg.Destroy()
    2439             Atoms.ClearSelection()
    2440             Atoms.ForceRefresh()
    2441         else:
    2442             print "select one or more rows of atoms"
    2443             G2frame.ErrorDialog('Select atom',"select one or more atoms then redo")
     2426#            finally:
     2427#                dlg.Destroy()
     2428#            Atoms.ClearSelection()
     2429#            Atoms.ForceRefresh()
     2430#        else:
     2431#            print "select one or more rows of atoms"
     2432#            G2frame.ErrorDialog('Select atom',"select one or more atoms then redo")
    24442433               
    24452434    def MakeMolecule(event):     
    24462435        indx = GetSelectedAtoms()
    2447         Oxyz = []
    2448         xyz = []
    24492436        DisAglCtls = {}
    24502437        if len(indx) == 1:
     
    27762763        Indx = {}
    27772764       
    2778         def SetCell(laue,cell):
    2779             if laue in ['-3','-3m','6/m','6/mmm','4/m','4/mmm']:                   
    2780                 cell[4] = cell[5] = 90.
    2781                 cell[6] = 120.
    2782                 if laue in ['4/m','4/mmm']:
    2783                     cell[6] = 90.
    2784                 if ObjId == 0:
    2785                     cell[1] = cell[2] = value
    2786                     Obj.SetValue("%.5f"%(cell[1]))
    2787                 else:
    2788                     cell[3] = value
    2789                     Obj.SetValue("%.5f"%(cell[3]))
    2790             elif laue in ['mmm']:
    2791                 cell[ObjId+1] = value
    2792                 cell[4] = cell[5] = cell[6] = 90.
    2793                 Obj.SetValue("%.5f"%(cell[ObjId+1]))
    2794             elif laue in ['2/m','-1']:
    2795                 cell[4] = cell[5] = 90.
    2796                 if ObjId != 3:
    2797                     cell[ObjId+1] = value
    2798                     Obj.SetValue("%.5f"%(cell[ObjId+1]))
    2799                 else:
    2800                     cell[6] = value
    2801                     Obj.SetValue("%.3f"%(cell[6]))
    2802             cell[7] = G2lat.calc_V(G2lat.cell2A(cell[1:7]))
     2765#        def SetCell(laue,cell):
     2766#            if laue in ['-3','-3m','6/m','6/mmm','4/m','4/mmm']:                   
     2767#                cell[4] = cell[5] = 90.
     2768#                cell[6] = 120.
     2769#                if laue in ['4/m','4/mmm']:
     2770#                    cell[6] = 90.
     2771#                if ObjId == 0:
     2772#                    cell[1] = cell[2] = value
     2773#                    Obj.SetValue("%.5f"%(cell[1]))
     2774#                else:
     2775#                    cell[3] = value
     2776#                    Obj.SetValue("%.5f"%(cell[3]))
     2777#            elif laue in ['mmm']:
     2778#                cell[ObjId+1] = value
     2779#                cell[4] = cell[5] = cell[6] = 90.
     2780#                Obj.SetValue("%.5f"%(cell[ObjId+1]))
     2781#            elif laue in ['2/m','-1']:
     2782#                cell[4] = cell[5] = 90.
     2783#                if ObjId != 3:
     2784#                    cell[ObjId+1] = value
     2785#                    Obj.SetValue("%.5f"%(cell[ObjId+1]))
     2786#                else:
     2787#                    cell[6] = value
     2788#                    Obj.SetValue("%.3f"%(cell[6]))
     2789#            cell[7] = G2lat.calc_V(G2lat.cell2A(cell[1:7]))
    28032790
    28042791        def OnLaue(event):
     
    28542841                except ValueError:
    28552842                    if ObjId < 3:               #bad cell edge - reset
    2856                         value = controls[6+ObjId]
     2843                        value = cell[ObjId+1]
    28572844                    else:                       #bad angle
    28582845                        value = 90.
     
    34773464                return
    34783465            dlg.Destroy()
    3479             PWDR = data['Histograms'][HistName]
    34803466            G2frame.PatternId = G2gd.GetPatternTreeItemId(G2frame,G2frame.root,HistName)
    34813467            sample = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(
     
    35483534            return
    35493535        dlg.Destroy()
    3550         PWDR = data['Histograms'][HistName]
    35513536        G2frame.PatternId = G2gd.GetPatternTreeItemId(G2frame,G2frame.root,HistName)
    35523537        sample = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(
     
    35723557        nSteps = simCodes[4]
    35733558        laue = Layers['Laue']
    3574         dStep = (BegFin[1]-BegFin[0])/nSteps
    35753559        vals = np.linspace(BegFin[0],BegFin[1],nSteps+1,True)
    35763560        simNames = []
     
    36063590                    print ' Transition matrix:'
    36073591                    for trans in Layers['Transitions']:
    3608                         line = str([' %.3f'%(vals[0]) for vals in trans])
     3592                        line = str([' %.3f'%(item[0]) for item in trans])
    36093593                        print line[1:-2].replace("'",'')
    36103594                else:
     
    36413625        cx,ct,cs,cia = generalData['AtomPtrs']
    36423626        atomData = data['Atoms']
    3643         Map = generalData['Map']
    36443627        D4Map = generalData['4DmapData']
    36453628        if waveData.GetSizer():
     
    36663649            G2frame.bottomSizer = ShowAtomInfo()
    36673650            mainSizer.Add(G2frame.bottomSizer)
    3668             Indx = {}
    36693651            mainSizer.Layout()
    36703652            G2frame.dataFrame.Refresh()
     
    38113793            atm = atomData[iatm]
    38123794            xyz = atm[cx:cx+3]
    3813             uij = atm[cia+2:cia+8]
    38143795            atomSizer = wx.BoxSizer(wx.VERTICAL)
    38153796            G2G.HorizontalLine(atomSizer,waveData)
     
    38673848        Amat,Bmat = G2lat.cell2AB(generalData['Cell'][1:7])
    38683849        atomData = data['Atoms']
    3869         AA3letter = ['ALA','ARG','ASN','ASP','CYS','GLN','GLU','GLY','HIS','ILE',
    3870             'LEU','LYS','MET','PHE','PRO','SER','THR','TRP','TYR','VAL','MSE','HOH','WAT','UNK']
    3871         AA1letter = ['A','R','N','D','C','Q','E','G','H','I',
    3872             'L','K','M','F','P','S','T','W','Y','V','M',' ',' ',' ']
    38733850        defaultDrawing = {'viewPoint':[[0.5,0.5,0.5],[]],'showHydrogen':True,
    38743851            'backColor':[0,0,0],'depthFog':False,'Zclip':50.0,'cameraPos':50.,'Zstep':0.5,
     
    39283905        cx,ct,cs,ci = drawingData['atomPtrs']
    39293906        atomData = drawingData['Atoms']
    3930         atNames = []
    39313907        atXYZ = []
    39323908        atSymOp = []
     
    39433919                restData[PhaseName] = {}
    39443920                restData[PhaseName]['Bond'] = bondData
    3945             dist = G2mth.getRestDist(atXYZ,Amat)
    39463921            bondData['Bonds'].append([atIndx,atSymOp,1.54,0.01])
    39473922        elif event.GetId() == G2gd.wxID_DRAWRESTRANGLE and len(indx) == 3:
     
    39523927                restData[PhaseName] = {}
    39533928                restData[PhaseName]['Angle'] = angleData
    3954             angle = G2mth.getRestAngle(atXYZ,Amat)
    39553929            angleData['Angles'].append([atIndx,atSymOp,109.5,1.0])           
    39563930        elif event.GetId() == G2gd.wxID_DRAWRESTRPLANE and len(indx) > 3:
     
    39613935                restData[PhaseName] = {}
    39623936                restData[PhaseName]['Plane'] = planeData
    3963             plane = G2mth.getRestPlane(atXYZ,Amat)
    39643937            planeData['Planes'].append([atIndx,atSymOp,0.0,0.01])           
    39653938        elif event.GetId() == G2gd.wxID_DRAWRESTRCHIRAL and len(indx) == 4:
     
    39703943                restData[PhaseName] = {}
    39713944                restData[PhaseName]['Chiral'] = chiralData
    3972             volume = G2mth.getRestChiral(atXYZ,Amat)
    39733945            chiralData['Volumes'].append([atIndx,atSymOp,2.5,0.1])           
    39743946        else:
     
    40404012                    for x in sel:
    40414013                        parms.append(choice[x])
    4042                     noSkip = False
    40434014                    drawAtoms.ClearSelection()
    40444015                    drawingData['selectedAtoms'] = []
     
    40604031            elif r < 0:                          #dclick on col label
    40614032                sel = -1
    4062                 Parms = False
    4063                 noSkip = True
    40644033                if drawAtoms.GetColLabelValue(c) == 'Style':
    40654034                    dlg = wx.SingleChoiceDialog(G2frame,'Select','Atom drawing style',styleChoice)
     
    41564125        G2frame.dataFrame.SetStatusText('')
    41574126        generalData = data['General']
    4158         SpnFlp = generalData['SGData'].get('SpnFlp',[])
    41594127        SetupDrawingData()
    41604128        drawingData = data['Drawing']
     
    42694237            else:
    42704238                G2frame.dataFrame.SetStatusText('Change color, Add to Custom Colors, then OK')
    4271             generalData = data['General']
    42724239            atomData = data['Drawing']['Atoms']
    42734240            cx,ct,cs,ci = data['Drawing']['atomPtrs']
     
    44934460           
    44944461    def FillCoordSphere(event):
    4495         colLabels = [drawAtoms.GetColLabelValue(c) for c in range(drawAtoms.GetNumberCols())]
    44964462        generalData = data['General']
    44974463        Amat,Bmat = G2lat.cell2AB(generalData['Cell'][1:7])
     
    45114477            cij = ci+2
    45124478            SGData = generalData['SGData']
    4513             SpnFlp = SGData.get('SpnFlp',[])
    45144479            cellArray = G2lat.CellBlock(1)
    45154480            wx.BeginBusyCursor()
     
    47194684
    47204685    def UpdateDrawOptions():
    4721         import copy
    47224686        import wx.lib.colourselect as wcs
    47234687        def SlopSizer():           
     
    50965060        SetupDrawingData()
    50975061        drawingData = data['Drawing']
    5098         if generalData['Type'] in ['nuclear','faulted',]:
    5099             pickChoice = ['Atoms','Bonds','Torsions','Planes']
    5100         elif generalData['Type'] == 'macromolecular':
    5101             pickChoice = ['Atoms','Residues','Chains','Bonds','Torsions','Planes','phi/psi']
    51025062
    51035063        G2frame.dataFrame.SetStatusText('')
     
    53795339                'SH Coeff':[False,{}],'SHShow':False,'PFhkl':[0,0,1],
    53805340                'PFxyz':[0,0,1.],'PlotType':'Pole figure'}
    5381         if 'SHShow' not in textureData:     #another fix
     5341        if 'SHShow' not in textureData:
    53825342            textureData.update({'SHShow':False,'PFhkl':[0,0,1],'PFxyz':[0,0,1.],'PlotType':'Pole figure'})
    5383         try:                        #another fix!
    5384             x = textureData['PlotType']
    5385         except KeyError:
     5343        if 'PlotType' not in textureData:
    53865344            textureData.update({'PFxyz':[0,0,1.],'PlotType':'Pole figure'})
    53875345        if 'Penalty' not in textureData:
     
    53895347        shModels = ['cylindrical','none','shear - 2/m','rolling - mmm']
    53905348        SamSym = dict(zip(shModels,['0','-1','2/m','mmm']))
    5391         shAngles = ['omega','chi','phi']
    53925349        if Texture.GetSizer():
    53935350            Texture.GetSizer().Clear(True)
     
    55705527        UseList = data['Histograms']
    55715528        hist = G2frame.hist
    5572         useDict = {}
    55735529        keyList = G2frame.GetHistogramNames(hist[:4])
    55745530        if UseList:
     
    61276083        if dlg.ShowModal() == wx.ID_OK:
    61286084            sel = dlg.GetSelection()
    6129             name = Source[sel]
    61306085            for item in ['Orig','Orient','ThermalMotion']:
    61316086                sourceRB.update({item:RBObjs[sel][item],})
     
    63926347                mainSizer.Add((5,5),0)
    63936348                if Torsions:                   
    6394                     AtNames = data['testRBObj']['AtNames']
    6395                     rbAtTypes = data['testRBObj']['rbAtTypes']
    63966349                    rbSeq = RBData['Residue'][rbId]['rbSeq']
    63976350                    TorSizer = wx.FlexGridSizer(0,4)
     
    69646917        RBData = G2frame.PatternTree.GetItemPyData(Id)
    69656918        Indx = {}
    6966         atomStyle = 'balls & sticks'
    6967         if 'macro' in general['Type']:
    6968             atomStyle = 'sticks'
     6919#        atomStyle = 'balls & sticks'
     6920#        if 'macro' in general['Type']:
     6921#            atomStyle = 'sticks'
    69696922        G2frame.dataFrame.SetStatusText('')
    69706923        mainSizer = wx.BoxSizer(wx.VERTICAL)
     
    73087261        Sample = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,PatternId,'Sample Parameters'))
    73097262        wave = G2mth.getWave(Inst)
    7310         posCorr = Inst['Zero'][1]
    73117263        const = 9.e-2/(np.pi*Sample['Gonio. radius'])                  #shifts in microns
    73127264        gconst = 2.35482 # sqrt(8 ln 2)
     
    74927444    def OnPeaksEquiv(event):
    74937445        if 'Map Peaks' in data:
    7494             mapPeaks = data['Map Peaks']
    74957446            Ind = MapPeaks.GetSelectedRows()
    74967447            if Ind:
     
    77667717        General = data['General']
    77677718        phaseName = General['Name']
    7768         Histograms = data['Histograms']
    77697719        keyList = G2frame.GetHistogramNames('PWDR')
    77707720        histNames = []
  • trunk/GSASIIplot.py

    r2540 r2544  
    1414import math
    1515import time
    16 import copy
    1716import sys
    1817import os.path
     
    4039import GSASIIctrls as G2G
    4140import pytexture as ptx
    42 from  OpenGL.GL import *
    43 from OpenGL.GLU import *
    44 import OpenGL.GLE as gle
    45 #from OpenGL.GLE import *
     41#from  OpenGL.GL import *
     42import OpenGL.GL as GL
     43import OpenGL.GLU as GLU
    4644import gltext
    4745from matplotlib.backends.backend_wx import _load_bitmap
     
    472470        to F, F**2, etc. as requested
    473471    '''
    474     from matplotlib.patches import Circle,CirclePolygon
     472    from matplotlib.patches import Circle
    475473    global HKL,HKLF,HKLref
    476474    HKLref = hklRef
     
    587585    HKL = []
    588586    HKLF = []
    589     time0 = time.time()
    590587    sumFo = 0.
    591588    sumDF = 0.
     
    716713            print Fname+' saved'
    717714            size = Page.canvas.GetSize()
    718             glPixelStorei(GL_UNPACK_ALIGNMENT, 1)
     715            GL.glPixelStorei(GL.GL_UNPACK_ALIGNMENT, 1)
    719716            if mode in ['jpeg',]:
    720                 Pix = glReadPixels(0,0,size[0],size[1],GL_RGBA, GL_UNSIGNED_BYTE)
     717                Pix = GL.glReadPixels(0,0,size[0],size[1],GL.GL_RGBA,GL.GL_UNSIGNED_BYTE)
    721718                im = Im.new("RGBA", (size[0],size[1]))
    722719            else:
    723                 Pix = glReadPixels(0,0,size[0],size[1],GL_RGB, GL_UNSIGNED_BYTE)
     720                Pix = GL.glReadPixels(0,0,size[0],size[1],GL.GL_RGB,GL.GL_UNSIGNED_BYTE)
    724721                im = Im.new("RGB", (size[0],size[1]))
    725722            try:
     
    817814    if Super:
    818815        SuperVec = np.array(Data['SuperVec'][0])
    819     defaultViewPt = copy.copy(drawingData['viewPoint'])
    820816    Amat,Bmat = G2lat.cell2AB(cell)         #Amat - crystal to cartesian, Bmat - inverse
    821817    Gmat,gmat = G2lat.cell2Gmat(cell)
    822     invcell = G2lat.Gmat2cell(Gmat)
    823     A4mat = np.concatenate((np.concatenate((Amat,[[0],[0],[0]]),axis=1),[[0,0,0,1],]),axis=0)
    824818    B4mat = np.concatenate((np.concatenate((Bmat,[[0],[0],[0]]),axis=1),[[0,0,0,1],]),axis=0)
    825819    drawingData['Quaternion'] = G2mth.AV2Q(2*np.pi,np.inner(Bmat,[0,0,1]))
     
    827821    Rd = np.array([255,0,0])
    828822    Gr = np.array([0,255,0])
    829     wxGreen = wx.Colour(0,255,0)
    830823    Bl = np.array([0,0,255])
    831824    uBox = np.array([[0,0,0],[1,0,0],[1,1,0],[0,1,0],[0,0,1],[1,0,1],[1,1,1],[0,1,1]])
     
    844837        C = []
    845838        HKL = []
    846         RC = []
    847839        for i,refl in enumerate(hklRef):
    848840            H = refl[:3]
     
    911903
    912904    def GetTruePosition(xy):
    913         View = glGetIntegerv(GL_VIEWPORT)
    914         Proj = glGetDoublev(GL_PROJECTION_MATRIX)
    915         Model = glGetDoublev(GL_MODELVIEW_MATRIX)
     905        View = GL.glGetIntegerv(GL.GL_VIEWPORT)
     906        Proj = GL.glGetDoublev(GL.GL_PROJECTION_MATRIX)
     907        Model = GL.glGetDoublev(GL.GL_MODELVIEW_MATRIX)
    916908        Zmax = 1.
    917909        xy = [int(xy[0]),int(View[3]-xy[1])]
     
    919911            h,k,l = ref[:3]
    920912            try:
    921                 X,Y,Z = gluProject(h,k,l,Model,Proj,View)
     913                X,Y,Z = GLU.gluProject(h,k,l,Model,Proj,View)
    922914                XY = [int(X),int(Y)]
    923915                if np.allclose(xy,XY,atol=10) and Z < Zmax:
     
    968960    def SetRotationZ(newxy):                       
    969961#first get rotation vector (= view vector) in screen coords. & angle increment       
    970         View = glGetIntegerv(GL_VIEWPORT)
     962        View = GL.glGetIntegerv(GL.GL_VIEWPORT)
    971963        cent = [View[2]/2,View[3]/2]
    972964        oldxy = drawingData['oldxy']
     
    1003995            if event.LeftIsDown():
    1004996                SetRotation(newxy)
    1005                 Q = drawingData['Quaternion']
    1006997            elif event.RightIsDown():
    1007998                SetTranslation(newxy)
     
    10091000            elif event.MiddleIsDown():
    10101001                SetRotationZ(newxy)
    1011                 Q = drawingData['Quaternion']
    10121002            Draw('move')
    10131003        else:
     
    10271017    def SetBackground():
    10281018        R,G,B,A = Page.camera['backColor']
    1029         glClearColor(R,G,B,A)
    1030         glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
     1019        GL.glClearColor(R,G,B,A)
     1020        GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT)
    10311021       
    10321022    def SetLights():
    1033         glEnable(GL_DEPTH_TEST)
    1034         glShadeModel(GL_SMOOTH)
    1035         glEnable(GL_LIGHTING)
    1036         glEnable(GL_LIGHT0)
    1037         glLightModeli(GL_LIGHT_MODEL_TWO_SIDE,0)
    1038         glLightfv(GL_LIGHT0,GL_AMBIENT,[1,1,1,.8])
    1039         glLightfv(GL_LIGHT0,GL_DIFFUSE,[1,1,1,1])
     1023        GL.glEnable(GL.GL_DEPTH_TEST)
     1024        GL.glShadeModel(GL.GL_SMOOTH)
     1025        GL.glEnable(GL.GL_LIGHTING)
     1026        GL.glEnable(GL.GL_LIGHT0)
     1027        GL.glLightModeli(GL.GL_LIGHT_MODEL_TWO_SIDE,0)
     1028        GL.glLightfv(GL.GL_LIGHT0,GL.GL_AMBIENT,[1,1,1,.8])
     1029        GL.glLightfv(GL.GL_LIGHT0,GL.GL_DIFFUSE,[1,1,1,1])
    10401030       
    10411031    def RenderBox(x,y,z):
    1042         xyz = np.array([x,y,z])
    1043         glEnable(GL_COLOR_MATERIAL)
    1044         glLineWidth(1)
    1045         glPushMatrix()
    1046         glTranslate(x,y,z)
    1047         glColor4ubv([0,0,0,0])
    1048         glBegin(GL_LINES)
     1032        GL.glEnable(GL.GL_COLOR_MATERIAL)
     1033        GL.glLineWidth(1)
     1034        GL.glPushMatrix()
     1035        GL.glTranslate(x,y,z)
     1036        GL.glColor4ubv([0,0,0,0])
     1037        GL.glBegin(GL.GL_LINES)
    10491038        for line,color in zip(uEdges,uColors):
    1050             glColor3ubv(color)
    1051             glVertex3fv(line[0])
    1052             glVertex3fv(line[1])
    1053         glEnd()
    1054         glPopMatrix()
    1055         glColor4ubv([0,0,0,0])
    1056         glDisable(GL_COLOR_MATERIAL)
     1039            GL.glColor3ubv(color)
     1040            GL.glVertex3fv(line[0])
     1041            GL.glVertex3fv(line[1])
     1042        GL.glEnd()
     1043        GL.glPopMatrix()
     1044        GL.glColor4ubv([0,0,0,0])
     1045        GL.glDisable(GL.GL_COLOR_MATERIAL)
    10571046       
    10581047    def RenderUnitVectors(x,y,z,labxyz=['','','']):
    1059         xyz = np.array([x,y,z])
    1060         glEnable(GL_COLOR_MATERIAL)
    1061         glLineWidth(1)
    1062         glPushMatrix()
    1063         glTranslate(x,y,z)
    1064         glBegin(GL_LINES)
     1048        GL.glEnable(GL.GL_COLOR_MATERIAL)
     1049        GL.glLineWidth(1)
     1050        GL.glPushMatrix()
     1051        GL.glTranslate(x,y,z)
     1052        GL.glBegin(GL.GL_LINES)
    10651053        for line,color in zip(uEdges,uColors)[:3]:
    1066             glColor3ubv(color)
    1067             glVertex3fv([0,0,0])
    1068 #            glVertex3fv(-line[1])
    1069             glVertex3fv(line[1])
    1070         glEnd()
    1071         glRotate(180,1,0,0)             #fix to flip about x-axis
     1054            GL.glColor3ubv(color)
     1055            GL.glVertex3fv([0,0,0])
     1056#            GL.glVertex3fv(-line[1])
     1057            GL.glVertex3fv(line[1])
     1058        GL.glEnd()
     1059        GL.glRotate(180,1,0,0)             #fix to flip about x-axis
    10721060        for ix,txt in enumerate(labxyz):
    10731061            if txt:
    10741062                pos = uEdges[ix][1]
    1075                 glTranslate(pos[0],-1.5*pos[1],-pos[2])
     1063                GL.glTranslate(pos[0],-1.5*pos[1],-pos[2])
    10761064                text = gltext.TextElement(text=txt,font=Font)
    10771065                text.draw_text(scale=0.05)
    1078                 glTranslate(-pos[0],1.5*pos[1],pos[2])
    1079         glPopMatrix()
    1080         glColor4ubv([0,0,0,0])
    1081         glDisable(GL_COLOR_MATERIAL)
     1066                GL.glTranslate(-pos[0],1.5*pos[1],pos[2])
     1067        GL.glPopMatrix()
     1068        GL.glColor4ubv([0,0,0,0])
     1069        GL.glDisable(GL.GL_COLOR_MATERIAL)
    10821070               
    10831071    def RenderDots(XYZ,RC):
    1084         glEnable(GL_COLOR_MATERIAL)
     1072        GL.glEnable(GL.GL_COLOR_MATERIAL)
    10851073        XYZ = np.array(XYZ)
    1086         glPushMatrix()
     1074        GL.glPushMatrix()
    10871075        for xyz,rc in zip(XYZ,RC):
    10881076            x,y,z = xyz
    10891077            r,c = rc
    1090             glColor3ubv(c)
    1091             glPointSize(r*50)
    1092             glBegin(GL_POINTS)
    1093             glVertex3fv(xyz)
    1094             glEnd()
    1095         glPopMatrix()
    1096         glColor4ubv([0,0,0,0])
    1097         glDisable(GL_COLOR_MATERIAL)
     1078            GL.glColor3ubv(c)
     1079            GL.glPointSize(r*50)
     1080            GL.glBegin(GL.GL_POINTS)
     1081            GL.glVertex3fv(xyz)
     1082            GL.glEnd()
     1083        GL.glPopMatrix()
     1084        GL.glColor4ubv([0,0,0,0])
     1085        GL.glDisable(GL.GL_COLOR_MATERIAL)
    10981086       
    10991087    def Draw(caller=''):
     
    11211109       
    11221110        SetBackground()
    1123         glInitNames()
    1124         glPushName(0)
    1125        
    1126         glMatrixMode(GL_PROJECTION)
    1127         glLoadIdentity()
    1128         glViewport(0,0,VS[0],VS[1])
    1129         gluPerspective(20.,aspect,cPos-Zclip,cPos+Zclip)
    1130         gluLookAt(0,0,cPos,0,0,0,0,1,0)
     1111        GL.glInitNames()
     1112        GL.glPushName(0)
     1113       
     1114        GL.glMatrixMode(GL.GL_PROJECTION)
     1115        GL.glLoadIdentity()
     1116        GL.glViewport(0,0,VS[0],VS[1])
     1117        GLU.gluPerspective(20.,aspect,cPos-Zclip,cPos+Zclip)
     1118        GLU.gluLookAt(0,0,cPos,0,0,0,0,1,0)
    11311119        SetLights()           
    11321120           
    1133         glMatrixMode(GL_MODELVIEW)
    1134         glLoadIdentity()
     1121        GL.glMatrixMode(GL.GL_MODELVIEW)
     1122        GL.glLoadIdentity()
    11351123        matRot = G2mth.Q2Mat(Q)
    11361124        matRot = np.concatenate((np.concatenate((matRot,[[0],[0],[0]]),axis=1),[[0,0,0,1],]),axis=0)
    1137         glMultMatrixf(matRot.T)
    1138         glMultMatrixf(B4mat)
    1139         glTranslate(-Tx,-Ty,-Tz)
     1125        GL.glMultMatrixf(matRot.T)
     1126        GL.glMultMatrixf(B4mat)
     1127        GL.glTranslate(-Tx,-Ty,-Tz)
    11401128        x,y,z = drawingData['viewPoint'][0]
    11411129        if ifBox:
     
    11451133        RenderUnitVectors(0,0,0,labxyz=['h','k','l'])
    11461134        RenderDots(HKL,RC)
    1147         time0 = time.time()
    11481135        try:
    11491136            if Page.context: Page.canvas.SetCurrent(Page.context)
     
    11561143    if new:
    11571144        Page.views = False
    1158         view = False
    1159         altDown = False
    11601145    Font = Page.GetFont()
    11611146    Page.Choice = None
     
    14181403               
    14191404    def OnPress(event): #ugh - this removes a matplotlib error for mouse clicks in log plots                 
    1420         olderr = np.seterr(invalid='ignore')
     1405        np.seterr(invalid='ignore')
    14211406                                                   
    14221407    def onMoveDiffCurve(event):
     
    15171502            Page.canvas.blit(Page.figure.gca().bbox)
    15181503
     1504        try:
     1505            Parms,Parms2 = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,G2frame.PatternId, 'Instrument Parameters'))
     1506        except TypeError:
     1507            return
    15191508        if event is None: # called from a menu command rather than by click on mpl artist
    15201509            mouse = 1
     
    15371526                xy[1] = xy[1]**2
    15381527        PatternId = G2frame.PatternId
    1539         try:
    1540             Parms,Parms2 = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,G2frame.PatternId, 'Instrument Parameters'))
    1541         except TypeError:
    1542             return
    15431528        PickId = G2frame.PickId
    15441529        if G2frame.PatternTree.GetItemText(PickId) == 'Peak List':
     
    15551540                pick.set_linestyle(':') # set line as dotted
    15561541                Page = G2frame.G2plotNB.nb.GetPage(plotNum)
    1557                 Plot = Page.figure.gca()
     1542                Page.figure.gca()
    15581543                Page.canvas.draw() # refresh without dotted line & save bitmap
    15591544                savedplot = Page.canvas.copy_from_bbox(Page.figure.gca().bbox)
     
    15871572                pick.set_linestyle(':') # set line as dotted
    15881573                Page = G2frame.G2plotNB.nb.GetPage(plotNum)
    1589                 Plot = Page.figure.gca()
     1574                Page.figure.gca()
    15901575                Page.canvas.draw() # refresh without dotted line & save bitmap
    15911576                savedplot = Page.canvas.copy_from_bbox(Page.figure.gca().bbox)
     
    16101595            G2frame.itemPicked = pick
    16111596            Page = G2frame.G2plotNB.nb.GetPage(plotNum)
    1612             Plot = Page.figure.gca()
     1597            Page.figure.gca()
    16131598            if DifLine[0] is G2frame.itemPicked:  # pick of difference curve
    16141599                Page.canvas.draw() # save bitmap
     
    16521637                    pick.set_marker('|') # change the point appearance
    16531638                    Page = G2frame.G2plotNB.nb.GetPage(plotNum)
    1654                     Plot = Page.figure.gca()
     1639                    Page.figure.gca()
    16551640                    Page.canvas.draw() # refresh with changed point & save bitmap
    16561641                    savedplot = Page.canvas.copy_from_bbox(Page.figure.gca().bbox)
     
    19751960        if Pattern[1] is None: continue # skip over uncomputed simulations
    19761961        xye = ma.array(ma.getdata(Pattern[1]))
    1977         Zero = Parms.get('Zero',[0.,0.])[1]
    19781962        if PickId:
    19791963            ifpicked = Pattern[2] == G2frame.PatternTree.GetItemText(PatternId)
     
    19841968                xye[0] = ma.masked_inside(xye[0],excl[0],excl[1])
    19851969        if G2frame.plotStyle['qPlot'] and 'PWDR' in plottype:
    1986             Id = G2gd.GetPatternTreeItemId(G2frame,G2frame.root, Pattern[2])
    19871970            X = 2.*np.pi/G2lat.Pos2dsp(Parms,xye[0])
    19881971        elif G2frame.plotStyle['dPlot'] and 'PWDR' in plottype:
    1989             Id = G2gd.GetPatternTreeItemId(G2frame,G2frame.root, Pattern[2])
    19901972            X = G2lat.Pos2dsp(Parms,xye[0])
    19911973        else:
     
    22902272    new,plotNum,Page,Plot,lim = G2frame.G2plotNB.FindPlotTab('Error analysis','mpl')
    22912273    if new:
    2292         newPlot = True
    22932274        G2frame.Cmax = 1.0
    22942275    # save information needed to reload from tree and redraw
     
    23222303    EDS = np.zeros_like(DS)
    23232304    DX = np.linspace(0.,1.,num=len(DS),endpoint=True)
    2324     oldErr = np.seterr(invalid='ignore')    #avoid problem at DX==0
     2305    np.seterr(invalid='ignore')    #avoid problem at DX==0
    23252306    T = np.sqrt(np.log(1.0/DX**2))
    23262307    top = 2.515517+0.802853*T+0.010328*T**2
     
    24942475            return
    24952476        Ymax = max(Ymax,max(xye[1]))
    2496     offset = Pattern[0].get('Offset',[0,0])[0]*Ymax/100.0
    24972477    if G2frame.Contour:
    24982478        ContourZ = []
     
    29302910                G2frame.G2plotNB.status.SetStatusText('Select Strain pattern first',1)
    29312911
    2932     xylim = []
    29332912    new,plotNum,Page,Plot,lim = G2frame.G2plotNB.FindPlotTab('Size Distribution','mpl')
    29342913    if new:
    2935         newPlot = True
    29362914        G2frame.G2plotNB.Bind(wx.aui.EVT_AUINOTEBOOK_PAGE_CHANGED,OnPageChanged)
    29372915        Page.canvas.mpl_connect('motion_notify_event', OnMotion)
     
    29852963    Plot.set_title('Powder Pattern Lines')
    29862964    Plot.set_xlabel(r'$\mathsf{2\theta}$',fontsize=14)
    2987     PickId = G2frame.PickId
    29882965    PatternId = G2frame.PatternId
    29892966    peaks = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,PatternId, 'Index Peak List'))[0]
     
    30543031    Page.Choice = None
    30553032    Page.canvas.SetToolTipString('')
    3056     colors=['b','g','r','c','m','k']
    30573033    X = []
    30583034    Y = []
     
    30943070            Z = []
    30953071            W = []
    3096             V = []
    30973072            for peak in peaks:
    30983073                X.append(4.0*math.pi*sind(peak[0]/2.0)/lam)
     
    31543129        W = []
    31553130        Q = []
    3156         V = []
    31573131        for peak in peaks:
    31583132            T.append(peak[0])
     
    32233197    generalData = data['General']
    32243198    SGData = generalData['SGData']
    3225     SGLaue = SGData['SGLaue']
    32263199    if Start:                   #initialize the spherical harmonics qlmn arrays
    32273200        ptx.pyqlmninit()
     
    32293202    cell = generalData['Cell'][1:]
    32303203    Amat,Bmat = G2lat.cell2AB(cell[:6])
    3231     Vol = cell[6]
    32323204    useList = data['Histograms']
    32333205    phase = generalData['Name']
     
    32403212    if hist == '':
    32413213        hist = useList.keys()[0]
    3242     numPlots = len(useList)
    32433214
    32443215    if plotType in ['Mustrain','Size']:
     
    33263297                   
    33273298        if np.any(X) and np.any(Y) and np.any(Z):
    3328             errFlags = np.seterr(all='ignore')
     3299            np.seterr(all='ignore')
    33293300            Plot.plot_surface(X,Y,Z,rstride=1,cstride=1,color='g',linewidth=1)
    3330             np.seterr(all='ignore')
    33313301            xyzlim = np.array([Plot.get_xlim3d(),Plot.get_ylim3d(),Plot.get_zlim3d()]).T
    33323302            XYZlim = [min(xyzlim[0]),max(xyzlim[1])]
     
    33783348        else:
    33793349            obsRMD = Refs[15+ns]
    3380         ObsIVP = []
    33813350        Phi = []
    33823351        Beta = []
     
    35823551           
    35833552            if np.any(X) and np.any(Y) and np.any(Z):
    3584                 errFlags = np.seterr(all='ignore')
     3553                np.seterr(all='ignore')
    35853554                Plot.plot_surface(X,Y,Z,rstride=1,cstride=1,color='g',linewidth=1)
    35863555                np.seterr(all='ignore')
     
    35963565                Plot.set_zlabel(r'Z, MRD')
    35973566        else:
    3598             PFproj = textureData.get('PFproj','XY')
    3599             PRrev = textureData.get('PFrev',False)
    36003567            X,Y = np.meshgrid(np.linspace(1.,-1.,npts),np.linspace(-1.,1.,npts))
    36013568            R,P = np.sqrt(X**2+Y**2).flatten(),npatan2d(X,Y).flatten()
     
    36443611    def OnPlotKeyPress(event):
    36453612        global Off,Atom,Ax
    3646         newPlot = False
    36473613        if event.key == '0':
    36483614            Off = 0
     
    37463712    varyList = Data['varyList']
    37473713    values = Data['variables']
    3748     Xmax = len(varyList)
    37493714    covMatrix = Data['covMatrix']
    37503715    sig = np.sqrt(np.diag(covMatrix))
     
    37563721
    37573722    def OnPlotKeyPress(event):
    3758         newPlot = False
    37593723        if event.key == 's':
    37603724            choice = [m for m in mpl.cm.datad.keys() if not m.endswith("_r")]
     
    38323796    ylabs = [varyList[int(i)] for i in ytics[:-1]]
    38333797    imgAx.set_yticklabels(ylabs)
    3834     colorBar = Page.figure.colorbar(Img)
     3798    Page.figure.colorbar(Img)
    38353799    Plot.set_title('V-Cov matrix'+title)
    38363800    Plot.set_xlabel('Variable number')
     
    39103874    names = Names
    39113875    rama = np.log(2*Rama+1.)
    3912     ramaMax = np.max(rama)
    39133876    rama = np.reshape(rama,(45,45))
    39143877    global Phi,Psi
     
    39173880
    39183881    def OnPlotKeyPress(event):
    3919         newPlot = False
    39203882        if event.key == 's':
    39213883            choice = [m for m in mpl.cm.datad.keys() if not m.endswith("_r")]
     
    39953957    Plot.set_xlabel(r'$\phi$',fontsize=16)
    39963958    Plot.set_ylabel(r'$\psi$',fontsize=16)
    3997     colorBar = Page.figure.colorbar(Img)
     3959    Page.figure.colorbar(Img)
    39983960    Page.canvas.draw()
    39993961
     
    41754137    :param bool newImage: If True, the Figure is cleared and redrawn
    41764138    '''
    4177     from matplotlib.patches import Ellipse,Arc,Circle,Polygon
     4139    from matplotlib.patches import Ellipse,Circle
    41784140    import numpy.ma as ma
    41794141    Dsp = lambda tth,wave: wave/(2.*npsind(tth/2.))
     
    42514213            if event.key in ['a',]:
    42524214                G2frame.StrainKey = event.key
    4253                 StrSta = OnStartNewDzero(G2frame)
     4215                OnStartNewDzero(G2frame)
    42544216                wx.CallAfter(PlotImage,G2frame,newImage=False)
    42554217               
     
    44594421                    for poly in G2frame.polyList:   #merging points problem here?
    44604422                        if Obj == poly[0]:
    4461                             ind = G2frame.itemPicked.contains(G2frame.mousePicked)[1]['ind'][0]
     4423#                            ind = G2frame.itemPicked.contains(G2frame.mousePicked)[1]['ind'][0]
    44624424                            oldPos = np.array([G2frame.mousePicked.xdata,G2frame.mousePicked.ydata])
    44634425                            pN = poly[1]
     
    45274489    sizexy = Data['size']
    45284490    pixelSize = Data['pixelSize']
    4529     scalex = 1000./pixelSize[0]
    4530     scaley = 1000./pixelSize[1]
    45314491    Xmax = sizexy[0]*pixelSize[0]/1000.
    45324492    Ymax = sizexy[1]*pixelSize[1]/1000.
     
    45534513                AM = np.where(AM>0,np.log(AM),0)
    45544514                Imin,Imax = [np.amin(A),np.amax(A)]
    4555             ImgM = Plot.imshow(AM,aspect='equal',cmap='Reds',
     4515            Plot.imshow(AM,aspect='equal',cmap='Reds',
    45564516                interpolation='nearest',vmin=0,vmax=2,extent=[0,Xmax,Ymax,0])
    45574517            Img = Plot.imshow(A,aspect='equal',cmap=acolor,
     
    46794639            Plot.plot(x,y,'g')           
    46804640        if newImage:
    4681             colorBar = Page.figure.colorbar(Img)
     4641            Page.figure.colorbar(Img)
    46824642        Plot.set_xlim(xlim)
    46834643        Plot.set_ylim(ylim)
     
    47264686        Page.canvas.mpl_connect('motion_notify_event', OnMotion)
    47274687        Page.views = False
    4728         view = False
    47294688    Page.Choice = None
    47304689       
     
    47414700    Img = Plot.imshow(image,cmap=acolor,vmin=Imin,vmax=Imax,interpolation='nearest', \
    47424701        extent=[ysc[0],ysc[-1],xsc[-1],xsc[0]],aspect='auto')
    4743     colorBar = Page.figure.colorbar(Img)
     4702    Page.figure.colorbar(Img)
    47444703#    if Data['ellipses']:           
    47454704#        for ellipse in Data['ellipses']:
     
    47824741        Page.canvas.mpl_connect('motion_notify_event', OnMotion)
    47834742        Page.views = False
    4784         view = False
    47854743    Page.Choice = None
    47864744    Data = G2frame.PatternTree.GetItemPyData(
     
    48584816    B4mat = np.concatenate((np.concatenate((Bmat,[[0],[0],[0]]),axis=1),[[0,0,0,1],]),axis=0)
    48594817    SGData = generalData['SGData']
    4860     if generalData['Modulated']:
    4861         SSGData = generalData['SSGData']
    48624818    SpnFlp = SGData.get('SpnFlp',[1,])
    4863     Mydir = generalData['Mydir']
    4864     Super = generalData.get('Super',0)
    48654819    atomData = data['Atoms']
    48664820    mapPeaks = []
     
    49094863    mapData = {}
    49104864    flipData = {}
    4911     rhoXYZ = []
    49124865    showBonds = False
    49134866    if 'Map' in generalData:
     
    49354888    Bc = np.array(list(drawingData['backColor']))
    49364889    uColors = [Rd,Gr,Bl,Wt-Bc, Wt-Bc,Wt-Bc,Wt-Bc,Wt-Bc, Wt-Bc,Wt-Bc,Wt-Bc,Wt-Bc]
    4937     altDown = False
    4938     shiftDown = False
    4939     ctrlDown = False
    49404890    G2frame.tau = 0.
    49414891   
     
    49544904            Fname = (os.path.splitext(projFile)[0]+'.'+mode).replace('*','+')
    49554905            size = Page.canvas.GetSize()
    4956             glPixelStorei(GL_UNPACK_ALIGNMENT, 1)
     4906            GL.glPixelStorei(GL.GL_UNPACK_ALIGNMENT, 1)
    49574907            if mode in ['jpeg',]:
    4958                 Pix = glReadPixels(0,0,size[0],size[1],GL_RGBA, GL_UNSIGNED_BYTE)
     4908                Pix = GL.glReadPixels(0,0,size[0],size[1],GL.GL_RGBA, GL.GL_UNSIGNED_BYTE)
    49594909                im = Im.new("RGBA", (size[0],size[1]))
    49604910            else:
    4961                 Pix = glReadPixels(0,0,size[0],size[1],GL_RGB, GL_UNSIGNED_BYTE)
     4911                Pix = GL.glReadPixels(0,0,size[0],size[1],GL.GL_RGB, GL.GL_UNSIGNED_BYTE)
    49624912                im = Im.new("RGB", (size[0],size[1]))
    49634913            try:
     
    50935043           
    50945044    def GetTruePosition(xy,Add=False):
    5095         View = glGetIntegerv(GL_VIEWPORT)
    5096         Proj = glGetDoublev(GL_PROJECTION_MATRIX)
    5097         Model = glGetDoublev(GL_MODELVIEW_MATRIX)
     5045        View = GL.glGetIntegerv(GL.GL_VIEWPORT)
     5046        Proj = GL.glGetDoublev(GL.GL_PROJECTION_MATRIX)
     5047        Model = GL.glGetDoublev(GL.GL_MODELVIEW_MATRIX)
    50985048        Zmax = 1.
    50995049        if Add:
     
    51025052            for i,peak in enumerate(mapPeaks):
    51035053                x,y,z = peak[1:4]
    5104                 X,Y,Z = gluProject(x,y,z,Model,Proj,View)
     5054                X,Y,Z = GLU.GLU.gluProject(x,y,z,Model,Proj,View)
    51055055                XY = [int(X),int(View[3]-Y)]
    51065056                if np.allclose(xy,XY,atol=10) and Z < Zmax:
     
    51175067            for i,atom in enumerate(drawAtoms):
    51185068                x,y,z = atom[cx:cx+3]
    5119                 X,Y,Z = gluProject(x,y,z,Model,Proj,View)
     5069                X,Y,Z = GLU.gluProject(x,y,z,Model,Proj,View)
    51205070                XY = [int(X),int(View[3]-Y)]
    51215071                if np.allclose(xy,XY,atol=10) and Z < Zmax:
     
    52865236    def SetBackground():
    52875237        R,G,B,A = Page.camera['backColor']
    5288         glClearColor(R,G,B,A)
    5289         glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
     5238        GL.glClearColor(R,G,B,A)
     5239        GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT)
    52905240       
    52915241    def SetLights():
    5292         glEnable(GL_DEPTH_TEST)
    5293         glShadeModel(GL_SMOOTH)
    5294         glEnable(GL_LIGHTING)
    5295         glEnable(GL_LIGHT0)
    5296         glLightModeli(GL_LIGHT_MODEL_TWO_SIDE,0)
    5297         glLightfv(GL_LIGHT0,GL_AMBIENT,[.1,.1,.1,1])
    5298         glLightfv(GL_LIGHT0,GL_DIFFUSE,[.8,.8,.8,1])
     5242        GL.glEnable(GL.GL_DEPTH_TEST)
     5243        GL.glShadeModel(GL.GL_SMOOTH)
     5244        GL.glEnable(GL.GL_LIGHTING)
     5245        GL.glEnable(GL.GL_LIGHT0)
     5246        GL.glLightModeli(GL.GL_LIGHT_MODEL_TWO_SIDE,0)
     5247        GL.glLightfv(GL.GL_LIGHT0,GL.GL_AMBIENT,[.1,.1,.1,1])
     5248        GL.glLightfv(GL.GL_LIGHT0,GL.GL_DIFFUSE,[.8,.8,.8,1])
    52995249#        glLightfv(GL_LIGHT0,GL_SPECULAR,[1,1,1,1])
    53005250#        glLightfv(GL_LIGHT0,GL_POSITION,[0,0,1,1])
     
    53875337    def SetRotationZ(newxy):                       
    53885338#first get rotation vector (= view vector) in screen coords. & angle increment       
    5389         View = glGetIntegerv(GL_VIEWPORT)
     5339        View = GL.glGetIntegerv(GL.GL_VIEWPORT)
    53905340        cent = [View[2]/2,View[3]/2]
    53915341        oldxy = drawingData['oldxy']
     
    54315381    def SetRBRotationZ(newxy):                       
    54325382#first get rotation vector (= view vector) in screen coords. & angle increment       
    5433         View = glGetIntegerv(GL_VIEWPORT)
     5383        View = GL.glGetIntegerv(GL.GL_VIEWPORT)
    54345384        cent = [View[2]/2,View[3]/2]
    54355385        oldxy = drawingData['oldxy']
     
    54575407
    54585408    def RenderBox():
    5459         glEnable(GL_COLOR_MATERIAL)
    5460         glLineWidth(2)
    5461         glEnable(GL_BLEND)
    5462         glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA)
    5463         glEnable(GL_LINE_SMOOTH)
    5464         glBegin(GL_LINES)
     5409        GL.glEnable(GL.GL_COLOR_MATERIAL)
     5410        GL.glLineWidth(2)
     5411        GL.glEnable(GL.GL_BLEND)
     5412        GL.glBlendFunc(GL.GL_SRC_ALPHA,GL.GL_ONE_MINUS_SRC_ALPHA)
     5413        GL.glEnable(GL.GL_LINE_SMOOTH)
     5414        GL.glBegin(GL.GL_LINES)
    54655415        for line,color in zip(uEdges,uColors):
    5466             glColor3ubv(color)
    5467             glVertex3fv(line[0])
    5468             glVertex3fv(line[1])
    5469         glEnd()
    5470         glColor4ubv([0,0,0,0])
    5471         glDisable(GL_LINE_SMOOTH)
    5472         glDisable(GL_BLEND)
    5473         glDisable(GL_COLOR_MATERIAL)
     5416            GL.glColor3ubv(color)
     5417            GL.glVertex3fv(line[0])
     5418            GL.glVertex3fv(line[1])
     5419        GL.glEnd()
     5420        GL.glColor4ubv([0,0,0,0])
     5421        GL.glDisable(GL.GL_LINE_SMOOTH)
     5422        GL.glDisable(GL.GL_BLEND)
     5423        GL.glDisable(GL.GL_COLOR_MATERIAL)
    54745424       
    54755425    def RenderUnitVectors(x,y,z):
    5476         xyz = np.array([x,y,z])
    5477         glEnable(GL_COLOR_MATERIAL)
    5478         glLineWidth(2)
    5479         glEnable(GL_BLEND)
    5480         glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA)
    5481         glEnable(GL_LINE_SMOOTH)
    5482         glPushMatrix()
    5483         glTranslate(x,y,z)
    5484         glScalef(1/cell[0],1/cell[1],1/cell[2])
    5485         glBegin(GL_LINES)
     5426        GL.glEnable(GL.GL_COLOR_MATERIAL)
     5427        GL.glLineWidth(2)
     5428        GL.glEnable(GL.GL_BLEND)
     5429        GL.glBlendFunc(GL.GL_SRC_ALPHA,GL.GL_ONE_MINUS_SRC_ALPHA)
     5430        GL.glEnable(GL.GL_LINE_SMOOTH)
     5431        GL.glPushMatrix()
     5432        GL.glTranslate(x,y,z)
     5433        GL.glScalef(1/cell[0],1/cell[1],1/cell[2])
     5434        GL.glBegin(GL.GL_LINES)
    54865435        for line,color in zip(uEdges,uColors)[:3]:
    5487             glColor3ubv(color)
    5488             glVertex3fv(-line[1]/2.)
    5489             glVertex3fv(line[1]/2.)
    5490         glEnd()
    5491         glPopMatrix()
    5492         glColor4ubv([0,0,0,0])
    5493         glDisable(GL_LINE_SMOOTH)
    5494         glDisable(GL_BLEND)
    5495         glDisable(GL_COLOR_MATERIAL)
     5436            GL.glColor3ubv(color)
     5437            GL.glVertex3fv(-line[1]/2.)
     5438            GL.glVertex3fv(line[1]/2.)
     5439        GL.glEnd()
     5440        GL.glPopMatrix()
     5441        GL.glColor4ubv([0,0,0,0])
     5442        GL.glDisable(GL.GL_LINE_SMOOTH)
     5443        GL.glDisable(GL.GL_BLEND)
     5444        GL.glDisable(GL.GL_COLOR_MATERIAL)
    54965445       
    54975446    def RenderPlane(plane,color):
    54985447        fade = list(color) + [.25,]
    5499         glMaterialfv(GL_FRONT_AND_BACK,GL_AMBIENT_AND_DIFFUSE,fade)
    5500         glShadeModel(GL_FLAT)
    5501         glEnable(GL_BLEND)
    5502         glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA)
    5503         glPushMatrix()
    5504         glShadeModel(GL_SMOOTH)
    5505         glPolygonMode(GL_FRONT_AND_BACK,GL_FILL)
    5506         glFrontFace(GL_CW)
    5507         glBegin(GL_TRIANGLE_FAN)
     5448        GL.glMaterialfv(GL.GL_FRONT_AND_BACK,GL.GL_AMBIENT_AND_DIFFUSE,fade)
     5449        GL.glShadeModel(GL.GL_FLAT)
     5450        GL.glEnable(GL.GL_BLEND)
     5451        GL.glBlendFunc(GL.GL_SRC_ALPHA,GL.GL_ONE_MINUS_SRC_ALPHA)
     5452        GL.glPushMatrix()
     5453        GL.glShadeModel(GL.GL_SMOOTH)
     5454        GL.glPolygonMode(GL.GL_FRONT_AND_BACK,GL.GL_FILL)
     5455        GL.glFrontFace(GL.GL_CW)
     5456        GL.glBegin(GL.GL_TRIANGLE_FAN)
    55085457        for vertex in plane:
    5509             glVertex3fv(vertex)
    5510         glEnd()
    5511         glPopMatrix()
    5512         glDisable(GL_BLEND)
    5513         glShadeModel(GL_SMOOTH)
     5458            GL.glVertex3fv(vertex)
     5459        GL.glEnd()
     5460        GL.glPopMatrix()
     5461        GL.glDisable(GL.GL_BLEND)
     5462        GL.glShadeModel(GL.GL_SMOOTH)
    55145463               
    55155464    def RenderSphere(x,y,z,radius,color):
    5516         glMaterialfv(GL_FRONT_AND_BACK,GL_DIFFUSE,color)
    5517         glPushMatrix()
    5518         glTranslate(x,y,z)
    5519         glMultMatrixf(B4mat.T)
    5520         q = gluNewQuadric()
    5521         gluSphere(q,radius,20,10)
    5522         glPopMatrix()
     5465        GL.glMaterialfv(GL.GL_FRONT_AND_BACK,GL.GL_DIFFUSE,color)
     5466        GL.glPushMatrix()
     5467        GL.glTranslate(x,y,z)
     5468        GL.glMultMatrixf(B4mat.T)
     5469        q = GLU.gluNewQuadric()
     5470        GLU.gluSphere(q,radius,20,10)
     5471        GL.glPopMatrix()
    55235472       
    55245473    def RenderDots(XYZ,RC):
    5525         glEnable(GL_COLOR_MATERIAL)
     5474        GL.glEnable(GL.GL_COLOR_MATERIAL)
    55265475        XYZ = np.array(XYZ)
    5527         glPushMatrix()
     5476        GL.glPushMatrix()
    55285477        for xyz,rc in zip(XYZ,RC):
    55295478            x,y,z = xyz
    55305479            r,c = rc
    5531             glColor3ubv(c)
    5532             glPointSize(r*50)
    5533             glBegin(GL_POINTS)
    5534             glVertex3fv(xyz)
    5535             glEnd()
    5536         glPopMatrix()
    5537         glColor4ubv([0,0,0,0])
    5538         glDisable(GL_COLOR_MATERIAL)
     5480            GL.glColor3ubv(c)
     5481            GL.glPointSize(r*50)
     5482            GL.glBegin(GL.GL_POINTS)
     5483            GL.glVertex3fv(xyz)
     5484            GL.glEnd()
     5485        GL.glPopMatrix()
     5486        GL.glColor4ubv([0,0,0,0])
     5487        GL.glDisable(GL.GL_COLOR_MATERIAL)
    55395488       
    55405489    def RenderSmallSphere(x,y,z,radius,color):
    5541         glMaterialfv(GL_FRONT_AND_BACK,GL_DIFFUSE,color)
    5542         glPushMatrix()
    5543         glTranslate(x,y,z)
    5544         glMultMatrixf(B4mat.T)
    5545         q = gluNewQuadric()
    5546         gluSphere(q,radius,4,2)
    5547         glPopMatrix()
     5490        GL.glMaterialfv(GL.GL_FRONT_AND_BACK,GL.GL_DIFFUSE,color)
     5491        GL.glPushMatrix()
     5492        GL.glTranslate(x,y,z)
     5493        GL.glMultMatrixf(B4mat.T)
     5494        q = GLU.gluNewQuadric()
     5495        GLU.gluSphere(q,radius,4,2)
     5496        GL.glPopMatrix()
    55485497               
    55495498    def RenderEllipsoid(x,y,z,ellipseProb,E,R4,color):
    55505499        s1,s2,s3 = E
    5551         glMaterialfv(GL_FRONT_AND_BACK,GL_DIFFUSE,color)
    5552         glPushMatrix()
    5553         glTranslate(x,y,z)
    5554         glMultMatrixf(B4mat.T)
    5555         glMultMatrixf(R4.T)
    5556         glEnable(GL_NORMALIZE)
    5557         glScale(s1,s2,s3)
    5558         q = gluNewQuadric()
    5559         gluSphere(q,ellipseProb,20,10)
    5560         glDisable(GL_NORMALIZE)
    5561         glPopMatrix()
     5500        GL.glMaterialfv(GL.GL_FRONT_AND_BACK,GL.GL_DIFFUSE,color)
     5501        GL.glPushMatrix()
     5502        GL.glTranslate(x,y,z)
     5503        GL.glMultMatrixf(B4mat.T)
     5504        GL.glMultMatrixf(R4.T)
     5505        GL.glEnable(GL.GL_NORMALIZE)
     5506        GL.glScale(s1,s2,s3)
     5507        q = GLU.gluNewQuadric()
     5508        GLU.gluSphere(q,ellipseProb,20,10)
     5509        GL.glDisable(GL.GL_NORMALIZE)
     5510        GL.glPopMatrix()
    55625511       
    55635512    def RenderBonds(x,y,z,Bonds,radius,color,slice=20):
    5564         glMaterialfv(GL_FRONT_AND_BACK,GL_DIFFUSE,color)
    5565         glPushMatrix()
    5566         glTranslate(x,y,z)
    5567         glMultMatrixf(B4mat.T)
     5513        GL.glMaterialfv(GL.GL_FRONT_AND_BACK,GL.GL_DIFFUSE,color)
     5514        GL.glPushMatrix()
     5515        GL.glTranslate(x,y,z)
     5516        GL.glMultMatrixf(B4mat.T)
    55685517        for bond in Bonds:
    5569             glPushMatrix()
     5518            GL.glPushMatrix()
    55705519            Dx = np.inner(Amat,bond)
    55715520            Z = np.sqrt(np.sum(Dx**2))
     
    55735522                azm = atan2d(-Dx[1],-Dx[0])
    55745523                phi = acosd(Dx[2]/Z)
    5575                 glRotate(-azm,0,0,1)
    5576                 glRotate(phi,1,0,0)
    5577                 q = gluNewQuadric()
    5578                 gluCylinder(q,radius,radius,Z,slice,2)
    5579             glPopMatrix()           
    5580         glPopMatrix()
     5524                GL.glRotate(-azm,0,0,1)
     5525                GL.glRotate(phi,1,0,0)
     5526                q = GLU.gluNewQuadric()
     5527                GLU.gluCylinder(q,radius,radius,Z,slice,2)
     5528            GL.glPopMatrix()           
     5529        GL.glPopMatrix()
    55815530       
    55825531    def RenderMoment(x,y,z,Moment,color,slice=20):
     
    55845533        Z = np.sqrt(np.sum(Dx**2))
    55855534        if Z:
    5586             glMaterialfv(GL_FRONT_AND_BACK,GL_DIFFUSE,color)
    5587             glPushMatrix()
    5588             glTranslate(x,y,z)
    5589             glMultMatrixf(B4mat.T)
    5590             glTranslate(-Dx[0],-Dx[1],-Dx[2])
     5535            GL.glMaterialfv(GL.GL_FRONT_AND_BACK,GL.GL_DIFFUSE,color)
     5536            GL.glPushMatrix()
     5537            GL.glTranslate(x,y,z)
     5538            GL.glMultMatrixf(B4mat.T)
     5539            GL.glTranslate(-Dx[0],-Dx[1],-Dx[2])
    55915540            azm = atan2d(-Dx[1],-Dx[0])
    55925541            phi = acosd(Dx[2]/Z)
    5593             glRotate(-azm,0,0,1)
    5594             glRotate(phi,1,0,0)
    5595             q = gluNewQuadric()
    5596             gluQuadricOrientation(q,GLU_INSIDE)
    5597             gluDisk(q,0.,.1,slice,1)
    5598             gluQuadricOrientation(q,GLU_OUTSIDE)
    5599             gluCylinder(q,.1,.1,2.*Z,slice,2)
    5600             glTranslate(0,0,2*Z)
    5601             gluQuadricOrientation(q,GLU_INSIDE)
    5602             gluDisk(q,.1,.2,slice,1)
    5603             gluQuadricOrientation(q,GLU_OUTSIDE)
    5604             gluCylinder(q,.2,0.,.4,slice,2)
    5605             glPopMatrix()           
     5542            GL.glRotate(-azm,0,0,1)
     5543            GL.glRotate(phi,1,0,0)
     5544            q = GLU.gluNewQuadric()
     5545            GLU.gluQuadricOrientation(q,GLU.GLU_INSIDE)
     5546            GLU.gluDisk(q,0.,.1,slice,1)
     5547            GLU.gluQuadricOrientation(q,GLU.GLU_OUTSIDE)
     5548            GLU.gluCylinder(q,.1,.1,2.*Z,slice,2)
     5549            GL.glTranslate(0,0,2*Z)
     5550            GLU.gluQuadricOrientation(q,GLU.GLU_INSIDE)
     5551            GLU.gluDisk(q,.1,.2,slice,1)
     5552            GLU.gluQuadricOrientation(q,GLU.GLU_OUTSIDE)
     5553            GLU.gluCylinder(q,.2,0.,.4,slice,2)
     5554            GL.glPopMatrix()           
    56065555               
    56075556    def RenderLines(x,y,z,Bonds,color):
    5608         glShadeModel(GL_FLAT)
     5557        GL.glShadeModel(GL.GL_FLAT)
    56095558        xyz = np.array([x,y,z])
    5610         glEnable(GL_COLOR_MATERIAL)
    5611         glLineWidth(1)
    5612         glColor3fv(color)
    5613         glPushMatrix()
    5614         glBegin(GL_LINES)
     5559        GL.glEnable(GL.GL_COLOR_MATERIAL)
     5560        GL.glLineWidth(1)
     5561        GL.glColor3fv(color)
     5562        GL.glPushMatrix()
     5563        GL.glBegin(GL.GL_LINES)
    56155564        for bond in Bonds:
    5616             glVertex3fv(xyz)
    5617             glVertex3fv(xyz+bond)
    5618         glEnd()
    5619         glColor4ubv([0,0,0,0])
    5620         glPopMatrix()
    5621         glDisable(GL_COLOR_MATERIAL)
    5622         glShadeModel(GL_SMOOTH)
     5565            GL.glVertex3fv(xyz)
     5566            GL.glVertex3fv(xyz+bond)
     5567        GL.glEnd()
     5568        GL.glColor4ubv([0,0,0,0])
     5569        GL.glPopMatrix()
     5570        GL.glDisable(GL.GL_COLOR_MATERIAL)
     5571        GL.glShadeModel(GL.GL_SMOOTH)
    56235572       
    56245573    def RenderPolyhedra(x,y,z,Faces,color):
    5625         glShadeModel(GL_FLAT)
    5626         glPushMatrix()
    5627         glTranslate(x,y,z)
    5628         glMaterialfv(GL_FRONT_AND_BACK,GL_DIFFUSE,color)
    5629         glShadeModel(GL_SMOOTH)
    5630         glMultMatrixf(B4mat.T)
     5574        GL.glShadeModel(GL.GL_FLAT)
     5575        GL.glPushMatrix()
     5576        GL.glTranslate(x,y,z)
     5577        GL.glMaterialfv(GL.GL_FRONT_AND_BACK,GL.GL_DIFFUSE,color)
     5578        GL.glShadeModel(GL.GL_SMOOTH)
     5579        GL.glMultMatrixf(B4mat.T)
    56315580        for face,norm in Faces:
    5632             glPolygonMode(GL_FRONT_AND_BACK,GL_FILL)
    5633             glFrontFace(GL_CW)
    5634             glNormal3fv(norm)
    5635             glBegin(GL_TRIANGLES)
     5581            GL.glPolygonMode(GL.GL_FRONT_AND_BACK,GL.GL_FILL)
     5582            GL.glFrontFace(GL.GL_CW)
     5583            GL.glNormal3fv(norm)
     5584            GL.glBegin(GL.GL_TRIANGLES)
    56365585            for vert in face:
    5637                 glVertex3fv(vert)
    5638             glEnd()
    5639         glPopMatrix()
    5640         glShadeModel(GL_SMOOTH)
     5586                GL.glVertex3fv(vert)
     5587            GL.glEnd()
     5588        GL.glPopMatrix()
     5589        GL.glShadeModel(GL.GL_SMOOTH)
    56415590
    56425591    def RenderMapPeak(x,y,z,color,den):
    5643         glShadeModel(GL_FLAT)
     5592        GL.glShadeModel(GL.GL_FLAT)
    56445593        xyz = np.array([x,y,z])
    5645         glEnable(GL_COLOR_MATERIAL)
    5646         glLineWidth(3)
    5647         glColor3fv(color*den/255)
    5648         glPushMatrix()
    5649         glBegin(GL_LINES)
     5594        GL.glEnable(GL.GL_COLOR_MATERIAL)
     5595        GL.glLineWidth(3)
     5596        GL.glColor3fv(color*den/255)
     5597        GL.glPushMatrix()
     5598        GL.glBegin(GL.GL_LINES)
    56505599        for vec in mapPeakVecs:
    5651             glVertex3fv(vec[0]+xyz)
    5652             glVertex3fv(vec[1]+xyz)
    5653         glEnd()
    5654         glColor4ubv([0,0,0,0])
    5655         glPopMatrix()
    5656         glDisable(GL_COLOR_MATERIAL)
    5657         glShadeModel(GL_SMOOTH)
     5600            GL.glVertex3fv(vec[0]+xyz)
     5601            GL.glVertex3fv(vec[1]+xyz)
     5602        GL.glEnd()
     5603        GL.glColor4ubv([0,0,0,0])
     5604        GL.glPopMatrix()
     5605        GL.glDisable(GL.GL_COLOR_MATERIAL)
     5606        GL.glShadeModel(GL.GL_SMOOTH)
    56585607       
    56595608    def RenderBackbone(Backbone,BackboneColor,radius):
    5660         glPushMatrix()
    5661         glMultMatrixf(B4mat.T)
    5662         glEnable(GL_COLOR_MATERIAL)
    5663         glShadeModel(GL_SMOOTH)
     5609        GL.glPushMatrix()
     5610        GL.glMultMatrixf(B4mat.T)
     5611        GL.glEnable(GL.GL_COLOR_MATERIAL)
     5612        GL.glShadeModel(GL.GL_SMOOTH)
    56645613#        gle.gleSetJoinStyle(TUBE_NORM_EDGE | TUBE_JN_ANGLE | TUBE_JN_CAP)
    56655614#        gle.glePolyCylinder(Backbone,BackboneColor,radius)
    5666         glPopMatrix()       
    5667         glDisable(GL_COLOR_MATERIAL)
     5615        GL.glPopMatrix()       
     5616        GL.glDisable(GL.GL_COLOR_MATERIAL)
    56685617       
    56695618    def RenderLabel(x,y,z,label,r,color,matRot):
     
    56715620        color wx.Colour object
    56725621        '''       
    5673         glPushMatrix()
    5674         glTranslate(x,y,z)
    5675         glMultMatrixf(B4mat.T)
    5676         glDisable(GL_LIGHTING)
    5677         glRasterPos3f(0,0,0)
    5678         glMultMatrixf(matRot)
    5679         glRotate(180,1,0,0)             #fix to flip about x-axis
     5622        GL.glPushMatrix()
     5623        GL.glTranslate(x,y,z)
     5624        GL.glMultMatrixf(B4mat.T)
     5625        GL.glDisable(GL.GL_LIGHTING)
     5626        GL.glRasterPos3f(0,0,0)
     5627        GL.glMultMatrixf(matRot)
     5628        GL.glRotate(180,1,0,0)             #fix to flip about x-axis
    56805629        text = gltext.Text(text=label,font=Font,foreground=color)
    56815630        text.draw_text(scale=0.025)
    5682         glEnable(GL_LIGHTING)
    5683         glPopMatrix()
     5631        GL.glEnable(GL.GL_LIGHTING)
     5632        GL.glPopMatrix()
    56845633       
    56855634    def RenderMap(rho,rhoXYZ,indx,Rok):
    5686         glShadeModel(GL_FLAT)
     5635        GL.glShadeModel(GL.GL_FLAT)
    56875636        cLevel = drawingData['contourLevel']
    56885637        XYZ = []
     
    57025651                    RC.append([0.1*alpha,Gr])
    57035652        RenderDots(XYZ,RC)
    5704         glShadeModel(GL_SMOOTH)
     5653        GL.glShadeModel(GL.GL_SMOOTH)
    57055654                           
    57065655    def Draw(caller='',Fade=[]):
     
    57575706       
    57585707        SetBackground()
    5759         glInitNames()
    5760         glPushName(0)
    5761        
    5762         glMatrixMode(GL_PROJECTION)
    5763         glLoadIdentity()
    5764         glViewport(0,0,VS[0],VS[1])
    5765         gluPerspective(20.,aspect,cPos-Zclip,cPos+Zclip)
    5766         gluLookAt(0,0,cPos,0,0,0,0,1,0)
     5708        GL.glInitNames()
     5709        GL.glPushName(0)
     5710       
     5711        GL.glMatrixMode(GL.GL_PROJECTION)
     5712        GL.glLoadIdentity()
     5713        GL.glViewport(0,0,VS[0],VS[1])
     5714        GLU.gluPerspective(20.,aspect,cPos-Zclip,cPos+Zclip)
     5715        GLU.gluLookAt(0,0,cPos,0,0,0,0,1,0)
    57675716        SetLights()           
    57685717           
    5769         glMatrixMode(GL_MODELVIEW)
    5770         glLoadIdentity()
     5718        GL.glMatrixMode(GL.GL_MODELVIEW)
     5719        GL.glLoadIdentity()
    57715720        matRot = G2mth.Q2Mat(Q)
    57725721        matRot = np.concatenate((np.concatenate((matRot,[[0],[0],[0]]),axis=1),[[0,0,0,1],]),axis=0)
    5773         glMultMatrixf(matRot.T)
    5774         glMultMatrixf(A4mat.T)
    5775         glTranslate(-Tx,-Ty,-Tz)
     5722        GL.glMultMatrixf(matRot.T)
     5723        GL.glMultMatrixf(A4mat.T)
     5724        GL.glTranslate(-Tx,-Ty,-Tz)
    57765725        if drawingData['showABC']:
    57775726            x,y,z = drawingData['viewPoint'][0]
     
    57795728        Backbones = {}
    57805729        BackboneColor = []
    5781         time0 = time.time()
    57825730#        glEnable(GL_BLEND)
    57835731#        glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA)
     
    58085756            if atom[cs] != '':
    58095757                try:
    5810                     glLoadName(atom[-3])
     5758                    GL.glLoadName(atom[-3])
    58115759                except: #problem with old files - missing code
    58125760                    pass
     
    59505898    if new:
    59515899        Page.views = False
    5952         view = False
    5953         altDown = False
    59545900    Font = Page.GetFont()
    59555901    Page.Choice = None
     
    60165962                       
    60175963    Mydir = G2frame.dirname
    6018     Wt = np.array([255,255,255])
    60195964    Rd = np.array([255,0,0])
    60205965    Gr = np.array([0,255,0])
     
    60826027    def SetBackground():
    60836028        R,G,B,A = Page.camera['backColor']
    6084         glClearColor(R,G,B,A)
    6085         glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
     6029        GL.glClearColor(R,G,B,A)
     6030        GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT)
    60866031       
    60876032    def SetLights():
    6088         glEnable(GL_DEPTH_TEST)
    6089         glShadeModel(GL_FLAT)
    6090         glEnable(GL_LIGHTING)
    6091         glEnable(GL_LIGHT0)
    6092         glLightModeli(GL_LIGHT_MODEL_TWO_SIDE,0)
    6093         glLightfv(GL_LIGHT0,GL_AMBIENT,[1,1,1,.8])
    6094         glLightfv(GL_LIGHT0,GL_DIFFUSE,[1,1,1,1])
     6033        GL.glEnable(GL.GL_DEPTH_TEST)
     6034        GL.glShadeModel(GL.GL_FLAT)
     6035        GL.glEnable(GL.GL_LIGHTING)
     6036        GL.glEnable(GL.GL_LIGHT0)
     6037        GL.glLightModeli(GL.GL_LIGHT_MODEL_TWO_SIDE,0)
     6038        GL.glLightfv(GL.GL_LIGHT0,GL.GL_AMBIENT,[1,1,1,.8])
     6039        GL.glLightfv(GL.GL_LIGHT0,GL.GL_DIFFUSE,[1,1,1,1])
    60956040       
    60966041    def SetRotation(newxy):
     
    61166061    def SetRotationZ(newxy):                       
    61176062#first get rotation vector (= view vector) in screen coords. & angle increment       
    6118         View = glGetIntegerv(GL_VIEWPORT)
     6063        View = GL.glGetIntegerv(GL.GL_VIEWPORT)
    61196064        cent = [View[2]/2,View[3]/2]
    61206065        oldxy = defaults['oldxy']
     
    61396084
    61406085    def RenderUnitVectors(x,y,z):
    6141         xyz = np.array([x,y,z])
    6142         glEnable(GL_COLOR_MATERIAL)
    6143         glLineWidth(1)
    6144         glPushMatrix()
    6145         glTranslate(x,y,z)
    6146         glBegin(GL_LINES)
     6086        GL.glEnable(GL.GL_COLOR_MATERIAL)
     6087        GL.glLineWidth(1)
     6088        GL.glPushMatrix()
     6089        GL.glTranslate(x,y,z)
     6090        GL.glBegin(GL.GL_LINES)
    61476091        for line,color in zip(uEdges,uColors):
    6148             glColor3ubv(color)
    6149             glVertex3fv(-line[1])
    6150             glVertex3fv(line[1])
    6151         glEnd()
    6152         glPopMatrix()
    6153         glColor4ubv([0,0,0,0])
    6154         glDisable(GL_COLOR_MATERIAL)
     6092            GL.glColor3ubv(color)
     6093            GL.glVertex3fv(-line[1])
     6094            GL.glVertex3fv(line[1])
     6095        GL.glEnd()
     6096        GL.glPopMatrix()
     6097        GL.glColor4ubv([0,0,0,0])
     6098        GL.glDisable(GL.GL_COLOR_MATERIAL)
    61556099               
    61566100    def RenderSphere(x,y,z,radius,color):
    6157         glMaterialfv(GL_FRONT_AND_BACK,GL_DIFFUSE,color)
    6158         glPushMatrix()
    6159         glTranslate(x,y,z)
    6160         q = gluNewQuadric()
    6161         gluSphere(q,radius,20,10)
    6162         glPopMatrix()
     6101        GL.glMaterialfv(GL.GL_FRONT_AND_BACK,GL.GL_DIFFUSE,color)
     6102        GL.glPushMatrix()
     6103        GL.glTranslate(x,y,z)
     6104        q = GLU.gluNewQuadric()
     6105        GLU.gluSphere(q,radius,20,10)
     6106        GL.glPopMatrix()
    61636107       
    61646108    def RenderBonds(x,y,z,Bonds,radius,color,slice=20):
    6165         glMaterialfv(GL_FRONT_AND_BACK,GL_DIFFUSE,color)
    6166         glPushMatrix()
    6167         glTranslate(x,y,z)
     6109        GL.glMaterialfv(GL.GL_FRONT_AND_BACK,GL.GL_DIFFUSE,color)
     6110        GL.glPushMatrix()
     6111        GL.glTranslate(x,y,z)
    61686112        for Dx in Bonds:
    6169             glPushMatrix()
     6113            GL.glPushMatrix()
    61706114            Z = np.sqrt(np.sum(Dx**2))
    61716115            if Z:
    61726116                azm = atan2d(-Dx[1],-Dx[0])
    61736117                phi = acosd(Dx[2]/Z)
    6174                 glRotate(-azm,0,0,1)
    6175                 glRotate(phi,1,0,0)
    6176                 q = gluNewQuadric()
    6177                 gluCylinder(q,radius,radius,Z,slice,2)
    6178             glPopMatrix()           
    6179         glPopMatrix()
     6118                GL.glRotate(-azm,0,0,1)
     6119                GL.glRotate(phi,1,0,0)
     6120                q = GLU.gluNewQuadric()
     6121                GLU.gluCylinder(q,radius,radius,Z,slice,2)
     6122            GL.glPopMatrix()           
     6123        GL.glPopMatrix()
    61806124               
    61816125    def RenderLabel(x,y,z,label,matRot):       
    6182         glPushMatrix()
    6183         glTranslate(x,y,z)
    6184         glDisable(GL_LIGHTING)
    6185         glRasterPos3f(0,0,0)
    6186         glMultMatrixf(matRot)
    6187         glRotate(180,1,0,0)             #fix to flip about x-axis
     6126        GL.glPushMatrix()
     6127        GL.glTranslate(x,y,z)
     6128        GL.glDisable(GL.GL_LIGHTING)
     6129        GL.glRasterPos3f(0,0,0)
     6130        GL.glMultMatrixf(matRot)
     6131        GL.glRotate(180,1,0,0)             #fix to flip about x-axis
    61886132        text = gltext.TextElement(text=label,font=Font,foreground=wx.WHITE)
    61896133        text.draw_text(scale=0.025)
    6190         glEnable(GL_LIGHTING)
    6191         glPopMatrix()
     6134        GL.glEnable(GL.GL_LIGHTING)
     6135        GL.glPopMatrix()
    61926136       
    61936137    def Draw(caller=''):
     
    61996143        VS = np.array(Page.canvas.GetSize())
    62006144        aspect = float(VS[0])/float(VS[1])
    6201         Zclip = 500.0
    62026145        Q = defaults['Quaternion']
    62036146        SetBackground()
    6204         glInitNames()
    6205         glPushName(0)
    6206        
    6207         glMatrixMode(GL_PROJECTION)
    6208         glLoadIdentity()
    6209         glViewport(0,0,VS[0],VS[1])
    6210         gluPerspective(20.,aspect,1.,500.)
    6211         gluLookAt(0,0,cPos,0,0,0,0,1,0)
     6147        GL.glInitNames()
     6148        GL.glPushName(0)
     6149       
     6150        GL.glMatrixMode(GL.GL_PROJECTION)
     6151        GL.glLoadIdentity()
     6152        GL.glViewport(0,0,VS[0],VS[1])
     6153        GLU.gluPerspective(20.,aspect,1.,500.)
     6154        GLU.gluLookAt(0,0,cPos,0,0,0,0,1,0)
    62126155        SetLights()           
    62136156           
    6214         glMatrixMode(GL_MODELVIEW)
    6215         glLoadIdentity()
     6157        GL.glMatrixMode(GL.GL_MODELVIEW)
     6158        GL.glLoadIdentity()
    62166159        matRot = G2mth.Q2Mat(Q)
    62176160        matRot = np.concatenate((np.concatenate((matRot,[[0],[0],[0]]),axis=1),[[0,0,0,1],]),axis=0)
    6218         glMultMatrixf(matRot.T)
     6161        GL.glMultMatrixf(matRot.T)
    62196162        RenderUnitVectors(0.,0.,0.)
    62206163        radius = 0.2
     
    62506193            print Fname+' saved'
    62516194            size = Page.canvas.GetSize()
    6252             glPixelStorei(GL_UNPACK_ALIGNMENT, 1)
     6195            GL.glPixelStorei(GL.GL_UNPACK_ALIGNMENT, 1)
    62536196            if mode in ['jpeg',]:
    6254                 Pix = glReadPixels(0,0,size[0],size[1],GL_RGBA, GL_UNSIGNED_BYTE)
     6197                Pix = GL.glReadPixels(0,0,size[0],size[1],GL.GL_RGBA, GL.GL_UNSIGNED_BYTE)
    62556198                im = Im.new("RGBA", (size[0],size[1]))
    62566199            else:
    6257                 Pix = glReadPixels(0,0,size[0],size[1],GL_RGB, GL_UNSIGNED_BYTE)
     6200                Pix = GL.glReadPixels(0,0,size[0],size[1],GL.GL_RGB, GL.GL_UNSIGNED_BYTE)
    62586201                im = Im.new("RGB", (size[0],size[1]))
    62596202            try:
     
    62706213    if new:
    62716214        Page.views = False
    6272         view = False
    6273         altDown = False
    62746215    Page.name = rbData['RBname']
    62756216    Page.Choice = None
     
    63476288        na = max(int(8./cell[0]),1)
    63486289        nb = max(int(8./cell[1]),1)
    6349         nunit = [na,nb,0]
    63506290        indA = range(-na,na)
    63516291        indB = range(-nb,nb)
     
    63766316            Fname = (os.path.splitext(projFile)[0]+'.'+mode).replace('*','+')
    63776317            size = Page.canvas.GetSize()
    6378             glPixelStorei(GL_UNPACK_ALIGNMENT, 1)
     6318            GL.glPixelStorei(GL.GL_UNPACK_ALIGNMENT, 1)
    63796319            if mode in ['jpeg',]:
    6380                 Pix = glReadPixels(0,0,size[0],size[1],GL_RGBA, GL_UNSIGNED_BYTE)
     6320                Pix = GL.glReadPixels(0,0,size[0],size[1],GL.GL_RGBA, GL.GL_UNSIGNED_BYTE)
    63816321                im = Im.new("RGBA", (size[0],size[1]))
    63826322            else:
    6383                 Pix = glReadPixels(0,0,size[0],size[1],GL_RGB, GL_UNSIGNED_BYTE)
     6323                Pix = GL.glReadPixels(0,0,size[0],size[1],GL.GL_RGB, GL.GL_UNSIGNED_BYTE)
    63846324                im = Im.new("RGB", (size[0],size[1]))
    63856325            try:
     
    64556395            if event.LeftIsDown():
    64566396                SetRotation(newxy)
    6457                 Q = defaults['Quaternion']
    64586397            elif event.RightIsDown():
    64596398                SetTranslation(newxy)
     
    64616400            elif event.MiddleIsDown():
    64626401                SetRotationZ(newxy)
    6463                 Q = defaults['Quaternion']
    64646402            Draw('move')
    64656403       
     
    64716409    def SetBackground():
    64726410        R,G,B,A = Page.camera['backColor']
    6473         glClearColor(R,G,B,A)
    6474         glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
     6411        GL.glClearColor(R,G,B,A)
     6412        GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT)
    64756413       
    64766414    def SetLights():
    6477         glEnable(GL_DEPTH_TEST)
    6478         glShadeModel(GL_FLAT)
    6479         glEnable(GL_LIGHTING)
    6480         glEnable(GL_LIGHT0)
    6481         glLightModeli(GL_LIGHT_MODEL_TWO_SIDE,0)
    6482         glLightfv(GL_LIGHT0,GL_AMBIENT,[1,1,1,.8])
    6483         glLightfv(GL_LIGHT0,GL_DIFFUSE,[1,1,1,1])
     6415        GL.glEnable(GL.GL_DEPTH_TEST)
     6416        GL.glShadeModel(GL.GL_FLAT)
     6417        GL.glEnable(GL.GL_LIGHTING)
     6418        GL.glEnable(GL.GL_LIGHT0)
     6419        GL.glLightModeli(GL.GL_LIGHT_MODEL_TWO_SIDE,0)
     6420        GL.glLightfv(GL.GL_LIGHT0,GL.GL_AMBIENT,[1,1,1,.8])
     6421        GL.glLightfv(GL.GL_LIGHT0,GL.GL_DIFFUSE,[1,1,1,1])
    64846422       
    64856423    def SetTranslation(newxy):
     
    65226460    def SetRotationZ(newxy):                       
    65236461#first get rotation vector (= view vector) in screen coords. & angle increment       
    6524         View = glGetIntegerv(GL_VIEWPORT)
     6462        View = GL.glGetIntegerv(GL.GL_VIEWPORT)
    65256463        cent = [View[2]/2,View[3]/2]
    65266464        oldxy = defaults['oldxy']
     
    65456483
    65466484    def RenderUnitVectors(x,y,z):
    6547         xyz = np.array([x,y,z])
    6548         glEnable(GL_COLOR_MATERIAL)
    6549         glLineWidth(1)
    6550         glPushMatrix()
    6551         glTranslate(x,y,z)
    6552         glBegin(GL_LINES)
     6485        GL.glEnable(GL.GL_COLOR_MATERIAL)
     6486        GL.glLineWidth(1)
     6487        GL.glPushMatrix()
     6488        GL.glTranslate(x,y,z)
     6489        GL.glBegin(GL.GL_LINES)
    65536490        for line,color in zip(uEdges,uColors):
    6554             glColor3ubv(color)
    6555             glVertex3fv(line[0])
    6556             glVertex3fv(line[1])
    6557         glEnd()
    6558         glPopMatrix()
    6559         glColor4ubv([0,0,0,0])
    6560         glDisable(GL_COLOR_MATERIAL)
     6491            GL.glColor3ubv(color)
     6492            GL.glVertex3fv(line[0])
     6493            GL.glVertex3fv(line[1])
     6494        GL.glEnd()
     6495        GL.glPopMatrix()
     6496        GL.glColor4ubv([0,0,0,0])
     6497        GL.glDisable(GL.GL_COLOR_MATERIAL)
    65616498               
    65626499    def RenderSphere(x,y,z,radius,color):
    6563         glMaterialfv(GL_FRONT_AND_BACK,GL_DIFFUSE,color)
    6564         glPushMatrix()
    6565         glTranslate(x,y,z)
    6566         glMultMatrixf(B4mat.T)
    6567         q = gluNewQuadric()
    6568         gluSphere(q,radius,20,10)
    6569         glPopMatrix()
     6500        GL.glMaterialfv(GL.GL_FRONT_AND_BACK,GL.GL_DIFFUSE,color)
     6501        GL.glPushMatrix()
     6502        GL.glTranslate(x,y,z)
     6503        GL.glMultMatrixf(B4mat.T)
     6504        q = GLU.gluNewQuadric()
     6505        GLU.gluSphere(q,radius,20,10)
     6506        GL.glPopMatrix()
    65706507       
    65716508    def RenderBonds(x,y,z,Bonds,radius,color,slice=20):
    6572         glMaterialfv(GL_FRONT_AND_BACK,GL_DIFFUSE,color)
    6573         glPushMatrix()
    6574         glTranslate(x,y,z)
    6575         glMultMatrixf(B4mat.T)
     6509        GL.glMaterialfv(GL.GL_FRONT_AND_BACK,GL.GL_DIFFUSE,color)
     6510        GL.glPushMatrix()
     6511        GL.glTranslate(x,y,z)
     6512        GL.glMultMatrixf(B4mat.T)
    65766513        for Dx in Bonds:
    6577             glPushMatrix()
     6514            GL.glPushMatrix()
    65786515            Z = np.sqrt(np.sum(Dx**2))
    65796516            if Z:
    65806517                azm = atan2d(-Dx[1],-Dx[0])
    65816518                phi = acosd(Dx[2]/Z)
    6582                 glRotate(-azm,0,0,1)
    6583                 glRotate(phi,1,0,0)
    6584                 q = gluNewQuadric()
    6585                 gluCylinder(q,radius,radius,Z,slice,2)
    6586             glPopMatrix()           
    6587         glPopMatrix()
     6519                GL.glRotate(-azm,0,0,1)
     6520                GL.glRotate(phi,1,0,0)
     6521                q = GLU.gluNewQuadric()
     6522                GLU.gluCylinder(q,radius,radius,Z,slice,2)
     6523            GL.glPopMatrix()           
     6524        GL.glPopMatrix()
    65886525               
    65896526    def RenderLabel(x,y,z,label,matRot):       
    6590         glPushMatrix()
    6591         glTranslate(x,y,z)
    6592         glMultMatrixf(B4mat.T)
    6593         glDisable(GL_LIGHTING)
    6594         glRasterPos3f(0,0,0)
    6595         glMultMatrixf(matRot)
    6596         glRotate(180,1,0,0)             #fix to flip about x-axis
     6527        GL.glPushMatrix()
     6528        GL.glTranslate(x,y,z)
     6529        GL.glMultMatrixf(B4mat.T)
     6530        GL.glDisable(GL.GL_LIGHTING)
     6531        GL.glRasterPos3f(0,0,0)
     6532        GL.glMultMatrixf(matRot)
     6533        GL.glRotate(180,1,0,0)             #fix to flip about x-axis
    65976534        text = gltext.TextElement(text=label,font=Font,foreground=wx.WHITE)
    65986535        text.draw_text(scale=0.025)
    6599         glEnable(GL_LIGHTING)
    6600         glPopMatrix()
     6536        GL.glEnable(GL.GL_LIGHTING)
     6537        GL.glPopMatrix()
    66016538       
    66026539    def Draw(caller=''):
     
    66096546        VS = np.array(Page.canvas.GetSize())
    66106547        aspect = float(VS[0])/float(VS[1])
    6611         Zclip = 500.0
    66126548        Tx,Ty,Tz = defaults['viewPoint'][0]
    66136549        Q = defaults['Quaternion']
    66146550        SetBackground()
    6615         glInitNames()
    6616         glPushName(0)
    6617        
    6618         glMatrixMode(GL_PROJECTION)
    6619         glLoadIdentity()
    6620         glViewport(0,0,VS[0],VS[1])
    6621         gluPerspective(20.,aspect,1.,500.)
    6622         gluLookAt(0,0,cPos,0,0,0,0,1,0)
     6551        GL.glInitNames()
     6552        GL.glPushName(0)
     6553       
     6554        GL.glMatrixMode(GL.GL_PROJECTION)
     6555        GL.glLoadIdentity()
     6556        GL.glViewport(0,0,VS[0],VS[1])
     6557        GLU.gluPerspective(20.,aspect,1.,500.)
     6558        GLU.gluLookAt(0,0,cPos,0,0,0,0,1,0)
    66236559        SetLights()           
    66246560           
    6625         glMatrixMode(GL_MODELVIEW)
    6626         glLoadIdentity()
     6561        GL.glMatrixMode(GL.GL_MODELVIEW)
     6562        GL.glLoadIdentity()
    66276563        matRot = G2mth.Q2Mat(Q)
    66286564        matRot = np.concatenate((np.concatenate((matRot,[[0],[0],[0]]),axis=1),[[0,0,0,1],]),axis=0)
    6629         glMultMatrixf(matRot.T)
    6630         glMultMatrixf(A4mat.T)
    6631         glTranslate(-Tx,-Ty,-Tz)
     6565        GL.glMultMatrixf(matRot.T)
     6566        GL.glMultMatrixf(A4mat.T)
     6567        GL.glTranslate(-Tx,-Ty,-Tz)
    66326568        RenderUnitVectors(0.,0.,0.)
    66336569        bondRad = 0.1
     
    66366572            bondRad = 0.05
    66376573            atomRad = 0.2
    6638         glShadeModel(GL_SMOOTH)
     6574        GL.glShadeModel(GL.GL_SMOOTH)
    66396575        for iat,atom in enumerate(XYZ):
    66406576            x,y,z = atom
     
    66836619        Page.labels = False
    66846620        Page.fade = False
    6685         view = False
    6686         altDown = False
    66876621    choice = [' save as:','jpeg','tiff','bmp','use keys for:','L - toggle labels']
    66886622    if len(laySeq) == 2:
  • trunk/GSASIIpwdGUI.py

    r2525 r2544  
    4343import GSASIIElem as G2elem
    4444import GSASIIsasd as G2sasd
    45 import GSASIIexprGUI as G2exG
    4645VERY_LIGHT_GREY = wx.Colour(235,235,235)
    4746WACV = wx.ALIGN_CENTER_VERTICAL
     
    9190        self.panel.Destroy()
    9291        self.panel = wx.Panel(self)
    93         Ind = {}
    9492        mainSizer = wx.BoxSizer(wx.VERTICAL)
    9593        mainSizer.Add(wx.StaticText(self.panel,label='Background RDF controls:'),0,WACV)
     
    426424    def OnAutoSearch(event):
    427425        PatternId = G2frame.PatternId
    428         PickId = G2frame.PickId
    429426        limits = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,PatternId, 'Limits'))[1]
    430427        inst,inst2 = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,PatternId, 'Instrument Parameters'))
     
    631628        print 'Peak Fitting with '+controls['deriv type']+' derivatives:'
    632629        PatternId = G2frame.PatternId
    633         PickId = G2frame.PickId
    634630        peaks = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,PatternId, 'Peak List'))
    635631        if not peaks:
     
    661657    def OnResetSigGam(event):
    662658        PatternId = G2frame.PatternId
    663         PickId = G2frame.PickId
    664659        Inst,Inst2 = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,PatternId, 'Instrument Parameters'))
    665660        peaks = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,PatternId, 'Peak List'))
     
    674669               
    675670    def RefreshPeakGrid(event):
    676         r,c =  event.GetRow(),event.GetCol()
    677671       
    678672        event.StopPropagation()
     
    10391033        PatternId = G2frame.PatternId       
    10401034        background = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,PatternId, 'Background'))
    1041         limits = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,PatternId, 'Limits'))[1]
    10421035        inst,inst2 = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,PatternId, 'Instrument Parameters'))
    10431036        pwddata = G2frame.PatternTree.GetItemPyData(PatternId)[1]
     
    14021395            G2frame.ErrorDialog('No match','No histograms match '+hst,G2frame.dataFrame)
    14031396            return
    1404         copyList = []
    14051397        dlg = G2G.G2MultiChoiceDialog(
    14061398            G2frame.dataFrame,
     
    19361928                        fmt = '%12.6g'
    19371929                        nDig = (12,6)
    1938                     Fmt = ' %s: ('+fmt+')'
    19391930                    instSizer.Add(
    19401931                            wx.StaticText(G2frame.dataDisplay,-1,lblWdef(item,nDig[1],insDef[item])),
     
    20452036        insDef = dict(zip(instkeys,[data[key][0] for key in instkeys]))
    20462037        insRef = {}
    2047     ValObj = {}
    20482038    RefObj = {}
    20492039    waves = {'CuKa':[1.54051,1.54433],'TiKa':[2.74841,2.75207],'CrKa':[2.28962,2.29351],
     
    26302620    def KeyEditPickGrid(event):
    26312621        colList = G2frame.dataDisplay.GetSelectedCols()
    2632         rowList = G2frame.dataDisplay.GetSelectedRows()
    26332622        data = G2frame.PatternTree.GetItemPyData(IndexId)
    26342623        if event.GetKeyCode() == wx.WXK_RETURN:
     
    28822871       
    28832872    def SetCellValue(Obj,ObjId,value):
    2884         ibrav = bravaisSymb.index(controls[5])
    28852873        if controls[5] in ['Fm3m','Im3m','Pm3m']:
    28862874            controls[6] = controls[7] = controls[8] = value
     
    29652953    def OnHklShow(event):
    29662954        PatternId = G2frame.PatternId
    2967         PickId = G2frame.PickId   
    29682955        peaks = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,PatternId, 'Index Peak List'))
    2969         limits = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,PatternId, 'Limits'))[1]
    29702956        controls,bravais,cells,dminx,ssopt = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,PatternId, 'Unit Cells List'))
    29712957        cell = controls[6:12]
     
    30503036             
    30513037        PatternId = G2frame.PatternId
    3052         PickId = G2frame.PickId   
    30533038        peaks = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,PatternId, 'Index Peak List'))
    30543039        if not len(peaks[0]):
     
    34303415            3*[wg.GRID_VALUE_FLOAT+':10,5',]+3*[wg.GRID_VALUE_FLOAT+':10,3',]+ \
    34313416            [wg.GRID_VALUE_FLOAT+':10,2',wg.GRID_VALUE_BOOL]
    3432         numRows = len(cells)
    34333417        table = []
    34343418        for cell in cells:
     
    35533537        else:
    35543538            Super = 0
    3555             SuperVec = []       
    35563539        rowLabels = []
    35573540        if HKLF:
     
    46724655        data['BackFile'] = backFile.GetValue()
    46734656        if data['BackFile']:
    4674             fixBack =  data['Back'][0]
    46754657            BackId = G2gd.GetPatternTreeItemId(G2frame,G2frame.root,data['BackFile'])
    46764658            BackSample = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,BackId, 'Sample Parameters'))
     
    47874769    else:                                #initial setting at 90% of max Q
    47884770        data['QScaleLim'][0] = 0.90*data['QScaleLim'][1]
    4789     azimuth = inst['Azimuth'][1]
    47904771    itemDict = {}
    47914772    #patch
     
    49154896        G2plt.PlotISFG(G2frame,newPlot=False)
    49164897       
    4917     def OnPolaVal(event):
    4918         event.Skip()
    4919         try:
    4920             value = float(polaVal.GetValue())
    4921             if not (0.0 <= value <= 1.0):
    4922                 raise ValueError
    4923         except ValueError:
    4924             value = inst['Polariz.'][1]
    4925         inst['Polariz.'][1] = value
    4926         polaVal.SetValue('%.2f'%(inst['Polariz.'][1]))
    4927         UpdatePDFGrid(G2frame,data)
    4928         auxPlot = ComputePDF(data)
    4929         G2plt.PlotISFG(G2frame,newPlot=False)
    4930                
    4931     def OnAzimVal(event):
    4932         event.Skip()
    4933         try:
    4934             value = float(azimVal.GetValue())
    4935             if not (0. <= value <= 360.):
    4936                 raise ValueError
    4937         except ValueError:
    4938             value = inst['Azimuth'][1]
    4939         inst['Azimuth'][1] = value
    4940         azimVal.SetValue('%.1f'%(inst['Azimuth'][1]))
    4941         UpdatePDFGrid(G2frame,data)
    4942         auxPlot = ComputePDF(data)
    4943         G2plt.PlotISFG(G2frame,newPlot=False)
    4944                        
     4898#    def OnPolaVal(event):
     4899#        event.Skip()
     4900#        try:
     4901#            value = float(polaVal.GetValue())
     4902#            if not (0.0 <= value <= 1.0):
     4903#                raise ValueError
     4904#        except ValueError:
     4905#            value = inst['Polariz.'][1]
     4906#        inst['Polariz.'][1] = value
     4907#        polaVal.SetValue('%.2f'%(inst['Polariz.'][1]))
     4908#        UpdatePDFGrid(G2frame,data)
     4909#        auxPlot = ComputePDF(data)
     4910#        G2plt.PlotISFG(G2frame,newPlot=False)
     4911#               
     4912#    def OnAzimVal(event):
     4913#        event.Skip()
     4914#        try:
     4915#            value = float(azimVal.GetValue())
     4916#            if not (0. <= value <= 360.):
     4917#                raise ValueError
     4918#        except ValueError:
     4919#            value = inst['Azimuth'][1]
     4920#        inst['Azimuth'][1] = value
     4921#        azimVal.SetValue('%.1f'%(inst['Azimuth'][1]))
     4922#        UpdatePDFGrid(G2frame,data)
     4923#        auxPlot = ComputePDF(data)
     4924#        G2plt.PlotISFG(G2frame,newPlot=False)
     4925#                       
    49454926    def OnObliqCoeff(event):
    49464927        event.Skip()
     
    51385119            if name:
    51395120                xydata[key] = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,G2frame.root,name))
    5140                 PDFname = name
    51415121        powName = Data['Sample']['Name']
    51425122        powId = G2gd.GetPatternTreeItemId(G2frame,G2frame.root,powName)
  • trunk/GSASIIspc.py

    r2492 r2544  
    1616########### SVN repository information ###################
    1717import numpy as np
    18 import numpy.ma as ma
    1918import numpy.linalg as nl
    2019import scipy.optimize as so
    21 import math
    2220import sys
    2321import copy
     
    10871085               
    10881086    def extendSSGOps(SSGOps):
    1089         nOps = len(SSGOps)
    10901087        for OpA in SSGOps:
    10911088            OpAtxt = SSMT2text(OpA)
     
    17651762    OpM = np.array([op[0] for op in Ops],order='F')
    17661763    OpT = np.array([op[1] for op in Ops])
    1767     Inv = SGData['SGInv']
    17681764    Cen = np.array([cen for cen in SGData['SGCen']],order='F')
    17691765   
     
    19321928    '  2(+0-)':( 9,22, 9,19),'  m(+0-)':(19,22, 9,19),'2/m(+0-)':( 1,22, 0,-1),'   2(xy)':( 6,19, 6,18),
    19331929    '   m(xy)':(18,19, 6,18),' 2/m(xy)':( 1,19, 0,-1),'  2(+-0)':( 7,20, 7,17),'  m(+-0)':(17,20, 7,17),
    1934     '2/m(+-0)':( 1,20, 0,-1),'  mm2(x)':(12,10, 0,-1),'  mm2(y)':(13,10, 0,-1),'  mm2(z)':(14,10, 0,-1),
     1930    '2/m(+-0)':( 1,20, 17,-1),'  mm2(x)':(12,10, 0,-1),'  mm2(y)':(13,10, 0,-1),'  mm2(z)':(14,10, 0,-1),
    19351931    ' mm2(yz)':(10,13, 0,-1),'mm2(0+-)':(11,13, 0,-1),' mm2(xz)':( 8,12, 0,-1),'mm2(+0-)':( 9,12, 0,-1),
    19361932    ' mm2(xy)':( 6,11, 0,-1),'mm2(+-0)':( 7,11, 0,-1),'  222   ':( 1,10, 0,-1),'  222(x)':( 1,13, 0,-1),
     
    21662162        delt2 = np.eye(2)*0.001
    21672163        FSC = np.ones(2,dtype='i')
    2168         VFSC = np.ones(2)
    21692164        CSI = [np.zeros((2),dtype='i'),np.zeros(2)]
    21702165        if 'Crenel' in waveType:
     
    24112406            [[1.,0.,0.],[1.,0.,0.],[1.,0.,0.], [1.,0.,0.],[1.,0.,0.],[1.,0.,0.]]],}
    24122407    xyz = np.array(XYZ)%1.
    2413     xyzt = np.array(XYZ+[0,])%1.
    24142408    SGOps = copy.deepcopy(SGData['SGOps'])
    24152409    laue = SGData['SGLaue']
     
    26892683
    26902684    '''
    2691     SymName = ''
    26922685    Mult = 1
    26932686    Isym = 0
     
    27252718    So far I have the element type... getting all possible locations without lookup may be impossible!
    27262719    '''
    2727     SymElements = []
    27282720    Inv = SGData['SGInv']
    2729     Cen = SGData['SGCen']
    27302721    eleSym = {-3:['','-1'],-2:['',-6],-1:['2','-4'],0:['3','-3'],1:['4','m'],2:['6',''],3:['1','']}
    27312722    # get operators & expand if centrosymmetric
     
    34143405#66       
    34153406    'C c c m':['(00g)','(00g)s00','(10g)','(10g)s00','(0b0)','(0b0)00s','(0b0)s0s','(0b0)s00',],
    3416     'A m m a':['(a00)','(a00)0s0','(a10)','(a10)0s0','(00g)','(00g)s00','(00g)ss0','(00g)0s0',],
     3407    'A a m a':['(a00)','(a00)0s0','(a10)','(a10)0s0','(00g)','(00g)s00','(00g)ss0','(00g)0s0',],
    34173408    'B b m b':['(0b0)','(0b0)00s','(0b1)','(0b1)00s','(a00)','(a00)0s0','(a00)0ss','(a00)00s',],
    34183409#67       
     
    37743765        result = SpcGroup(spc)
    37753766        if result[0] == referr and referr > 0: return True
    3776         keys = result[1].keys()
    3777         #print result[1]['SpGrp']
     3767#        #print result[1]['SpGrp']
    37783768        #msg = msg0 + " in list lengths"
    37793769        #assert len(keys) == len(refdict.keys()), msg
Note: See TracChangeset for help on using the changeset viewer.