Changeset 4763
- Timestamp:
- Jan 13, 2021 4:34:34 PM (3 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIdataGUI.py
r4761 r4763 6229 6229 'wxID_ATOMSPDISAGL', 'wxID_ISODISP', 'wxID_ADDHATOM', 'wxID_UPDATEHATOM', 6230 6230 'wxID_ATOMSROTATE', 'wxID_ATOMSDENSITY','wxID_ATOMSBNDANGLHIST', 6231 'wxID_ATOMSSETALL', 'wxID_ATOMSSETSEL','wxID_ATOMFRACSPLIT', )6231 'wxID_ATOMSSETALL', 'wxID_ATOMSSETSEL','wxID_ATOMFRACSPLIT','wxID_COLLECTATOMS') 6232 6232 self.AtomsMenu = wx.MenuBar() 6233 6233 self.PrefillDataMenu(self.AtomsMenu) … … 6253 6253 self.AtomEdit.Append(G2G.wxID_ATOMMOVE,'Move selected atom to view point','Select a single atom to be moved to view point in plot') 6254 6254 self.AtomEdit.Append(G2G.wxID_MAKEMOLECULE,'Assemble molecule','Select a single atom to assemble as a molecule from scattered atom positions') 6255 self.AtomEdit.Append(G2G.wxID_COLLECTATOMS,'Collect atoms','Collect selected atoms to specified unit cell location') 6255 6256 self.AtomEdit.Append(G2G.wxID_RELOADDRAWATOMS,'Reload draw atoms','Reload atom drawing list') 6256 6257 submenu = wx.Menu() -
trunk/GSASIImath.py
r4761 r4763 558 558 ################################################################################ 559 559 560 def getAtomPtrs(data,draw=False): 561 ''' get atom data pointers cx,ct,cs,cia in Atoms or Draw Atoms lists 562 NB:may not match column numbers in displayed table 563 564 param: dict: data phase data structure 565 draw: boolean True if Draw Atoms list pointers are required 566 return: cx,ct,cs,cia pointers to atom xyz, type, site sym, uiso/aniso flag 567 ''' 568 if draw: 569 return data['Drawing']['atomPtrs'] 570 else: 571 return data['General']['AtomPtrs'] 572 560 573 def FindMolecule(ind,generalData,atomData): #uses numpy & masks - very fast even for proteins! 561 574 … … 752 765 generalData = data['General'] 753 766 SGData = generalData['SGData'] 754 cx,ct,cs,cia = ge neralData['AtomPtrs']767 cx,ct,cs,cia = getAtomPtrs(data) 755 768 drawingData = data['Drawing'] 756 dcx,dct,dcs,dci = drawingData['atomPtrs']769 dcx,dct,dcs,dci = getAtomPtrs(data,True) 757 770 atoms = data['Atoms'] 758 771 drawAtoms = drawingData['Atoms'] … … 785 798 def FindNeighbors(phase,FrstName,AtNames,notName=''): 786 799 General = phase['General'] 787 cx,ct,cs,cia = General['AtomPtrs']800 cx,ct,cs,cia = getAtomPtrs(phase) 788 801 Atoms = phase['Atoms'] 789 802 atNames = [atom[ct-1] for atom in Atoms] … … 873 886 def FindAllNeighbors(phase,FrstName,AtNames,notName='',Orig=None,Short=False): 874 887 General = phase['General'] 875 cx,ct,cs,cia = General['AtomPtrs']888 cx,ct,cs,cia = getAtomPtrs(phase) 876 889 Atoms = phase['Atoms'] 877 890 atNames = [atom[ct-1] for atom in Atoms] … … 1885 1898 SGData = generalData['SGData'] 1886 1899 SSGData = generalData['SSGData'] 1887 cx,ct,cs,cia = ge neralData['AtomPtrs']1900 cx,ct,cs,cia = getAtomPtrs(data) 1888 1901 drawingData = data['Drawing'] 1889 1902 modul = generalData['SuperVec'][0] 1890 dcx,dct,dcs,dci = drawingData['atomPtrs']1903 dcx,dct,dcs,dci = getAtomPtrs(data,True) 1891 1904 atoms = data['Atoms'] 1892 1905 drawAtoms = drawingData['Atoms'] … … 2943 2956 General = Phase['General'] 2944 2957 Amat,Bmat = G2lat.cell2AB(General['Cell'][1:7]) 2945 cx,ct,cs,cia = General['AtomPtrs']2958 cx,ct,cs,cia = getAtomPtrs(data) 2946 2959 Atoms = Phase['Atoms'] 2947 2960 cartAtoms = [] … … 4147 4160 Unique.append(icntr) 4148 4161 return Unique 4162 4163 def AtomsCollect(data,Ind,Sel): 4164 '''Finds the symmetry set of atoms for those selected. Selects 4165 the one closest to the selected part of the unit cell. 4166 Works on the contents of data['Map Peaks']. Called from OnPeaksUnique in 4167 GSASIIphsGUI.py, 4168 4169 :param data: the phase data structure 4170 :param list Ind: list of selected peak indices 4171 :param int Sel: selected part of unit to find atoms closest to 4172 4173 :returns: the list of symmetry unique peaks from among those given in Ind 4174 ''' 4175 cx,ct,cs,ci = getAtomPtrs(data) 4176 cent = np.ones(3)*.5 4177 generalData = data['General'] 4178 Amat,Bmat = G2lat.cell2AB(generalData['Cell'][1:7]) 4179 SGData = generalData['SGData'] 4180 Atoms = copy.deepcopy(data['Atoms']) 4181 Indx = [True for ind in Ind] 4182 # scan through peaks, finding all peaks equivalent to peak ind 4183 for ind in Ind: 4184 if Indx[ind]: 4185 xyz = Atoms[ind][cx:cx+3] 4186 uij = Atoms[ind][ci+2:ci+8] 4187 if Atoms[ind][ci] == 'A': 4188 Equiv = list(G2spc.GenAtom(xyz,SGData,Uij=uij)) 4189 Uijs = np.array([x[1] for x in Equiv]) 4190 else: 4191 Equiv = G2spc.GenAtom(xyz,SGData) 4192 xyzs = np.array([x[0] for x in Equiv]) 4193 dzeros = np.sqrt(np.sum(np.inner(Amat,xyzs)**2,axis=0)) 4194 dcent = np.sqrt(np.sum(np.inner(Amat,xyzs-cent)**2,axis=0)) 4195 xyzs = np.hstack((xyzs,dzeros[:,nxs],dcent[:,nxs])) 4196 cind = np.argmin(xyzs.T[Sel-1]) 4197 Atoms[ind][cx:cx+3] = xyzs[cind][:3] 4198 if Atoms[ind][ci] == 'A': 4199 Atoms[ind][ci+2:ci+8] = Uijs[cind] 4200 return Atoms 4149 4201 4150 4202 ################################################################################ … … 5061 5113 SGT = np.array([SGData['SGOps'][i][1] for i in range(len(SGData['SGOps']))]) 5062 5114 fixAtoms = data['Atoms'] #if any 5063 cx,ct,cs = ge neralData['AtomPtrs'][:3]5115 cx,ct,cs = getAtomPtrs(data)[:3] 5064 5116 aTypes = set([]) 5065 5117 parmDict = {'Bmat':Bmat,'Gmat':Gmat} -
trunk/GSASIIphsGUI.py
r4759 r4763 1198 1198 dlg.Destroy() 1199 1199 return indx 1200 1201 def getAtomPtrs(data,draw=False):1202 ''' get atom data pointers cx,ct,cs,cia in Atoms or Draw Atoms lists1203 NB:may not match column numbers in displayed table1204 1205 param: dict: data phase data structure1206 draw: boolean True if Draw Atoms list pointers are required1207 return: cx,ct,cs,cia pointers to atom xyz, type, site sym, uiso/aniso flag1208 '''1209 if draw:1210 return data['Drawing']['atomPtrs']1211 else:1212 return data['General']['AtomPtrs']1213 1200 1214 1201 def SetPhaseWindow(phasePage,mainSizer=None,Scroll=0): … … 3650 3637 '''Inserts a new atom into list immediately before every selected atom 3651 3638 ''' 3652 cx,ct,cs,ci = getAtomPtrs(data)3639 cx,ct,cs,ci = G2mth.getAtomPtrs(data) 3653 3640 indx = getAtomSelections(Atoms,ct-1) 3654 3641 for a in reversed(sorted(indx)): … … 3671 3658 '''Adds H atoms to fill out coordination sphere for selected atoms 3672 3659 ''' 3673 cx,ct,cs,cia = getAtomPtrs(data)3660 cx,ct,cs,cia = G2mth.getAtomPtrs(data) 3674 3661 indx = getAtomSelections(Atoms,ct-1) 3675 3662 if not indx: return … … 3794 3781 3795 3782 def OnAtomMove(event): 3796 cx,ct,cs,ci = getAtomPtrs(data)3783 cx,ct,cs,ci = G2mth.getAtomPtrs(data) 3797 3784 indx = getAtomSelections(Atoms,ct-1) 3798 3785 drawData = data['Drawing'] … … 3841 3828 3842 3829 def AtomDelete(event): 3843 cx,ct,cs,ci = getAtomPtrs(data)3830 cx,ct,cs,ci = G2mth.getAtomPtrs(data) 3844 3831 indx = getAtomSelections(Atoms) 3845 3832 colLabels = [Atoms.GetColLabelValue(c) for c in range(Atoms.GetNumberCols())] … … 3877 3864 3878 3865 def AtomRefine(event): 3879 cx,ct,cs,ci = getAtomPtrs(data)3866 cx,ct,cs,ci = G2mth.getAtomPtrs(data) 3880 3867 indx = getAtomSelections(Atoms,ct-1) 3881 3868 if not indx: return … … 3902 3889 3903 3890 def AtomModify(event): 3904 cx,ct,cs,ci = getAtomPtrs(data)3891 cx,ct,cs,ci = G2mth.getAtomPtrs(data) 3905 3892 indx = getAtomSelections(Atoms,ct-1) 3906 3893 if not indx: return … … 4013 4000 4014 4001 def AtomTransform(event): 4015 cx,ct,cs,ci = getAtomPtrs(data)4002 cx,ct,cs,ci = G2mth.getAtomPtrs(data) 4016 4003 indx = getAtomSelections(Atoms,ct-1) 4017 4004 if not indx: return … … 4083 4070 # 'yz':np.array([[0,i,j] for i in range(3) for j in range(3)])-np.array([1,1,0]), 4084 4071 # '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])} 4085 # cx,ct,cs,ci = getAtomPtrs(data)4072 # cx,ct,cs,ci = G2mth.getAtomPtrs(data) 4086 4073 # indx = getAtomSelections(Atoms,ct-1) 4087 4074 # if indx: … … 4126 4113 # print "select one or more rows of atoms" 4127 4114 # G2frame.ErrorDialog('Select atom',"select one or more atoms then redo") 4115 4116 def CollectAtoms(event): 4117 cx,ct,cs,ci = G2mth.getAtomPtrs(data) 4118 Ind = getAtomSelections(Atoms,ct-1) 4119 if Ind: 4120 choice = ['x=0','y=0','z=0','origin','center'] 4121 dlg = wx.SingleChoiceDialog(G2frame,'Atoms closest to:','Select',choice) 4122 if dlg.ShowModal() == wx.ID_OK: 4123 sel = dlg.GetSelection()+1 4124 dlg.Destroy() 4125 else: 4126 dlg.Destroy() 4127 return 4128 wx.BeginBusyCursor() 4129 data['Atoms'] = G2mth.AtomsCollect(data,Ind,sel) 4130 wx.EndBusyCursor() 4131 Atoms.ClearSelection() 4132 data['Drawing']['Atoms'] = [] 4133 OnReloadDrawAtoms(event) 4134 FillAtomsGrid(Atoms) 4128 4135 4129 4136 def MakeMolecule(event): 4130 cx,ct,cs,ci = getAtomPtrs(data)4137 cx,ct,cs,ci = G2mth.getAtomPtrs(data) 4131 4138 indx = getAtomSelections(Atoms,ct-1) 4132 4139 DisAglCtls = {} … … 4181 4188 def OnDistAngle(event,fp=None,hist=False): 4182 4189 'Compute distances and angles' 4183 cx,ct,cs,ci = getAtomPtrs(data)4190 cx,ct,cs,ci = G2mth.getAtomPtrs(data) 4184 4191 indx = getAtomSelections(Atoms,ct-1) 4185 4192 Oxyz = [] … … 4252 4259 def OnFracSplit(event): 4253 4260 'Split atom frac accordintg to atom type & refined site fraction' 4254 cx,ct,cs,ci = getAtomPtrs(data)4261 cx,ct,cs,ci = G2mth.getAtomPtrs(data) 4255 4262 indx = getAtomSelections(Atoms,ct-1) 4256 4263 if indx: … … 7444 7451 7445 7452 def OnRestraint(event): 7446 cx,ct,cs,ci = getAtomPtrs(data,draw=True)7453 cx,ct,cs,ci = G2mth.getAtomPtrs(data,draw=True) 7447 7454 indx = getAtomSelections(drawAtoms,ct-1) 7448 7455 if not indx: return … … 7500 7507 7501 7508 def OnDefineRB(event): 7502 cx,ct,cs,ci = getAtomPtrs(data,draw=True)7509 cx,ct,cs,ci = G2mth.getAtomPtrs(data,draw=True) 7503 7510 indx = getAtomSelections(drawAtoms,ct-1) 7504 7511 if not indx: return … … 7763 7770 7764 7771 def DrawAtomStyle(event): 7765 cx,ct,cs,ci = getAtomPtrs(data,draw=True)7772 cx,ct,cs,ci = G2mth.getAtomPtrs(data,draw=True) 7766 7773 indx = getAtomSelections(drawAtoms,ct-1) 7767 7774 if not indx: return … … 7785 7792 7786 7793 def DrawAtomLabel(event): 7787 cx,ct,cs,ci = getAtomPtrs(data,draw=True)7794 cx,ct,cs,ci = G2mth.getAtomPtrs(data,draw=True) 7788 7795 indx = getAtomSelections(drawAtoms,ct-1) 7789 7796 if not indx: return … … 7805 7812 7806 7813 def DrawAtomColor(event): 7807 cx,ct,cs,ci = getAtomPtrs(data,draw=True)7814 cx,ct,cs,ci = G2mth.getAtomPtrs(data,draw=True) 7808 7815 indx = getAtomSelections(drawAtoms,ct-1) 7809 7816 if not indx: return … … 7865 7872 7866 7873 def SetViewPoint(event): 7867 cx,ct,cs,ci = getAtomPtrs(data,draw=True)7874 cx,ct,cs,ci = G2mth.getAtomPtrs(data,draw=True) 7868 7875 indx = getAtomSelections(drawAtoms,ct-1) 7869 7876 if not indx: return … … 7881 7888 7882 7889 def AddSymEquiv(event): 7883 cx,ct,cs,ci = getAtomPtrs(data,draw=True)7890 cx,ct,cs,ci = G2mth.getAtomPtrs(data,draw=True) 7884 7891 indx = getAtomSelections(drawAtoms,ct-1) 7885 7892 if not indx: return … … 7936 7943 7937 7944 def AddSphere(event): 7938 cx,ct,cs,ci = getAtomPtrs(data,draw=True)7945 cx,ct,cs,ci = G2mth.getAtomPtrs(data,draw=True) 7939 7946 indx = getAtomSelections(drawAtoms,ct-1,'as center of sphere addition', 7940 7947 includeView=True) … … 8135 8142 added = 0 8136 8143 targets = [item for item in atomTypes if params[item]] 8137 cx,ct,cs,ci = getAtomPtrs(data,draw=True)8144 cx,ct,cs,ci = G2mth.getAtomPtrs(data,draw=True) 8138 8145 rep = 0 8139 8146 allrep = 0 … … 12682 12689 G2frame.Bind(wx.EVT_MENU, OnAtomMove, id=G2G.wxID_ATOMMOVE) 12683 12690 G2frame.Bind(wx.EVT_MENU, MakeMolecule, id=G2G.wxID_MAKEMOLECULE) 12691 G2frame.Bind(wx.EVT_MENU, CollectAtoms, id=G2G.wxID_COLLECTATOMS) 12684 12692 G2frame.Bind(wx.EVT_MENU, OnReloadDrawAtoms, id=G2G.wxID_RELOADDRAWATOMS) 12685 12693 G2frame.Bind(wx.EVT_MENU, OnDistAngle, id=G2G.wxID_ATOMSDISAGL) -
trunk/GSASIIplot.py
r4759 r4763 8452 8452 elif G2frame.phaseDisplay.GetPageText(getSelection()) == 'Draw Atoms': 8453 8453 atomList = drawAtoms 8454 cx,ct,cs,cia = G2 phG.getAtomPtrs(data,True)8454 cx,ct,cs,cia = G2mth.getAtomPtrs(data,True) 8455 8455 cs -= 1 #cs points at style for drawings; want sytsym 8456 8456 else: 8457 8457 atomList = data['Atoms'] 8458 cx,ct,cs,ciax = G2 phG.getAtomPtrs(data)8458 cx,ct,cs,ciax = G2mth.getAtomPtrs(data) 8459 8459 for i,atom in enumerate(atomList): 8460 8460 x,y,z = atom[cx:cx+3] … … 9215 9215 ballScale = drawingData['ballScale'] 9216 9216 xyzA = np.array((x,y,z)) 9217 cx,ct,cs,ci = G2 phG.getAtomPtrs(data)9217 cx,ct,cs,ci = G2mth.getAtomPtrs(data) 9218 9218 cellArray = G2lat.CellBlock(1) 9219 9219 radDict = dict(zip(*G2phG.getAtomRadii(data))) -
trunk/imports/G2img_1TIF.py
r4762 r4763 69 69 if self.Npix == 0: 70 70 G2fil.G2Print("GetTifData failed to read "+str(filename)+" Trying PIL") 71 # import scipy.misc72 # self.Image = scipy.misc.imread(filename,flatten=True)73 71 import PIL.Image as PI 74 72 self.Image = PI.open(filename,mode='r') 75 # self.Image.shape = self.Image.size76 # for scipy 1.2 & later scipy.misc.imread will be removed77 # with note to use imageio.imread instead78 # (N.B. scipy.misc.imread uses PIL/pillow perhaps better to just use pillow)79 73 self.Npix = self.Image.size 80 74 if ParentFrame: … … 82 76 self.Comments = ['no metadata'] 83 77 self.Data = {'wavelength': 0.1, 'pixelSize': [200., 200.], 'distance': 100.0} 84 # try: #as suggested by Adam Creuziger 1/12/202185 # self.Data['size'] = list(self.Image.shape)86 # except:87 # self.Data['size'] = list(self.Image.size)88 # try:89 # self.Data['center'] = [int(i/2) for i in self.Image.shape]90 # except:91 # self.Data['center'] = [int(i/2) for i in self.Image.size]92 78 self.Data['size'] = list(self.Image.size) 93 79 self.Data['center'] = [int(i/2) for i in self.Image.size]
Note: See TracChangeset
for help on using the changeset viewer.