Changeset 2544
- Timestamp:
- Nov 21, 2016 4:40:02 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASII.py
r2542 r2544 1103 1103 1104 1104 ibanks = int(Iparm.get('INS BANK ','1').strip()) 1105 hType = Iparm['INS HTYPE '].strip()1106 1105 if ibanks == 1: # there is only one bank here, return it 1107 1106 rd.instbank = 1 … … 1651 1650 while item: # loop over (new) phases 1652 1651 iph += 1 1653 phaseName = self.PatternTree.GetItemText(item)1654 1652 data = self.PatternTree.GetItemPyData(item) 1655 1653 item, cookie = self.PatternTree.GetNextChild(sub, cookie) … … 1818 1816 while item: # loop over (new) phases 1819 1817 iph += 1 1820 phaseName = self.PatternTree.GetItemText(item)1821 1818 data = self.PatternTree.GetItemPyData(item) 1822 1819 item, cookie = self.PatternTree.GetNextChild(sub, cookie) … … 1888 1885 if len(rdlist) == 0: return 1889 1886 self.CheckNotebook() 1890 Iparm = None1891 lastdatafile = ''1892 1887 newHistList = [] 1893 1888 self.EnablePlot = False 1894 1889 for rd in rdlist: 1895 lastdatafile = rd.smallangleentry[0]1896 1890 HistName = rd.idstring 1897 1891 HistName = 'SASD '+HistName … … 2123 2117 path,rootname = os.path.split(filename) 2124 2118 pkg = os.path.splitext(rootname)[0] 2125 try:2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 except AttributeError:2140 print 'Import_'+errprefix+': Attribute Error'+str(filename)2141 pass2142 except ImportError:2143 print 'Import_'+errprefix+': Error importing file'+str(filename)2144 pass2119 # 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 2145 2139 if fp: fp.close() 2146 2140 # Add submenu item(s) for each Exporter by its self-declared type (can be more than one) … … 2468 2462 if pltNum >= 0: #to avoid the startup with no plot! 2469 2463 pltPage = self.G2plotNB.nb.GetPage(pltNum) 2470 pltPlot = pltPage.figure2471 2464 item = event.GetItem() 2472 2465 G2gd.MovePatternTreeToGrid(self,item) … … 2564 2557 def OnReadPowderPeaks(self,event): 2565 2558 'Bound to menu Data/Read Powder Peaks' 2566 Cuka = 1.540522567 2559 self.CheckNotebook() 2568 2560 pth = G2G.GetImportPath(self) … … 2777 2769 TextList = [] 2778 2770 DataList = [] 2779 SumList = []2780 2771 Names = [] 2781 2772 Inst = None 2782 SumItemList = []2783 2773 Comments = ['Sum equals: \n'] 2784 2774 if self.PatternTree.GetCount(): … … 2881 2871 TextList = [] 2882 2872 DataList = [] 2883 SumList = []2884 2873 Names = [] 2885 Inst = []2886 SumItemList = []2887 2874 Comments = ['Sum equals: \n'] 2888 2875 if self.PatternTree.GetCount(): … … 3101 3088 DelItemList = [] 3102 3089 nItems = {'PWDR':0,'SASD':0,'IMG':0,'HKLF':0,'PDF':0} 3103 ifPWDR = False3104 ifSASD = False3105 ifIMG = False3106 ifHKLF = False3107 ifPDF = False3108 3090 if self.PatternTree.GetCount(): 3109 3091 item, cookie = self.PatternTree.GetFirstChild(self.root) … … 3112 3094 if name not in ['Notebook','Controls','Covariance','Constraints', 3113 3095 'Restraints','Phases','Rigid bodies'] or 'Sequential' not in name: 3114 if 'PWDR' in name: ifPWDR = True;nItems['PWDR'] += 13115 if 'SASD' in name: ifSASD = True;nItems['SASD'] += 13116 if 'IMG' in name: ifIMG = True;nItems['IMG'] += 13117 if 'HKLF' in name: ifHKLF = True;nItems['HKLF'] += 13118 if 'PDF' in name: ifPDF = True;nItems['PDF'] += 13096 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 3119 3101 TextList.append(name) 3120 3102 item, cookie = self.PatternTree.GetNextChild(self.root, cookie) … … 3449 3431 '''Calculates PDFs 3450 3432 ''' 3451 sind = lambda x: math.sin(x*math.pi/180.)3452 tth2q = lambda t,w:4.0*math.pi*sind(t/2.0)/w3453 3433 TextList = [] 3454 3434 PDFlist = [] … … 3966 3946 'Python version error', wx.OK) 3967 3947 try: 3968 result =dlg.ShowModal()3948 dlg.ShowModal() 3969 3949 finally: 3970 3950 dlg.Destroy() -
trunk/GSASIIIO.py
r2532 r2544 289 289 G2frame.PatternTree.SetItemPyData(G2frame.PatternTree.AppendItem(Id,text='Comments'),Comments) 290 290 Imax = np.amax(Image) 291 Imin = max(0.0,np.amin(Image)) #force positive292 291 if G2frame.imageDefault: 293 292 Data = copy.copy(G2frame.imageDefault) … … 387 386 errorReport += ': '+rd.errors 388 387 continue 389 rdbuffer = {} # create temporary storage for file reader390 388 if imageOnly: 391 389 ParentFrame = None # prevent GUI access on reread … … 540 538 def GetEdfData(filename,imageOnly=False): 541 539 'Read European detector data edf file' 542 import struct as st543 import array as ar544 540 if not imageOnly: 545 541 print 'Read European detector data edf file: ',filename … … 600 596 def GetRigaku(filename,imageOnly=False): 601 597 'Read Rigaku R-Axis IV image file' 602 import struct as st603 598 import array as ar 604 599 if not imageOnly: … … 632 627 def GetImgData(filename,imageOnly=False): 633 628 'Read an ADSC image file' 634 import struct as st635 629 import array as ar 636 630 if not imageOnly: … … 663 657 data = {'pixelSize':pixel,'wavelength':wave,'distance':distance,'center':center,'size':[size,size]} 664 658 image = [] 665 row = 0666 659 pos = 512 667 660 File.seek(pos) 668 661 image = np.array(ar.array('H',File.read(2*Npix)),dtype=np.int32) 669 image = np.reshape(image,(size xy[1],sizexy[0]))662 image = np.reshape(image,(size,size)) 670 663 # image = np.zeros(shape=(size,size),dtype=np.int32) 671 664 # while row < size: … … 684 677 def GetMAR345Data(filename,imageOnly=False): 685 678 'Read a MAR-345 image plate image' 686 import array as ar687 import struct as st688 679 try: 689 680 import pack_f as pf … … 699 690 File = open(filename,'rb') 700 691 head = File.read(4095) 701 numbers = st.unpack('<iiiiiiiiii',head[:40])702 692 lines = head[128:].split('\n') 703 693 head = [] … … 870 860 X = 4.*np.pi*npsind(X/2.)/data['wavelength'] #convert to q 871 861 Xminmax = [X[0],X[-1]] 872 LRazm = data['LRazimuth']873 862 Azms = [] 874 863 dazm = 0. … … 1019 1008 dlg = wx.MessageDialog(G2frame, 'No peaks!', 'Nothing to save!', wx.OK) 1020 1009 try: 1021 result =dlg.ShowModal()1010 dlg.ShowModal() 1022 1011 finally: 1023 1012 dlg.Destroy() … … 1037 1026 dlg = wx.MessageDialog(G2frame, 'No peaks!', 'Nothing to save!', wx.OK) 1038 1027 try: 1039 result =dlg.ShowModal()1028 dlg.ShowModal() 1040 1029 finally: 1041 1030 dlg.Destroy() … … 2576 2565 Layer['Layers'].append({'Name':Struct[N],'SameAs':'','Symm':Symm,'Atoms':[]}) 2577 2566 N += 2 2578 iatm = 02579 2567 while 'layer' not in Struct[N]: 2580 2568 atom = Struct[N][4:].split() -
trunk/GSASIIconstrGUI.py
r2520 r2544 458 458 l2 = max(l2,len(i2)) 459 459 fmt = "{:"+str(l1)+"s} {:"+str(l2)+"s} {:s}" 460 atchoice = [fmt.format(*i ) for iin choices]460 atchoice = [fmt.format(*i1) for i1 in choices] 461 461 dlg = G2G.G2MultiChoiceDialog( 462 462 G2frame.dataFrame,legend, … … 688 688 parent=G2frame.dataFrame) 689 689 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)" 691 691 GetAddVars(page,title1,title2,varList,constrDictEnt,'equivalence') 692 692 … … 701 701 parent=G2frame.dataFrame) 702 702 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)" 704 704 GetAddAtomVars(page,title1,title2,varList,constrDictEnt,'equivalence') 705 705 … … 714 714 parent=G2frame.dataFrame) 715 715 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)" 717 717 GetAddAtomVars(page,title1,title2,varList,constrDictEnt,'riding') 718 718 … … 727 727 parent=G2frame.dataFrame) 728 728 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)" 730 730 GetAddVars(page,title1,title2,varList,constrDictEnt,'function') 731 731 … … 740 740 parent=G2frame.dataFrame) 741 741 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)" 743 743 GetAddVars(page,title1,title2,varList,constrDictEnt,'constraint') 744 744 … … 1398 1398 if dlg.ShowModal() == wx.ID_OK: 1399 1399 nAtoms,nTrans = dlg.GetValues() 1400 vectorRB = data['Vector']1401 1400 rbId = ran.randint(0,sys.maxint) 1402 1401 vecMag = [1.0 for i in range(nTrans)] … … 1467 1466 rbTypes = [] 1468 1467 rbXYZ = [] 1469 rbSeq = []1470 1468 atNames = [] 1471 1469 txtStr = text.readline() … … 1589 1587 if dlg.ShowModal() == wx.ID_OK: 1590 1588 Orig = dlg.GetSelection() 1591 xyz = XYZ[Orig]1592 1589 TargList = neighDict[atNames[Orig]] 1593 1590 dlg.Destroy() … … 1618 1615 event.Skip() 1619 1616 Obj = event.GetEventObject() 1620 rbId = Indx[Obj.GetId()]1621 1617 rbData['RBname'] = Obj.GetValue() 1622 1618 … … 1631 1627 def OnPlotRB(event): 1632 1628 Obj = event.GetEventObject() 1633 rbId = Indx[Obj.GetId()]1634 1629 Obj.SetValue(False) 1635 1630 G2plt.PlotRigidBody(G2frame,'Vector',AtInfo,rbData,plotDefaults) … … 1727 1722 1728 1723 def TypeSelect(event): 1729 Obj = event.GetEventObject()1730 1724 AtInfo = data['Vector']['AtInfo'] 1731 1725 r,c = event.GetRow(),event.GetCol() … … 1744 1738 1745 1739 def ChangeCell(event): 1746 Obj = event.GetEventObject()1747 1740 r,c = event.GetRow(),event.GetCol() 1748 1741 if r >= 0 and (0 <= c < 3): … … 1832 1825 def OnRBName(event): 1833 1826 Obj = event.GetEventObject() 1834 rbId = Indx[Obj.GetId()]1835 1827 rbData['RBname'] = Obj.GetValue() 1836 1828 … … 1844 1836 def OnPlotRB(event): 1845 1837 Obj = event.GetEventObject() 1846 rbId = Indx[Obj.GetId()]1847 1838 Obj.SetValue(False) 1848 1839 G2plt.PlotRigidBody(G2frame,'Residue',AtInfo,rbData,plotDefaults) -
trunk/GSASIIgrid.py
r2538 r2544 2249 2249 self.AtomsMenu.Append(menu=self.AtomCompute, title='Compute') 2250 2250 submenu = wx.Menu() 2251 self.AtomEdit.AppendMenu(wx.ID_ANY, ' Atoms selection...', submenu,2251 self.AtomEdit.AppendMenu(wx.ID_ANY, 'On selected atoms...', submenu, 2252 2252 help='Set/Act on selected atoms') 2253 2253 submenu.Append(wxID_ATOMSSETSEL, -
trunk/GSASIImath.py
r2522 r2544 15 15 16 16 ''' 17 import sys18 import os19 import os.path as ospath20 17 import random as rn 21 18 import numpy as np 22 19 import numpy.linalg as nl 23 20 import numpy.ma as ma 24 import cPickle25 21 import time 26 22 import math … … 213 209 214 210 def getNeighbors(atom,radius): 215 neighList = []216 211 Dx = UAtoms-np.array(atom[cx:cx+3]) 217 212 dist = ma.masked_less(np.sqrt(np.sum(np.inner(Amat,Dx)**2,axis=0)),0.5) #gets rid of disorder "bonds" < 0.5A … … 495 490 Tatoms = GetAtomsById(Atoms,AtLookUp,AddHydId[1]) 496 491 TXYZ = np.array([tatom[cx:cx+3] for tatom in Tatoms]) #3 x xyz 497 DX = np.inner(Amat,TXYZ-OXYZ).T498 492 if nBonds == 4: 499 493 if AddHydId[-1] == 1: … … 633 627 XYZ = np.inner(Amat,atom[cx:cx+3]) 634 628 Axyz = np.array([ 0,XYZ[2],-XYZ[1], -XYZ[2],0,XYZ[0], XYZ[1],-XYZ[0],0],ndmin=2 ) 635 if 'U' in T SLtype:629 if 'U' in TLStype: 636 630 atom[cia+1] = TLS[0] 637 631 atom[cia] = 'I' … … 1132 1126 ''' 1133 1127 glTau,glWt = pwd.pygauleg(0.,1.,ngl) #get Gauss-Legendre intervals & weights 1134 dT = 2./ngl1135 dX = 0.00011136 1128 waveShapes = [FSSdata.T.shape,XSSdata.T.shape,USSdata.T.shape] 1137 1129 Af = np.array(FSSdata[0]).T #sin frac mods x waves x atoms … … 1429 1421 # area += w[i]*f(x[i]) 1430 1422 1431 import math1432 1423 def gaulegf(a, b, n): 1433 1424 x = range(n+1) # x[0] unused … … 1510 1501 return 0. 1511 1502 pId = distance_dict['pId'] 1512 pfx = '%d::'%(pId)1513 1503 A = [parmDict['%s::A%d'%(pId,i)] for i in range(6)] 1514 1504 Amat = G2lat.cell2AB(G2lat.A2cell(A))[0] … … 1534 1524 return None 1535 1525 pId = distance_dict['pId'] 1536 pfx = '%d::'%(pId)1537 1526 A = [parmDict['%s::A%d'%(pId,i)] for i in range(6)] 1538 1527 Amat = G2lat.cell2AB(G2lat.A2cell(A))[0] … … 1549 1538 return 0. 1550 1539 pId = angle_dict['pId'] 1551 pfx = '%d::'%(pId)1552 1540 A = [parmDict['%s::A%d'%(pId,i)] for i in range(6)] 1553 1541 Amat = G2lat.cell2AB(G2lat.A2cell(A))[0] … … 1581 1569 return None 1582 1570 pId = angle_dict['pId'] 1583 pfx = '%d::'%(pId)1584 1571 A = [parmDict['%s::A%d'%(pId,i)] for i in range(6)] 1585 1572 Amat = G2lat.cell2AB(G2lat.A2cell(A))[0] … … 2034 2021 return np.sqrt(np.sum(V1**2)) 2035 2022 2036 Inv = []2037 2023 SyOps = [] 2038 2024 names = [] … … 2048 2034 sig = -0.001 2049 2035 if 'covMatrix' in covData: 2050 parmNames = []2051 2036 dx = .00001 2052 2037 dadx = np.zeros(6) … … 2091 2076 return acosd(cang) 2092 2077 2093 Inv = []2094 2078 SyOps = [] 2095 2079 names = [] … … 2105 2089 sig = -0.01 2106 2090 if 'covMatrix' in covData: 2107 parmNames = []2108 2091 dx = .00001 2109 2092 dadx = np.zeros(9) … … 2149 2132 M = np.array([V1,V2,V3]) 2150 2133 D = nl.det(M) 2151 Ang = 1.02152 2134 P12 = np.dot(V1,V2) 2153 2135 P13 = np.dot(V1,V3) … … 2156 2138 return Tors 2157 2139 2158 Inv = []2159 2140 SyOps = [] 2160 2141 names = [] … … 2170 2151 sig = -0.01 2171 2152 if 'covMatrix' in covData: 2172 parmNames = []2173 2153 dx = .00001 2174 2154 dadx = np.zeros(12) … … 2240 2220 M = np.array([V1,V2,V3]) 2241 2221 D = nl.det(M) 2242 Ang = 1.02243 2222 P12 = np.dot(V1,V2) 2244 2223 P13 = np.dot(V1,V3) … … 2247 2226 return Tors 2248 2227 2249 Inv = []2250 2228 SyOps = [] 2251 2229 names = [] … … 2268 2246 sig = sigVals[M-3] 2269 2247 if 'covMatrix' in covData: 2270 parmNames = []2271 2248 dx = .00001 2272 2249 N = M*3 … … 2600 2577 phasep = complex(a,b) 2601 2578 phasem = complex(a,-b) 2602 Fo = np.sqrt(Fosq)2603 2579 if '2Fo-Fc' in mapData['MapType']: 2604 2580 F = 2.*np.sqrt(Fosq)-np.sqrt(Fcsq) … … 2828 2804 DH = [] 2829 2805 Dphi = [] 2830 SGMT = np.array([ops[0].T for ops in SGData['SGOps']])2831 SGT = np.array([ops[1] for ops in SGData['SGOps']])2832 2806 Hmax = 2*np.asarray(G2lat.getHKLmax(3.5,SGData,A),dtype='i') 2833 2807 for F in Flist: … … 3055 3029 SGData = generalData['SGData'] 3056 3030 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']])3059 3031 SSGMT = np.array([ops[0].T for ops in SSGData['SSGOps']]) 3060 3032 SSGT = np.array([ops[1] for ops in SSGData['SSGOps']]) … … 3240 3212 return Vec,Hess 3241 3213 3242 phaseName = generalData['Name']3243 3214 SGData = generalData['SGData'] 3244 3215 Amat,Bmat = G2lat.cell2AB(generalData['Cell'][1:7]) … … 3283 3254 x1 = result[0] 3284 3255 if not np.any(x1 < 0): 3285 mag = x1[0]3286 3256 peak = (np.array(x1[1:4])-ind)/incre 3287 3257 peak = fixSpecialPos(peak,SGData,Amat) … … 3330 3300 3331 3301 generalData = data['General'] 3332 cell = generalData['Cell'][1:7]3333 3302 Amat,Bmat = G2lat.cell2AB(generalData['Cell'][1:7]) 3334 A = G2lat.cell2A(cell)3335 3303 SGData = generalData['SGData'] 3336 3304 mapPeaks = data['Map Peaks'] … … 3365 3333 3366 3334 generalData = data['General'] 3367 cell = generalData['Cell'][1:7]3368 3335 Amat,Bmat = G2lat.cell2AB(generalData['Cell'][1:7]) 3369 A = G2lat.cell2A(cell)3370 3336 SGData = generalData['SGData'] 3371 3337 mapPeaks = data['Map Peaks'] … … 3585 3551 3586 3552 import numpy 3587 from numpy import asarray, tan, exp, ones,squeeze, sign, \3588 all, log, sqrt, pi, shape, array, minimum, where3553 from numpy import asarray, tan, exp, squeeze, sign, \ 3554 all, log, pi, shape, array, where 3589 3555 from numpy import random 3590 3556 … … 4267 4233 MCSA = generalData['MCSA controls'] 4268 4234 reflName = MCSA['Data source'] 4269 phaseName = generalData['Name']4270 4235 MCSAObjs = data['MCSA']['Models'] #list of MCSA models 4271 4236 upper = [] -
trunk/GSASIIphsGUI.py
r2530 r2544 24 24 import wx 25 25 import wx.grid as wg 26 import wx.lib.gridmovers as wgmove27 import wx.wizard as wz28 26 import wx.lib.scrolledpanel as wxscroll 29 27 import matplotlib as mpl … … 32 30 import sys 33 31 import random as ran 34 import cPickle35 32 import GSASIIpath 36 33 GSASIIpath.SetVersionNumber("$Revision$") … … 51 48 import GSASIIctrls as G2G 52 49 import GSASIIconstrGUI as G2cnstG 53 import atmdata54 50 import numpy as np 55 51 import numpy.linalg as nl 56 import numpy.ma as ma57 52 58 53 VERY_LIGHT_GREY = wx.Colour(235,235,235) … … 565 560 except ValueError: 566 561 if ObjId < 3: #bad cell edge - reset 567 value = c ontrols[6+ObjId]562 value = cell[ObjId+1] 568 563 else: #bad angle 569 564 value = 90. … … 944 939 modS = G2spc.splitSSsym(generalData['SuperSg'])[0] 945 940 generalData['SuperVec'][0],ifShow = G2spc.SSGModCheck(generalData['SuperVec'][0],modS) 946 vec = generalData['SuperVec'][0]947 941 for i,[val,show] in enumerate(zip(generalData['SuperVec'][0],ifShow)): 948 942 if show: … … 1154 1148 1155 1149 def MCSASizer(): 1156 Ind = {}1157 1150 1158 1151 def OnRefList(event): … … 1202 1195 MCSAdata['ranStart'] = ranStart.GetValue() 1203 1196 1204 def OnAutoRan(event):1205 MCSAdata['autoRan'] = autoRan.GetValue()1197 # def OnAutoRan(event): 1198 # MCSAdata['autoRan'] = autoRan.GetValue() 1206 1199 1207 1200 def OnRanRange(event): … … 1800 1793 generalData = data['General'] 1801 1794 SpnFlp = generalData['SGData'].get('SpnFlp',[]) 1802 OprNames = generalData['SGData'].get('OprNames',[])1795 # OprNames = generalData['SGData'].get('OprNames',[]) 1803 1796 # print OprNames 1804 1797 # print SpnFlp 1805 1798 # print generalData['SGData'].get('MagMom',[]) 1806 1799 atomData = data['Atoms'] 1807 DData = data['Drawing']1808 1800 resRBData = data['RBModels'].get('Residue',[]) 1809 1801 vecRBData = data['RBModels'].get('Vector',[]) … … 1894 1886 atomData = data['Atoms'] 1895 1887 generalData = data['General'] 1896 Ncol = Atoms.GetNumberCols()1897 1888 atId = ran.randint(0,sys.maxint) 1898 1889 E,SGData = G2spc.SpcGroup(generalData['SGData']['SpGrp']) … … 2038 2029 2039 2030 def OnHydAtomUpdate(event): 2040 Error = ''2041 2031 generalData = data['General'] 2042 2032 cx,ct,cs,cia = generalData['AtomPtrs'] … … 2134 2124 atomData = data['Atoms'] 2135 2125 generalData = data['General'] 2136 Ncol = Atoms.GetNumberCols()2137 2126 E,SGData = G2spc.SpcGroup(generalData['SGData']['SpGrp']) 2138 2127 Sytsym,Mult = G2spc.SytSym([x,y,z],SGData)[:2] … … 2392 2381 G2plt.PlotStructure(G2frame,data) 2393 2382 2394 def AtomRotate(event):2395 '''Currently not used - Bind commented out below2396 '''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+Unit2420 XYZS -= T2421 XYZS = np.inner(A,XYZS).T #to Cartesian2422 XYZS = np.inner(M,XYZS).T #rotate2423 XYZS = np.inner(B,XYZS).T+T #back to crystal & translate2424 GSASIIpath.IPyBreak()2425 atomData[ind][cx:cx+3] = XYZ2383 # 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 2426 2415 # for unit in Unit: 2427 2416 # XYZ = np.copy(np.array(atomData[ind][cx:cx+3])) … … 2435 2424 ## atom[css:css+2] = G2spc.SytSym(XYZ,SGData)[:2] 2436 2425 # 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") 2444 2433 2445 2434 def MakeMolecule(event): 2446 2435 indx = GetSelectedAtoms() 2447 Oxyz = []2448 xyz = []2449 2436 DisAglCtls = {} 2450 2437 if len(indx) == 1: … … 2776 2763 Indx = {} 2777 2764 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] = value2786 Obj.SetValue("%.5f"%(cell[1]))2787 else:2788 cell[3] = value2789 Obj.SetValue("%.5f"%(cell[3]))2790 elif laue in ['mmm']:2791 cell[ObjId+1] = value2792 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] = value2798 Obj.SetValue("%.5f"%(cell[ObjId+1]))2799 else:2800 cell[6] = value2801 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])) 2803 2790 2804 2791 def OnLaue(event): … … 2854 2841 except ValueError: 2855 2842 if ObjId < 3: #bad cell edge - reset 2856 value = c ontrols[6+ObjId]2843 value = cell[ObjId+1] 2857 2844 else: #bad angle 2858 2845 value = 90. … … 3477 3464 return 3478 3465 dlg.Destroy() 3479 PWDR = data['Histograms'][HistName]3480 3466 G2frame.PatternId = G2gd.GetPatternTreeItemId(G2frame,G2frame.root,HistName) 3481 3467 sample = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId( … … 3548 3534 return 3549 3535 dlg.Destroy() 3550 PWDR = data['Histograms'][HistName]3551 3536 G2frame.PatternId = G2gd.GetPatternTreeItemId(G2frame,G2frame.root,HistName) 3552 3537 sample = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId( … … 3572 3557 nSteps = simCodes[4] 3573 3558 laue = Layers['Laue'] 3574 dStep = (BegFin[1]-BegFin[0])/nSteps3575 3559 vals = np.linspace(BegFin[0],BegFin[1],nSteps+1,True) 3576 3560 simNames = [] … … 3606 3590 print ' Transition matrix:' 3607 3591 for trans in Layers['Transitions']: 3608 line = str([' %.3f'%( vals[0]) for valsin trans])3592 line = str([' %.3f'%(item[0]) for item in trans]) 3609 3593 print line[1:-2].replace("'",'') 3610 3594 else: … … 3641 3625 cx,ct,cs,cia = generalData['AtomPtrs'] 3642 3626 atomData = data['Atoms'] 3643 Map = generalData['Map']3644 3627 D4Map = generalData['4DmapData'] 3645 3628 if waveData.GetSizer(): … … 3666 3649 G2frame.bottomSizer = ShowAtomInfo() 3667 3650 mainSizer.Add(G2frame.bottomSizer) 3668 Indx = {}3669 3651 mainSizer.Layout() 3670 3652 G2frame.dataFrame.Refresh() … … 3811 3793 atm = atomData[iatm] 3812 3794 xyz = atm[cx:cx+3] 3813 uij = atm[cia+2:cia+8]3814 3795 atomSizer = wx.BoxSizer(wx.VERTICAL) 3815 3796 G2G.HorizontalLine(atomSizer,waveData) … … 3867 3848 Amat,Bmat = G2lat.cell2AB(generalData['Cell'][1:7]) 3868 3849 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',' ',' ',' ']3873 3850 defaultDrawing = {'viewPoint':[[0.5,0.5,0.5],[]],'showHydrogen':True, 3874 3851 'backColor':[0,0,0],'depthFog':False,'Zclip':50.0,'cameraPos':50.,'Zstep':0.5, … … 3928 3905 cx,ct,cs,ci = drawingData['atomPtrs'] 3929 3906 atomData = drawingData['Atoms'] 3930 atNames = []3931 3907 atXYZ = [] 3932 3908 atSymOp = [] … … 3943 3919 restData[PhaseName] = {} 3944 3920 restData[PhaseName]['Bond'] = bondData 3945 dist = G2mth.getRestDist(atXYZ,Amat)3946 3921 bondData['Bonds'].append([atIndx,atSymOp,1.54,0.01]) 3947 3922 elif event.GetId() == G2gd.wxID_DRAWRESTRANGLE and len(indx) == 3: … … 3952 3927 restData[PhaseName] = {} 3953 3928 restData[PhaseName]['Angle'] = angleData 3954 angle = G2mth.getRestAngle(atXYZ,Amat)3955 3929 angleData['Angles'].append([atIndx,atSymOp,109.5,1.0]) 3956 3930 elif event.GetId() == G2gd.wxID_DRAWRESTRPLANE and len(indx) > 3: … … 3961 3935 restData[PhaseName] = {} 3962 3936 restData[PhaseName]['Plane'] = planeData 3963 plane = G2mth.getRestPlane(atXYZ,Amat)3964 3937 planeData['Planes'].append([atIndx,atSymOp,0.0,0.01]) 3965 3938 elif event.GetId() == G2gd.wxID_DRAWRESTRCHIRAL and len(indx) == 4: … … 3970 3943 restData[PhaseName] = {} 3971 3944 restData[PhaseName]['Chiral'] = chiralData 3972 volume = G2mth.getRestChiral(atXYZ,Amat)3973 3945 chiralData['Volumes'].append([atIndx,atSymOp,2.5,0.1]) 3974 3946 else: … … 4040 4012 for x in sel: 4041 4013 parms.append(choice[x]) 4042 noSkip = False4043 4014 drawAtoms.ClearSelection() 4044 4015 drawingData['selectedAtoms'] = [] … … 4060 4031 elif r < 0: #dclick on col label 4061 4032 sel = -1 4062 Parms = False4063 noSkip = True4064 4033 if drawAtoms.GetColLabelValue(c) == 'Style': 4065 4034 dlg = wx.SingleChoiceDialog(G2frame,'Select','Atom drawing style',styleChoice) … … 4156 4125 G2frame.dataFrame.SetStatusText('') 4157 4126 generalData = data['General'] 4158 SpnFlp = generalData['SGData'].get('SpnFlp',[])4159 4127 SetupDrawingData() 4160 4128 drawingData = data['Drawing'] … … 4269 4237 else: 4270 4238 G2frame.dataFrame.SetStatusText('Change color, Add to Custom Colors, then OK') 4271 generalData = data['General']4272 4239 atomData = data['Drawing']['Atoms'] 4273 4240 cx,ct,cs,ci = data['Drawing']['atomPtrs'] … … 4493 4460 4494 4461 def FillCoordSphere(event): 4495 colLabels = [drawAtoms.GetColLabelValue(c) for c in range(drawAtoms.GetNumberCols())]4496 4462 generalData = data['General'] 4497 4463 Amat,Bmat = G2lat.cell2AB(generalData['Cell'][1:7]) … … 4511 4477 cij = ci+2 4512 4478 SGData = generalData['SGData'] 4513 SpnFlp = SGData.get('SpnFlp',[])4514 4479 cellArray = G2lat.CellBlock(1) 4515 4480 wx.BeginBusyCursor() … … 4719 4684 4720 4685 def UpdateDrawOptions(): 4721 import copy4722 4686 import wx.lib.colourselect as wcs 4723 4687 def SlopSizer(): … … 5096 5060 SetupDrawingData() 5097 5061 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']5102 5062 5103 5063 G2frame.dataFrame.SetStatusText('') … … 5379 5339 'SH Coeff':[False,{}],'SHShow':False,'PFhkl':[0,0,1], 5380 5340 'PFxyz':[0,0,1.],'PlotType':'Pole figure'} 5381 if 'SHShow' not in textureData: #another fix5341 if 'SHShow' not in textureData: 5382 5342 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: 5386 5344 textureData.update({'PFxyz':[0,0,1.],'PlotType':'Pole figure'}) 5387 5345 if 'Penalty' not in textureData: … … 5389 5347 shModels = ['cylindrical','none','shear - 2/m','rolling - mmm'] 5390 5348 SamSym = dict(zip(shModels,['0','-1','2/m','mmm'])) 5391 shAngles = ['omega','chi','phi']5392 5349 if Texture.GetSizer(): 5393 5350 Texture.GetSizer().Clear(True) … … 5570 5527 UseList = data['Histograms'] 5571 5528 hist = G2frame.hist 5572 useDict = {}5573 5529 keyList = G2frame.GetHistogramNames(hist[:4]) 5574 5530 if UseList: … … 6127 6083 if dlg.ShowModal() == wx.ID_OK: 6128 6084 sel = dlg.GetSelection() 6129 name = Source[sel]6130 6085 for item in ['Orig','Orient','ThermalMotion']: 6131 6086 sourceRB.update({item:RBObjs[sel][item],}) … … 6392 6347 mainSizer.Add((5,5),0) 6393 6348 if Torsions: 6394 AtNames = data['testRBObj']['AtNames']6395 rbAtTypes = data['testRBObj']['rbAtTypes']6396 6349 rbSeq = RBData['Residue'][rbId]['rbSeq'] 6397 6350 TorSizer = wx.FlexGridSizer(0,4) … … 6964 6917 RBData = G2frame.PatternTree.GetItemPyData(Id) 6965 6918 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' 6969 6922 G2frame.dataFrame.SetStatusText('') 6970 6923 mainSizer = wx.BoxSizer(wx.VERTICAL) … … 7308 7261 Sample = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,PatternId,'Sample Parameters')) 7309 7262 wave = G2mth.getWave(Inst) 7310 posCorr = Inst['Zero'][1]7311 7263 const = 9.e-2/(np.pi*Sample['Gonio. radius']) #shifts in microns 7312 7264 gconst = 2.35482 # sqrt(8 ln 2) … … 7492 7444 def OnPeaksEquiv(event): 7493 7445 if 'Map Peaks' in data: 7494 mapPeaks = data['Map Peaks']7495 7446 Ind = MapPeaks.GetSelectedRows() 7496 7447 if Ind: … … 7766 7717 General = data['General'] 7767 7718 phaseName = General['Name'] 7768 Histograms = data['Histograms']7769 7719 keyList = G2frame.GetHistogramNames('PWDR') 7770 7720 histNames = [] -
trunk/GSASIIplot.py
r2540 r2544 14 14 import math 15 15 import time 16 import copy17 16 import sys 18 17 import os.path … … 40 39 import GSASIIctrls as G2G 41 40 import 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 * 42 import OpenGL.GL as GL 43 import OpenGL.GLU as GLU 46 44 import gltext 47 45 from matplotlib.backends.backend_wx import _load_bitmap … … 472 470 to F, F**2, etc. as requested 473 471 ''' 474 from matplotlib.patches import Circle ,CirclePolygon472 from matplotlib.patches import Circle 475 473 global HKL,HKLF,HKLref 476 474 HKLref = hklRef … … 587 585 HKL = [] 588 586 HKLF = [] 589 time0 = time.time()590 587 sumFo = 0. 591 588 sumDF = 0. … … 716 713 print Fname+' saved' 717 714 size = Page.canvas.GetSize() 718 glPixelStorei(GL_UNPACK_ALIGNMENT, 1)715 GL.glPixelStorei(GL.GL_UNPACK_ALIGNMENT, 1) 719 716 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) 721 718 im = Im.new("RGBA", (size[0],size[1])) 722 719 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) 724 721 im = Im.new("RGB", (size[0],size[1])) 725 722 try: … … 817 814 if Super: 818 815 SuperVec = np.array(Data['SuperVec'][0]) 819 defaultViewPt = copy.copy(drawingData['viewPoint'])820 816 Amat,Bmat = G2lat.cell2AB(cell) #Amat - crystal to cartesian, Bmat - inverse 821 817 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)824 818 B4mat = np.concatenate((np.concatenate((Bmat,[[0],[0],[0]]),axis=1),[[0,0,0,1],]),axis=0) 825 819 drawingData['Quaternion'] = G2mth.AV2Q(2*np.pi,np.inner(Bmat,[0,0,1])) … … 827 821 Rd = np.array([255,0,0]) 828 822 Gr = np.array([0,255,0]) 829 wxGreen = wx.Colour(0,255,0)830 823 Bl = np.array([0,0,255]) 831 824 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]]) … … 844 837 C = [] 845 838 HKL = [] 846 RC = []847 839 for i,refl in enumerate(hklRef): 848 840 H = refl[:3] … … 911 903 912 904 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) 916 908 Zmax = 1. 917 909 xy = [int(xy[0]),int(View[3]-xy[1])] … … 919 911 h,k,l = ref[:3] 920 912 try: 921 X,Y,Z = gluProject(h,k,l,Model,Proj,View)913 X,Y,Z = GLU.gluProject(h,k,l,Model,Proj,View) 922 914 XY = [int(X),int(Y)] 923 915 if np.allclose(xy,XY,atol=10) and Z < Zmax: … … 968 960 def SetRotationZ(newxy): 969 961 #first get rotation vector (= view vector) in screen coords. & angle increment 970 View = glGetIntegerv(GL_VIEWPORT)962 View = GL.glGetIntegerv(GL.GL_VIEWPORT) 971 963 cent = [View[2]/2,View[3]/2] 972 964 oldxy = drawingData['oldxy'] … … 1003 995 if event.LeftIsDown(): 1004 996 SetRotation(newxy) 1005 Q = drawingData['Quaternion']1006 997 elif event.RightIsDown(): 1007 998 SetTranslation(newxy) … … 1009 1000 elif event.MiddleIsDown(): 1010 1001 SetRotationZ(newxy) 1011 Q = drawingData['Quaternion']1012 1002 Draw('move') 1013 1003 else: … … 1027 1017 def SetBackground(): 1028 1018 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) 1031 1021 1032 1022 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]) 1040 1030 1041 1031 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) 1049 1038 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) 1057 1046 1058 1047 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) 1065 1053 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-axis1054 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 1072 1060 for ix,txt in enumerate(labxyz): 1073 1061 if txt: 1074 1062 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]) 1076 1064 text = gltext.TextElement(text=txt,font=Font) 1077 1065 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) 1082 1070 1083 1071 def RenderDots(XYZ,RC): 1084 glEnable(GL_COLOR_MATERIAL)1072 GL.glEnable(GL.GL_COLOR_MATERIAL) 1085 1073 XYZ = np.array(XYZ) 1086 glPushMatrix()1074 GL.glPushMatrix() 1087 1075 for xyz,rc in zip(XYZ,RC): 1088 1076 x,y,z = xyz 1089 1077 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) 1098 1086 1099 1087 def Draw(caller=''): … … 1121 1109 1122 1110 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) 1131 1119 SetLights() 1132 1120 1133 glMatrixMode(GL_MODELVIEW)1134 glLoadIdentity()1121 GL.glMatrixMode(GL.GL_MODELVIEW) 1122 GL.glLoadIdentity() 1135 1123 matRot = G2mth.Q2Mat(Q) 1136 1124 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) 1140 1128 x,y,z = drawingData['viewPoint'][0] 1141 1129 if ifBox: … … 1145 1133 RenderUnitVectors(0,0,0,labxyz=['h','k','l']) 1146 1134 RenderDots(HKL,RC) 1147 time0 = time.time()1148 1135 try: 1149 1136 if Page.context: Page.canvas.SetCurrent(Page.context) … … 1156 1143 if new: 1157 1144 Page.views = False 1158 view = False1159 altDown = False1160 1145 Font = Page.GetFont() 1161 1146 Page.Choice = None … … 1418 1403 1419 1404 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') 1421 1406 1422 1407 def onMoveDiffCurve(event): … … 1517 1502 Page.canvas.blit(Page.figure.gca().bbox) 1518 1503 1504 try: 1505 Parms,Parms2 = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,G2frame.PatternId, 'Instrument Parameters')) 1506 except TypeError: 1507 return 1519 1508 if event is None: # called from a menu command rather than by click on mpl artist 1520 1509 mouse = 1 … … 1537 1526 xy[1] = xy[1]**2 1538 1527 PatternId = G2frame.PatternId 1539 try:1540 Parms,Parms2 = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,G2frame.PatternId, 'Instrument Parameters'))1541 except TypeError:1542 return1543 1528 PickId = G2frame.PickId 1544 1529 if G2frame.PatternTree.GetItemText(PickId) == 'Peak List': … … 1555 1540 pick.set_linestyle(':') # set line as dotted 1556 1541 Page = G2frame.G2plotNB.nb.GetPage(plotNum) 1557 P lot = Page.figure.gca()1542 Page.figure.gca() 1558 1543 Page.canvas.draw() # refresh without dotted line & save bitmap 1559 1544 savedplot = Page.canvas.copy_from_bbox(Page.figure.gca().bbox) … … 1587 1572 pick.set_linestyle(':') # set line as dotted 1588 1573 Page = G2frame.G2plotNB.nb.GetPage(plotNum) 1589 P lot = Page.figure.gca()1574 Page.figure.gca() 1590 1575 Page.canvas.draw() # refresh without dotted line & save bitmap 1591 1576 savedplot = Page.canvas.copy_from_bbox(Page.figure.gca().bbox) … … 1610 1595 G2frame.itemPicked = pick 1611 1596 Page = G2frame.G2plotNB.nb.GetPage(plotNum) 1612 P lot = Page.figure.gca()1597 Page.figure.gca() 1613 1598 if DifLine[0] is G2frame.itemPicked: # pick of difference curve 1614 1599 Page.canvas.draw() # save bitmap … … 1652 1637 pick.set_marker('|') # change the point appearance 1653 1638 Page = G2frame.G2plotNB.nb.GetPage(plotNum) 1654 P lot = Page.figure.gca()1639 Page.figure.gca() 1655 1640 Page.canvas.draw() # refresh with changed point & save bitmap 1656 1641 savedplot = Page.canvas.copy_from_bbox(Page.figure.gca().bbox) … … 1975 1960 if Pattern[1] is None: continue # skip over uncomputed simulations 1976 1961 xye = ma.array(ma.getdata(Pattern[1])) 1977 Zero = Parms.get('Zero',[0.,0.])[1]1978 1962 if PickId: 1979 1963 ifpicked = Pattern[2] == G2frame.PatternTree.GetItemText(PatternId) … … 1984 1968 xye[0] = ma.masked_inside(xye[0],excl[0],excl[1]) 1985 1969 if G2frame.plotStyle['qPlot'] and 'PWDR' in plottype: 1986 Id = G2gd.GetPatternTreeItemId(G2frame,G2frame.root, Pattern[2])1987 1970 X = 2.*np.pi/G2lat.Pos2dsp(Parms,xye[0]) 1988 1971 elif G2frame.plotStyle['dPlot'] and 'PWDR' in plottype: 1989 Id = G2gd.GetPatternTreeItemId(G2frame,G2frame.root, Pattern[2])1990 1972 X = G2lat.Pos2dsp(Parms,xye[0]) 1991 1973 else: … … 2290 2272 new,plotNum,Page,Plot,lim = G2frame.G2plotNB.FindPlotTab('Error analysis','mpl') 2291 2273 if new: 2292 newPlot = True2293 2274 G2frame.Cmax = 1.0 2294 2275 # save information needed to reload from tree and redraw … … 2322 2303 EDS = np.zeros_like(DS) 2323 2304 DX = np.linspace(0.,1.,num=len(DS),endpoint=True) 2324 oldErr =np.seterr(invalid='ignore') #avoid problem at DX==02305 np.seterr(invalid='ignore') #avoid problem at DX==0 2325 2306 T = np.sqrt(np.log(1.0/DX**2)) 2326 2307 top = 2.515517+0.802853*T+0.010328*T**2 … … 2494 2475 return 2495 2476 Ymax = max(Ymax,max(xye[1])) 2496 offset = Pattern[0].get('Offset',[0,0])[0]*Ymax/100.02497 2477 if G2frame.Contour: 2498 2478 ContourZ = [] … … 2930 2910 G2frame.G2plotNB.status.SetStatusText('Select Strain pattern first',1) 2931 2911 2932 xylim = []2933 2912 new,plotNum,Page,Plot,lim = G2frame.G2plotNB.FindPlotTab('Size Distribution','mpl') 2934 2913 if new: 2935 newPlot = True2936 2914 G2frame.G2plotNB.Bind(wx.aui.EVT_AUINOTEBOOK_PAGE_CHANGED,OnPageChanged) 2937 2915 Page.canvas.mpl_connect('motion_notify_event', OnMotion) … … 2985 2963 Plot.set_title('Powder Pattern Lines') 2986 2964 Plot.set_xlabel(r'$\mathsf{2\theta}$',fontsize=14) 2987 PickId = G2frame.PickId2988 2965 PatternId = G2frame.PatternId 2989 2966 peaks = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,PatternId, 'Index Peak List'))[0] … … 3054 3031 Page.Choice = None 3055 3032 Page.canvas.SetToolTipString('') 3056 colors=['b','g','r','c','m','k']3057 3033 X = [] 3058 3034 Y = [] … … 3094 3070 Z = [] 3095 3071 W = [] 3096 V = []3097 3072 for peak in peaks: 3098 3073 X.append(4.0*math.pi*sind(peak[0]/2.0)/lam) … … 3154 3129 W = [] 3155 3130 Q = [] 3156 V = []3157 3131 for peak in peaks: 3158 3132 T.append(peak[0]) … … 3223 3197 generalData = data['General'] 3224 3198 SGData = generalData['SGData'] 3225 SGLaue = SGData['SGLaue']3226 3199 if Start: #initialize the spherical harmonics qlmn arrays 3227 3200 ptx.pyqlmninit() … … 3229 3202 cell = generalData['Cell'][1:] 3230 3203 Amat,Bmat = G2lat.cell2AB(cell[:6]) 3231 Vol = cell[6]3232 3204 useList = data['Histograms'] 3233 3205 phase = generalData['Name'] … … 3240 3212 if hist == '': 3241 3213 hist = useList.keys()[0] 3242 numPlots = len(useList)3243 3214 3244 3215 if plotType in ['Mustrain','Size']: … … 3326 3297 3327 3298 if np.any(X) and np.any(Y) and np.any(Z): 3328 errFlags =np.seterr(all='ignore')3299 np.seterr(all='ignore') 3329 3300 Plot.plot_surface(X,Y,Z,rstride=1,cstride=1,color='g',linewidth=1) 3330 np.seterr(all='ignore')3331 3301 xyzlim = np.array([Plot.get_xlim3d(),Plot.get_ylim3d(),Plot.get_zlim3d()]).T 3332 3302 XYZlim = [min(xyzlim[0]),max(xyzlim[1])] … … 3378 3348 else: 3379 3349 obsRMD = Refs[15+ns] 3380 ObsIVP = []3381 3350 Phi = [] 3382 3351 Beta = [] … … 3582 3551 3583 3552 if np.any(X) and np.any(Y) and np.any(Z): 3584 errFlags =np.seterr(all='ignore')3553 np.seterr(all='ignore') 3585 3554 Plot.plot_surface(X,Y,Z,rstride=1,cstride=1,color='g',linewidth=1) 3586 3555 np.seterr(all='ignore') … … 3596 3565 Plot.set_zlabel(r'Z, MRD') 3597 3566 else: 3598 PFproj = textureData.get('PFproj','XY')3599 PRrev = textureData.get('PFrev',False)3600 3567 X,Y = np.meshgrid(np.linspace(1.,-1.,npts),np.linspace(-1.,1.,npts)) 3601 3568 R,P = np.sqrt(X**2+Y**2).flatten(),npatan2d(X,Y).flatten() … … 3644 3611 def OnPlotKeyPress(event): 3645 3612 global Off,Atom,Ax 3646 newPlot = False3647 3613 if event.key == '0': 3648 3614 Off = 0 … … 3746 3712 varyList = Data['varyList'] 3747 3713 values = Data['variables'] 3748 Xmax = len(varyList)3749 3714 covMatrix = Data['covMatrix'] 3750 3715 sig = np.sqrt(np.diag(covMatrix)) … … 3756 3721 3757 3722 def OnPlotKeyPress(event): 3758 newPlot = False3759 3723 if event.key == 's': 3760 3724 choice = [m for m in mpl.cm.datad.keys() if not m.endswith("_r")] … … 3832 3796 ylabs = [varyList[int(i)] for i in ytics[:-1]] 3833 3797 imgAx.set_yticklabels(ylabs) 3834 colorBar =Page.figure.colorbar(Img)3798 Page.figure.colorbar(Img) 3835 3799 Plot.set_title('V-Cov matrix'+title) 3836 3800 Plot.set_xlabel('Variable number') … … 3910 3874 names = Names 3911 3875 rama = np.log(2*Rama+1.) 3912 ramaMax = np.max(rama)3913 3876 rama = np.reshape(rama,(45,45)) 3914 3877 global Phi,Psi … … 3917 3880 3918 3881 def OnPlotKeyPress(event): 3919 newPlot = False3920 3882 if event.key == 's': 3921 3883 choice = [m for m in mpl.cm.datad.keys() if not m.endswith("_r")] … … 3995 3957 Plot.set_xlabel(r'$\phi$',fontsize=16) 3996 3958 Plot.set_ylabel(r'$\psi$',fontsize=16) 3997 colorBar =Page.figure.colorbar(Img)3959 Page.figure.colorbar(Img) 3998 3960 Page.canvas.draw() 3999 3961 … … 4175 4137 :param bool newImage: If True, the Figure is cleared and redrawn 4176 4138 ''' 4177 from matplotlib.patches import Ellipse, Arc,Circle,Polygon4139 from matplotlib.patches import Ellipse,Circle 4178 4140 import numpy.ma as ma 4179 4141 Dsp = lambda tth,wave: wave/(2.*npsind(tth/2.)) … … 4251 4213 if event.key in ['a',]: 4252 4214 G2frame.StrainKey = event.key 4253 StrSta =OnStartNewDzero(G2frame)4215 OnStartNewDzero(G2frame) 4254 4216 wx.CallAfter(PlotImage,G2frame,newImage=False) 4255 4217 … … 4459 4421 for poly in G2frame.polyList: #merging points problem here? 4460 4422 if Obj == poly[0]: 4461 ind = G2frame.itemPicked.contains(G2frame.mousePicked)[1]['ind'][0]4423 # ind = G2frame.itemPicked.contains(G2frame.mousePicked)[1]['ind'][0] 4462 4424 oldPos = np.array([G2frame.mousePicked.xdata,G2frame.mousePicked.ydata]) 4463 4425 pN = poly[1] … … 4527 4489 sizexy = Data['size'] 4528 4490 pixelSize = Data['pixelSize'] 4529 scalex = 1000./pixelSize[0]4530 scaley = 1000./pixelSize[1]4531 4491 Xmax = sizexy[0]*pixelSize[0]/1000. 4532 4492 Ymax = sizexy[1]*pixelSize[1]/1000. … … 4553 4513 AM = np.where(AM>0,np.log(AM),0) 4554 4514 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', 4556 4516 interpolation='nearest',vmin=0,vmax=2,extent=[0,Xmax,Ymax,0]) 4557 4517 Img = Plot.imshow(A,aspect='equal',cmap=acolor, … … 4679 4639 Plot.plot(x,y,'g') 4680 4640 if newImage: 4681 colorBar =Page.figure.colorbar(Img)4641 Page.figure.colorbar(Img) 4682 4642 Plot.set_xlim(xlim) 4683 4643 Plot.set_ylim(ylim) … … 4726 4686 Page.canvas.mpl_connect('motion_notify_event', OnMotion) 4727 4687 Page.views = False 4728 view = False4729 4688 Page.Choice = None 4730 4689 … … 4741 4700 Img = Plot.imshow(image,cmap=acolor,vmin=Imin,vmax=Imax,interpolation='nearest', \ 4742 4701 extent=[ysc[0],ysc[-1],xsc[-1],xsc[0]],aspect='auto') 4743 colorBar =Page.figure.colorbar(Img)4702 Page.figure.colorbar(Img) 4744 4703 # if Data['ellipses']: 4745 4704 # for ellipse in Data['ellipses']: … … 4782 4741 Page.canvas.mpl_connect('motion_notify_event', OnMotion) 4783 4742 Page.views = False 4784 view = False4785 4743 Page.Choice = None 4786 4744 Data = G2frame.PatternTree.GetItemPyData( … … 4858 4816 B4mat = np.concatenate((np.concatenate((Bmat,[[0],[0],[0]]),axis=1),[[0,0,0,1],]),axis=0) 4859 4817 SGData = generalData['SGData'] 4860 if generalData['Modulated']:4861 SSGData = generalData['SSGData']4862 4818 SpnFlp = SGData.get('SpnFlp',[1,]) 4863 Mydir = generalData['Mydir']4864 Super = generalData.get('Super',0)4865 4819 atomData = data['Atoms'] 4866 4820 mapPeaks = [] … … 4909 4863 mapData = {} 4910 4864 flipData = {} 4911 rhoXYZ = []4912 4865 showBonds = False 4913 4866 if 'Map' in generalData: … … 4935 4888 Bc = np.array(list(drawingData['backColor'])) 4936 4889 uColors = [Rd,Gr,Bl,Wt-Bc, Wt-Bc,Wt-Bc,Wt-Bc,Wt-Bc, Wt-Bc,Wt-Bc,Wt-Bc,Wt-Bc] 4937 altDown = False4938 shiftDown = False4939 ctrlDown = False4940 4890 G2frame.tau = 0. 4941 4891 … … 4954 4904 Fname = (os.path.splitext(projFile)[0]+'.'+mode).replace('*','+') 4955 4905 size = Page.canvas.GetSize() 4956 glPixelStorei(GL_UNPACK_ALIGNMENT, 1)4906 GL.glPixelStorei(GL.GL_UNPACK_ALIGNMENT, 1) 4957 4907 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) 4959 4909 im = Im.new("RGBA", (size[0],size[1])) 4960 4910 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) 4962 4912 im = Im.new("RGB", (size[0],size[1])) 4963 4913 try: … … 5093 5043 5094 5044 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) 5098 5048 Zmax = 1. 5099 5049 if Add: … … 5102 5052 for i,peak in enumerate(mapPeaks): 5103 5053 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) 5105 5055 XY = [int(X),int(View[3]-Y)] 5106 5056 if np.allclose(xy,XY,atol=10) and Z < Zmax: … … 5117 5067 for i,atom in enumerate(drawAtoms): 5118 5068 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) 5120 5070 XY = [int(X),int(View[3]-Y)] 5121 5071 if np.allclose(xy,XY,atol=10) and Z < Zmax: … … 5286 5236 def SetBackground(): 5287 5237 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) 5290 5240 5291 5241 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]) 5299 5249 # glLightfv(GL_LIGHT0,GL_SPECULAR,[1,1,1,1]) 5300 5250 # glLightfv(GL_LIGHT0,GL_POSITION,[0,0,1,1]) … … 5387 5337 def SetRotationZ(newxy): 5388 5338 #first get rotation vector (= view vector) in screen coords. & angle increment 5389 View = glGetIntegerv(GL_VIEWPORT)5339 View = GL.glGetIntegerv(GL.GL_VIEWPORT) 5390 5340 cent = [View[2]/2,View[3]/2] 5391 5341 oldxy = drawingData['oldxy'] … … 5431 5381 def SetRBRotationZ(newxy): 5432 5382 #first get rotation vector (= view vector) in screen coords. & angle increment 5433 View = glGetIntegerv(GL_VIEWPORT)5383 View = GL.glGetIntegerv(GL.GL_VIEWPORT) 5434 5384 cent = [View[2]/2,View[3]/2] 5435 5385 oldxy = drawingData['oldxy'] … … 5457 5407 5458 5408 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) 5465 5415 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) 5474 5424 5475 5425 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) 5486 5435 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) 5496 5445 5497 5446 def RenderPlane(plane,color): 5498 5447 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) 5508 5457 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) 5514 5463 5515 5464 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() 5523 5472 5524 5473 def RenderDots(XYZ,RC): 5525 glEnable(GL_COLOR_MATERIAL)5474 GL.glEnable(GL.GL_COLOR_MATERIAL) 5526 5475 XYZ = np.array(XYZ) 5527 glPushMatrix()5476 GL.glPushMatrix() 5528 5477 for xyz,rc in zip(XYZ,RC): 5529 5478 x,y,z = xyz 5530 5479 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) 5539 5488 5540 5489 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() 5548 5497 5549 5498 def RenderEllipsoid(x,y,z,ellipseProb,E,R4,color): 5550 5499 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() 5562 5511 5563 5512 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) 5568 5517 for bond in Bonds: 5569 glPushMatrix()5518 GL.glPushMatrix() 5570 5519 Dx = np.inner(Amat,bond) 5571 5520 Z = np.sqrt(np.sum(Dx**2)) … … 5573 5522 azm = atan2d(-Dx[1],-Dx[0]) 5574 5523 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() 5581 5530 5582 5531 def RenderMoment(x,y,z,Moment,color,slice=20): … … 5584 5533 Z = np.sqrt(np.sum(Dx**2)) 5585 5534 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]) 5591 5540 azm = atan2d(-Dx[1],-Dx[0]) 5592 5541 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() 5606 5555 5607 5556 def RenderLines(x,y,z,Bonds,color): 5608 glShadeModel(GL_FLAT)5557 GL.glShadeModel(GL.GL_FLAT) 5609 5558 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) 5615 5564 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) 5623 5572 5624 5573 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) 5631 5580 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) 5636 5585 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) 5641 5590 5642 5591 def RenderMapPeak(x,y,z,color,den): 5643 glShadeModel(GL_FLAT)5592 GL.glShadeModel(GL.GL_FLAT) 5644 5593 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) 5650 5599 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) 5658 5607 5659 5608 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) 5664 5613 # gle.gleSetJoinStyle(TUBE_NORM_EDGE | TUBE_JN_ANGLE | TUBE_JN_CAP) 5665 5614 # gle.glePolyCylinder(Backbone,BackboneColor,radius) 5666 glPopMatrix()5667 glDisable(GL_COLOR_MATERIAL)5615 GL.glPopMatrix() 5616 GL.glDisable(GL.GL_COLOR_MATERIAL) 5668 5617 5669 5618 def RenderLabel(x,y,z,label,r,color,matRot): … … 5671 5620 color wx.Colour object 5672 5621 ''' 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-axis5622 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 5680 5629 text = gltext.Text(text=label,font=Font,foreground=color) 5681 5630 text.draw_text(scale=0.025) 5682 glEnable(GL_LIGHTING)5683 glPopMatrix()5631 GL.glEnable(GL.GL_LIGHTING) 5632 GL.glPopMatrix() 5684 5633 5685 5634 def RenderMap(rho,rhoXYZ,indx,Rok): 5686 glShadeModel(GL_FLAT)5635 GL.glShadeModel(GL.GL_FLAT) 5687 5636 cLevel = drawingData['contourLevel'] 5688 5637 XYZ = [] … … 5702 5651 RC.append([0.1*alpha,Gr]) 5703 5652 RenderDots(XYZ,RC) 5704 glShadeModel(GL_SMOOTH)5653 GL.glShadeModel(GL.GL_SMOOTH) 5705 5654 5706 5655 def Draw(caller='',Fade=[]): … … 5757 5706 5758 5707 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) 5767 5716 SetLights() 5768 5717 5769 glMatrixMode(GL_MODELVIEW)5770 glLoadIdentity()5718 GL.glMatrixMode(GL.GL_MODELVIEW) 5719 GL.glLoadIdentity() 5771 5720 matRot = G2mth.Q2Mat(Q) 5772 5721 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) 5776 5725 if drawingData['showABC']: 5777 5726 x,y,z = drawingData['viewPoint'][0] … … 5779 5728 Backbones = {} 5780 5729 BackboneColor = [] 5781 time0 = time.time()5782 5730 # glEnable(GL_BLEND) 5783 5731 # glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA) … … 5808 5756 if atom[cs] != '': 5809 5757 try: 5810 glLoadName(atom[-3])5758 GL.glLoadName(atom[-3]) 5811 5759 except: #problem with old files - missing code 5812 5760 pass … … 5950 5898 if new: 5951 5899 Page.views = False 5952 view = False5953 altDown = False5954 5900 Font = Page.GetFont() 5955 5901 Page.Choice = None … … 6016 5962 6017 5963 Mydir = G2frame.dirname 6018 Wt = np.array([255,255,255])6019 5964 Rd = np.array([255,0,0]) 6020 5965 Gr = np.array([0,255,0]) … … 6082 6027 def SetBackground(): 6083 6028 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) 6086 6031 6087 6032 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]) 6095 6040 6096 6041 def SetRotation(newxy): … … 6116 6061 def SetRotationZ(newxy): 6117 6062 #first get rotation vector (= view vector) in screen coords. & angle increment 6118 View = glGetIntegerv(GL_VIEWPORT)6063 View = GL.glGetIntegerv(GL.GL_VIEWPORT) 6119 6064 cent = [View[2]/2,View[3]/2] 6120 6065 oldxy = defaults['oldxy'] … … 6139 6084 6140 6085 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) 6147 6091 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) 6155 6099 6156 6100 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() 6163 6107 6164 6108 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) 6168 6112 for Dx in Bonds: 6169 glPushMatrix()6113 GL.glPushMatrix() 6170 6114 Z = np.sqrt(np.sum(Dx**2)) 6171 6115 if Z: 6172 6116 azm = atan2d(-Dx[1],-Dx[0]) 6173 6117 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() 6180 6124 6181 6125 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-axis6126 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 6188 6132 text = gltext.TextElement(text=label,font=Font,foreground=wx.WHITE) 6189 6133 text.draw_text(scale=0.025) 6190 glEnable(GL_LIGHTING)6191 glPopMatrix()6134 GL.glEnable(GL.GL_LIGHTING) 6135 GL.glPopMatrix() 6192 6136 6193 6137 def Draw(caller=''): … … 6199 6143 VS = np.array(Page.canvas.GetSize()) 6200 6144 aspect = float(VS[0])/float(VS[1]) 6201 Zclip = 500.06202 6145 Q = defaults['Quaternion'] 6203 6146 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) 6212 6155 SetLights() 6213 6156 6214 glMatrixMode(GL_MODELVIEW)6215 glLoadIdentity()6157 GL.glMatrixMode(GL.GL_MODELVIEW) 6158 GL.glLoadIdentity() 6216 6159 matRot = G2mth.Q2Mat(Q) 6217 6160 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) 6219 6162 RenderUnitVectors(0.,0.,0.) 6220 6163 radius = 0.2 … … 6250 6193 print Fname+' saved' 6251 6194 size = Page.canvas.GetSize() 6252 glPixelStorei(GL_UNPACK_ALIGNMENT, 1)6195 GL.glPixelStorei(GL.GL_UNPACK_ALIGNMENT, 1) 6253 6196 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) 6255 6198 im = Im.new("RGBA", (size[0],size[1])) 6256 6199 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) 6258 6201 im = Im.new("RGB", (size[0],size[1])) 6259 6202 try: … … 6270 6213 if new: 6271 6214 Page.views = False 6272 view = False6273 altDown = False6274 6215 Page.name = rbData['RBname'] 6275 6216 Page.Choice = None … … 6347 6288 na = max(int(8./cell[0]),1) 6348 6289 nb = max(int(8./cell[1]),1) 6349 nunit = [na,nb,0]6350 6290 indA = range(-na,na) 6351 6291 indB = range(-nb,nb) … … 6376 6316 Fname = (os.path.splitext(projFile)[0]+'.'+mode).replace('*','+') 6377 6317 size = Page.canvas.GetSize() 6378 glPixelStorei(GL_UNPACK_ALIGNMENT, 1)6318 GL.glPixelStorei(GL.GL_UNPACK_ALIGNMENT, 1) 6379 6319 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) 6381 6321 im = Im.new("RGBA", (size[0],size[1])) 6382 6322 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) 6384 6324 im = Im.new("RGB", (size[0],size[1])) 6385 6325 try: … … 6455 6395 if event.LeftIsDown(): 6456 6396 SetRotation(newxy) 6457 Q = defaults['Quaternion']6458 6397 elif event.RightIsDown(): 6459 6398 SetTranslation(newxy) … … 6461 6400 elif event.MiddleIsDown(): 6462 6401 SetRotationZ(newxy) 6463 Q = defaults['Quaternion']6464 6402 Draw('move') 6465 6403 … … 6471 6409 def SetBackground(): 6472 6410 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) 6475 6413 6476 6414 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]) 6484 6422 6485 6423 def SetTranslation(newxy): … … 6522 6460 def SetRotationZ(newxy): 6523 6461 #first get rotation vector (= view vector) in screen coords. & angle increment 6524 View = glGetIntegerv(GL_VIEWPORT)6462 View = GL.glGetIntegerv(GL.GL_VIEWPORT) 6525 6463 cent = [View[2]/2,View[3]/2] 6526 6464 oldxy = defaults['oldxy'] … … 6545 6483 6546 6484 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) 6553 6490 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) 6561 6498 6562 6499 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() 6570 6507 6571 6508 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) 6576 6513 for Dx in Bonds: 6577 glPushMatrix()6514 GL.glPushMatrix() 6578 6515 Z = np.sqrt(np.sum(Dx**2)) 6579 6516 if Z: 6580 6517 azm = atan2d(-Dx[1],-Dx[0]) 6581 6518 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() 6588 6525 6589 6526 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-axis6527 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 6597 6534 text = gltext.TextElement(text=label,font=Font,foreground=wx.WHITE) 6598 6535 text.draw_text(scale=0.025) 6599 glEnable(GL_LIGHTING)6600 glPopMatrix()6536 GL.glEnable(GL.GL_LIGHTING) 6537 GL.glPopMatrix() 6601 6538 6602 6539 def Draw(caller=''): … … 6609 6546 VS = np.array(Page.canvas.GetSize()) 6610 6547 aspect = float(VS[0])/float(VS[1]) 6611 Zclip = 500.06612 6548 Tx,Ty,Tz = defaults['viewPoint'][0] 6613 6549 Q = defaults['Quaternion'] 6614 6550 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) 6623 6559 SetLights() 6624 6560 6625 glMatrixMode(GL_MODELVIEW)6626 glLoadIdentity()6561 GL.glMatrixMode(GL.GL_MODELVIEW) 6562 GL.glLoadIdentity() 6627 6563 matRot = G2mth.Q2Mat(Q) 6628 6564 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) 6632 6568 RenderUnitVectors(0.,0.,0.) 6633 6569 bondRad = 0.1 … … 6636 6572 bondRad = 0.05 6637 6573 atomRad = 0.2 6638 glShadeModel(GL_SMOOTH)6574 GL.glShadeModel(GL.GL_SMOOTH) 6639 6575 for iat,atom in enumerate(XYZ): 6640 6576 x,y,z = atom … … 6683 6619 Page.labels = False 6684 6620 Page.fade = False 6685 view = False6686 altDown = False6687 6621 choice = [' save as:','jpeg','tiff','bmp','use keys for:','L - toggle labels'] 6688 6622 if len(laySeq) == 2: -
trunk/GSASIIpwdGUI.py
r2525 r2544 43 43 import GSASIIElem as G2elem 44 44 import GSASIIsasd as G2sasd 45 import GSASIIexprGUI as G2exG46 45 VERY_LIGHT_GREY = wx.Colour(235,235,235) 47 46 WACV = wx.ALIGN_CENTER_VERTICAL … … 91 90 self.panel.Destroy() 92 91 self.panel = wx.Panel(self) 93 Ind = {}94 92 mainSizer = wx.BoxSizer(wx.VERTICAL) 95 93 mainSizer.Add(wx.StaticText(self.panel,label='Background RDF controls:'),0,WACV) … … 426 424 def OnAutoSearch(event): 427 425 PatternId = G2frame.PatternId 428 PickId = G2frame.PickId429 426 limits = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,PatternId, 'Limits'))[1] 430 427 inst,inst2 = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,PatternId, 'Instrument Parameters')) … … 631 628 print 'Peak Fitting with '+controls['deriv type']+' derivatives:' 632 629 PatternId = G2frame.PatternId 633 PickId = G2frame.PickId634 630 peaks = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,PatternId, 'Peak List')) 635 631 if not peaks: … … 661 657 def OnResetSigGam(event): 662 658 PatternId = G2frame.PatternId 663 PickId = G2frame.PickId664 659 Inst,Inst2 = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,PatternId, 'Instrument Parameters')) 665 660 peaks = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,PatternId, 'Peak List')) … … 674 669 675 670 def RefreshPeakGrid(event): 676 r,c = event.GetRow(),event.GetCol()677 671 678 672 event.StopPropagation() … … 1039 1033 PatternId = G2frame.PatternId 1040 1034 background = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,PatternId, 'Background')) 1041 limits = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,PatternId, 'Limits'))[1]1042 1035 inst,inst2 = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,PatternId, 'Instrument Parameters')) 1043 1036 pwddata = G2frame.PatternTree.GetItemPyData(PatternId)[1] … … 1402 1395 G2frame.ErrorDialog('No match','No histograms match '+hst,G2frame.dataFrame) 1403 1396 return 1404 copyList = []1405 1397 dlg = G2G.G2MultiChoiceDialog( 1406 1398 G2frame.dataFrame, … … 1936 1928 fmt = '%12.6g' 1937 1929 nDig = (12,6) 1938 Fmt = ' %s: ('+fmt+')'1939 1930 instSizer.Add( 1940 1931 wx.StaticText(G2frame.dataDisplay,-1,lblWdef(item,nDig[1],insDef[item])), … … 2045 2036 insDef = dict(zip(instkeys,[data[key][0] for key in instkeys])) 2046 2037 insRef = {} 2047 ValObj = {}2048 2038 RefObj = {} 2049 2039 waves = {'CuKa':[1.54051,1.54433],'TiKa':[2.74841,2.75207],'CrKa':[2.28962,2.29351], … … 2630 2620 def KeyEditPickGrid(event): 2631 2621 colList = G2frame.dataDisplay.GetSelectedCols() 2632 rowList = G2frame.dataDisplay.GetSelectedRows()2633 2622 data = G2frame.PatternTree.GetItemPyData(IndexId) 2634 2623 if event.GetKeyCode() == wx.WXK_RETURN: … … 2882 2871 2883 2872 def SetCellValue(Obj,ObjId,value): 2884 ibrav = bravaisSymb.index(controls[5])2885 2873 if controls[5] in ['Fm3m','Im3m','Pm3m']: 2886 2874 controls[6] = controls[7] = controls[8] = value … … 2965 2953 def OnHklShow(event): 2966 2954 PatternId = G2frame.PatternId 2967 PickId = G2frame.PickId2968 2955 peaks = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,PatternId, 'Index Peak List')) 2969 limits = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,PatternId, 'Limits'))[1]2970 2956 controls,bravais,cells,dminx,ssopt = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,PatternId, 'Unit Cells List')) 2971 2957 cell = controls[6:12] … … 3050 3036 3051 3037 PatternId = G2frame.PatternId 3052 PickId = G2frame.PickId3053 3038 peaks = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,PatternId, 'Index Peak List')) 3054 3039 if not len(peaks[0]): … … 3430 3415 3*[wg.GRID_VALUE_FLOAT+':10,5',]+3*[wg.GRID_VALUE_FLOAT+':10,3',]+ \ 3431 3416 [wg.GRID_VALUE_FLOAT+':10,2',wg.GRID_VALUE_BOOL] 3432 numRows = len(cells)3433 3417 table = [] 3434 3418 for cell in cells: … … 3553 3537 else: 3554 3538 Super = 0 3555 SuperVec = []3556 3539 rowLabels = [] 3557 3540 if HKLF: … … 4672 4655 data['BackFile'] = backFile.GetValue() 4673 4656 if data['BackFile']: 4674 fixBack = data['Back'][0]4675 4657 BackId = G2gd.GetPatternTreeItemId(G2frame,G2frame.root,data['BackFile']) 4676 4658 BackSample = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,BackId, 'Sample Parameters')) … … 4787 4769 else: #initial setting at 90% of max Q 4788 4770 data['QScaleLim'][0] = 0.90*data['QScaleLim'][1] 4789 azimuth = inst['Azimuth'][1]4790 4771 itemDict = {} 4791 4772 #patch … … 4915 4896 G2plt.PlotISFG(G2frame,newPlot=False) 4916 4897 4917 def OnPolaVal(event):4918 event.Skip()4919 try:4920 value = float(polaVal.GetValue())4921 if not (0.0 <= value <= 1.0):4922 raise ValueError4923 except ValueError:4924 value = inst['Polariz.'][1]4925 inst['Polariz.'][1] = value4926 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 ValueError4937 except ValueError:4938 value = inst['Azimuth'][1]4939 inst['Azimuth'][1] = value4940 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 # 4945 4926 def OnObliqCoeff(event): 4946 4927 event.Skip() … … 5138 5119 if name: 5139 5120 xydata[key] = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,G2frame.root,name)) 5140 PDFname = name5141 5121 powName = Data['Sample']['Name'] 5142 5122 powId = G2gd.GetPatternTreeItemId(G2frame,G2frame.root,powName) -
trunk/GSASIIspc.py
r2492 r2544 16 16 ########### SVN repository information ################### 17 17 import numpy as np 18 import numpy.ma as ma19 18 import numpy.linalg as nl 20 19 import scipy.optimize as so 21 import math22 20 import sys 23 21 import copy … … 1087 1085 1088 1086 def extendSSGOps(SSGOps): 1089 nOps = len(SSGOps)1090 1087 for OpA in SSGOps: 1091 1088 OpAtxt = SSMT2text(OpA) … … 1765 1762 OpM = np.array([op[0] for op in Ops],order='F') 1766 1763 OpT = np.array([op[1] for op in Ops]) 1767 Inv = SGData['SGInv']1768 1764 Cen = np.array([cen for cen in SGData['SGCen']],order='F') 1769 1765 … … 1932 1928 ' 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), 1933 1929 ' 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), 1935 1931 ' mm2(yz)':(10,13, 0,-1),'mm2(0+-)':(11,13, 0,-1),' mm2(xz)':( 8,12, 0,-1),'mm2(+0-)':( 9,12, 0,-1), 1936 1932 ' mm2(xy)':( 6,11, 0,-1),'mm2(+-0)':( 7,11, 0,-1),' 222 ':( 1,10, 0,-1),' 222(x)':( 1,13, 0,-1), … … 2166 2162 delt2 = np.eye(2)*0.001 2167 2163 FSC = np.ones(2,dtype='i') 2168 VFSC = np.ones(2)2169 2164 CSI = [np.zeros((2),dtype='i'),np.zeros(2)] 2170 2165 if 'Crenel' in waveType: … … 2411 2406 [[1.,0.,0.],[1.,0.,0.],[1.,0.,0.], [1.,0.,0.],[1.,0.,0.],[1.,0.,0.]]],} 2412 2407 xyz = np.array(XYZ)%1. 2413 xyzt = np.array(XYZ+[0,])%1.2414 2408 SGOps = copy.deepcopy(SGData['SGOps']) 2415 2409 laue = SGData['SGLaue'] … … 2689 2683 2690 2684 ''' 2691 SymName = ''2692 2685 Mult = 1 2693 2686 Isym = 0 … … 2725 2718 So far I have the element type... getting all possible locations without lookup may be impossible! 2726 2719 ''' 2727 SymElements = []2728 2720 Inv = SGData['SGInv'] 2729 Cen = SGData['SGCen']2730 2721 eleSym = {-3:['','-1'],-2:['',-6],-1:['2','-4'],0:['3','-3'],1:['4','m'],2:['6',''],3:['1','']} 2731 2722 # get operators & expand if centrosymmetric … … 3414 3405 #66 3415 3406 'C c c m':['(00g)','(00g)s00','(10g)','(10g)s00','(0b0)','(0b0)00s','(0b0)s0s','(0b0)s00',], 3416 'A mm 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',], 3417 3408 'B b m b':['(0b0)','(0b0)00s','(0b1)','(0b1)00s','(a00)','(a00)0s0','(a00)0ss','(a00)00s',], 3418 3409 #67 … … 3774 3765 result = SpcGroup(spc) 3775 3766 if result[0] == referr and referr > 0: return True 3776 keys = result[1].keys() 3777 #print result[1]['SpGrp'] 3767 # #print result[1]['SpGrp'] 3778 3768 #msg = msg0 + " in list lengths" 3779 3769 #assert len(keys) == len(refdict.keys()), msg
Note: See TracChangeset
for help on using the changeset viewer.