Changeset 1925
- Timestamp:
- Jul 10, 2015 3:50:10 PM (8 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIIO.py
r1920 r1925 178 178 if not os.path.exists(imagefile): 179 179 dlg = wx.FileDialog(G2frame, 'Previous image file not found; open here', '.', '',\ 180 'Any image file (*.edf;*.tif;*.tiff;*.mar*;*.ge*;*.avg;*.sum;*.img )\181 |*.edf;*.tif;*.tiff;*.mar*;*.ge*;*.avg;*.sum;*.img |\180 'Any image file (*.edf;*.tif;*.tiff;*.mar*;*.ge*;*.avg;*.sum;*.img;*.cor)\ 181 |*.edf;*.tif;*.tiff;*.mar*;*.ge*;*.avg;*.sum;*.img;*.cor|\ 182 182 European detector file (*.edf)|*.edf|\ 183 183 Any detector tif (*.tif;*.tiff)|*.tif;*.tiff|\ 184 184 MAR file (*.mar*)|*.mar*|\ 185 GE Image (*.ge*;*.avg;*.sum )|*.ge*;*.avg;*.sum|\185 GE Image (*.ge*;*.avg;*.sum;*.cor)|*.ge*;*.avg;*.sum;*.cor|\ 186 186 ADSC Image (*.img)|*.img|\ 187 187 All files (*.*)|*.*',wx.OPEN|wx.CHANGE_DIR) … … 303 303 elif ext in ['.mar3450','.mar2300','.mar2560']: 304 304 Comments,Data,Npix,Image = GetMAR345Data(imagefile) 305 elif ext in ['.sum','.avg' ] or 'ge' in ext:305 elif ext in ['.sum','.avg','.cor'] or 'ge' in ext: 306 306 Comments,Data,Npix,Image = GetGEsumData(imagefile) 307 307 elif ext == '.G2img': … … 410 410 print 'Read GE sum file: ',filename 411 411 File = open(filename,'rb') 412 if '.sum' in filename :413 head = ['GE detector sum data from APS 1-ID',]412 if '.sum' in filename or '.cor' in filename: 413 head = ['GE detector sum or cor data from APS 1-ID',] 414 414 sizexy = [2048,2048] 415 415 elif '.avg' in filename or '.ge' in filename: … … 424 424 File.seek(pos) 425 425 Npix = sizexy[0]*sizexy[1] 426 if '.sum' in filename :426 if '.sum' in filename or '.cor' in filename: 427 427 image = np.array(ar.array('f',File.read(4*Npix)),dtype=np.int32) 428 428 elif '.avg' in filename or '.ge' in filename: -
trunk/GSASIIconstrGUI.py
r1924 r1925 775 775 Dx = np.inner(Amat,XYZ-XYZ[Orig]).T 776 776 dist = np.sqrt(np.sum(Dx**2,axis=1)) 777 sumR = AtInfo[OType]+0.5 777 sumR = AtInfo[OType]+0.5 #H-atoms only! 778 778 IndB = ma.nonzero(ma.masked_greater(dist-0.85*sumR,0.)) 779 779 for j in IndB[0]: -
trunk/GSASIIgrid.py
r1924 r1925 316 316 parent.Raise() 317 317 self.EndModal(wx.ID_CANCEL) 318 319 class AddHatomDialog(wx.Dialog): 320 '''H atom addition dialog. After :meth:`ShowModal` returns, the results 321 are found in dict :attr:`self.data`, which is accessed using :meth:`GetData`. 322 :param wx.Frame parent: reference to parent frame (or None) 323 :param dict Neigh: a dict of atom names with list of atom name, dist pairs for neighboring atoms 324 :param dict phase: a dict containing the phase as defined by 325 :ref:`Phase Tree Item <Phase_table>` 326 ''' 327 def __init__(self,parent,Neigh,phase): 328 wx.Dialog.__init__(self,parent,wx.ID_ANY,'H atom add', 329 pos=wx.DefaultPosition,style=wx.DEFAULT_DIALOG_STYLE) 330 self.panel = wxscroll.ScrolledPanel(self) #just a dummy - gets destroyed in Draw! 331 self.Neigh = Neigh 332 self.phase = phase 333 self.Hatoms = [] 334 self.Draw(self.Neigh,self.phase) 335 336 def Draw(self,Neigh,phase): 337 '''Creates the contents of the dialog. Normally called 338 by :meth:`__init__`. 339 ''' 340 def OnHSelect(event): 341 Obj = event.GetEventObject() 342 item,i = Indx[Obj.GetId()] 343 for obj in Indx[item]: 344 obj.SetValue(False) 345 Obj.SetValue(True) 346 self.Neigh[item][2] = i 347 348 self.panel.Destroy() 349 self.panel = wxscroll.ScrolledPanel(self,style = wx.DEFAULT_DIALOG_STYLE) 350 mainSizer = wx.BoxSizer(wx.VERTICAL) 351 mainSizer.Add(wx.StaticText(self.panel,-1,'H atom add controls for phase %s:'%(phase['General']['Name'])), 352 0,wx.LEFT|wx.TOP,10) 353 mainSizer.Add(wx.StaticText(self.panel,-1," Atom: Add # H's Neighbors, dist"),0,wx.TOP|wx.LEFT,5) 354 nHatms = ['0','1','2','3'] 355 dataSizer = wx.FlexGridSizer(0,3,0,0) 356 Indx = {} 357 for inei,neigh in enumerate(Neigh): 358 dataSizer.Add(wx.StaticText(self.panel,-1,' %s: '%(neigh[0])),0,WACV) 359 nH = 1 #for O atom 360 if 'C' in neigh[0] or 'N' in neigh[0]: 361 nH = 4-len(neigh[1]) 362 neigh[2] = nH 363 checks = wx.BoxSizer(wx.HORIZONTAL) 364 Ids = [] 365 for i in range(nH+1): 366 nHs = wx.CheckBox(self.panel,-1,label=nHatms[i]) 367 if i == neigh[2]: 368 nHs.SetValue(True) 369 Indx[nHs.GetId()] = [inei,i] 370 Ids.append(nHs) 371 nHs.Bind(wx.EVT_CHECKBOX, OnHSelect) 372 checks.Add(nHs,0,WACV) 373 Indx[inei] = Ids 374 dataSizer.Add(checks,0,WACV) 375 lineSizer = wx.BoxSizer(wx.HORIZONTAL) 376 for bond in neigh[1]: 377 lineSizer.Add(wx.StaticText(self.panel,-1,' %s, %.3f'%(bond[0],bond[1])),0,WACV) 378 dataSizer.Add(lineSizer,0,WACV) 379 mainSizer.Add(dataSizer,0,wx.LEFT,5) 380 381 CancelBtn = wx.Button(self.panel,-1,'Cancel') 382 CancelBtn.Bind(wx.EVT_BUTTON, self.OnCancel) 383 OkBtn = wx.Button(self.panel,-1,'Ok') 384 OkBtn.Bind(wx.EVT_BUTTON, self.OnOk) 385 btnSizer = wx.BoxSizer(wx.HORIZONTAL) 386 btnSizer.Add((20,20),1) 387 btnSizer.Add(OkBtn) 388 btnSizer.Add((20,20),1) 389 btnSizer.Add(CancelBtn) 390 btnSizer.Add((20,20),1) 391 mainSizer.Add(btnSizer,0,wx.EXPAND|wx.BOTTOM|wx.TOP, 10) 392 self.panel.SetSizer(mainSizer) 393 self.panel.SetupScrolling() 394 395 def GetData(self): 396 'Returns the values from the dialog' 397 return self.Neigh #has #Hs to add for each entry 398 399 def OnOk(self,event): 400 'Called when the OK button is pressed' 401 parent = self.GetParent() 402 parent.Raise() 403 self.EndModal(wx.ID_OK) 404 405 def OnCancel(self,event): 406 parent = self.GetParent() 407 parent.Raise() 408 self.EndModal(wx.ID_CANCEL) 318 409 319 410 class DisAglDialog(wx.Dialog): … … 331 422 search ranges for each element. 332 423 ''' 333 def __init__(self,parent,data,default ):424 def __init__(self,parent,data,default,Reset=True): 334 425 wx.Dialog.__init__(self,parent,wx.ID_ANY, 335 426 'Distance Angle Controls', 336 427 pos=wx.DefaultPosition,style=wx.DEFAULT_DIALOG_STYLE) 337 428 self.default = default 429 self.Reset = Reset 338 430 self.panel = wx.Panel(self) #just a dummy - gets destroyed in Draw! 339 431 self._default(data,self.default) … … 396 488 OkBtn = wx.Button(self.panel,-1,"Ok") 397 489 OkBtn.Bind(wx.EVT_BUTTON, self.OnOk) 398 ResetBtn = wx.Button(self.panel,-1,'Reset')399 ResetBtn.Bind(wx.EVT_BUTTON, self.OnReset)400 490 btnSizer = wx.BoxSizer(wx.HORIZONTAL) 401 491 btnSizer.Add((20,20),1) 402 492 btnSizer.Add(OkBtn) 403 btnSizer.Add(ResetBtn) 493 if self.Reset: 494 ResetBtn = wx.Button(self.panel,-1,'Reset') 495 ResetBtn.Bind(wx.EVT_BUTTON, self.OnReset) 496 btnSizer.Add(ResetBtn) 404 497 btnSizer.Add((20,20),1) 405 498 mainSizer.Add(btnSizer,0,wx.EXPAND|wx.BOTTOM|wx.TOP, 10) -
trunk/GSASIImath.py
r1845 r1925 376 376 return XYZ 377 377 378 def FindNeighbors(phase,FrstName,AtNames): 379 General = phase['General'] 380 cx,ct,cs,cia = General['AtomPtrs'] 381 Atoms = phase['Atoms'] 382 atNames = [atom[ct-1] for atom in Atoms] 383 Cell = General['Cell'][1:7] 384 Amat,Bmat = G2lat.cell2AB(Cell) 385 atTypes = General['AtomTypes'] 386 Radii = np.array(General['BondRadii']) 387 AtInfo = dict(zip(atTypes,Radii)) #or General['BondRadii'] 388 Orig = atNames.index(FrstName) 389 OType = Atoms[Orig][ct] 390 XYZ = getAtomXYZ(Atoms,cx) 391 Neigh = [] 392 Dx = np.inner(Amat,XYZ-XYZ[Orig]).T 393 dist = np.sqrt(np.sum(Dx**2,axis=1)) 394 sumR = np.array([AtInfo[OType]+AtInfo[atom[ct]] for atom in Atoms]) 395 IndB = ma.nonzero(ma.masked_greater(dist-0.85*sumR,0.)) 396 for j in IndB[0]: 397 if j != Orig: 398 Neigh.append([AtNames[j],dist[j]]) 399 return Neigh 400 378 401 def AtomUij2TLS(atomData,atPtrs,Amat,Bmat,rbObj): #unfinished & not used 379 402 '''default doc string -
trunk/GSASIIphsGUI.py
r1924 r1925 1537 1537 1538 1538 def OnHydAtomAdd(event): 1539 print "Doesn't do anything yet!"1540 1539 indx = Atoms.GetSelectedRows() 1541 1540 if indx: 1541 DisAglCtls = {} 1542 1542 generalData = data['General'] 1543 1543 if 'DisAglCtls' in generalData: 1544 1544 DisAglCtls = generalData['DisAglCtls'] 1545 dlg = G2gd.DisAglDialog(G2frame,DisAglCtls,generalData) 1545 if 'H' not in DisAglCtls['AtomTypes']: 1546 DisAglCtls['AtomTypes'].append('H') 1547 DisAglCtls['AngleRadii'].append(0.5) 1548 DisAglCtls['BondRadii'].append(0.5) 1549 dlg = G2gd.DisAglDialog(G2frame,DisAglCtls,generalData,Reset=False) 1546 1550 if dlg.ShowModal() == wx.ID_OK: 1547 1551 DisAglCtls = dlg.GetData() … … 1551 1555 dlg.Destroy() 1552 1556 generalData['DisAglCtls'] = DisAglCtls 1557 cx,ct,cs,cia = generalData['AtomPtrs'] 1553 1558 atomData = data['Atoms'] 1559 AtNames = [atom[ct-1] for atom in atomData] 1554 1560 colLabels = [Atoms.GetColLabelValue(c) for c in range(Atoms.GetNumberCols())] 1561 Neigh = [] 1555 1562 for ind in indx: 1556 1563 atom = atomData[ind] 1564 if atom[ct] not in ['C','N','O']: 1565 continue 1566 neigh = [atom[ct-1],G2mth.FindNeighbors(data,atom[ct-1],AtNames),0] 1567 if len(neigh[1]) > 3 or (atom[ct] == 'O' and len(neigh[1]) > 1): 1568 continue 1569 Neigh.append(neigh) 1570 if Neigh: 1571 dlg = G2gd.AddHatomDialog(G2frame,Neigh,data) 1572 if dlg.ShowModal() == wx.ID_OK: 1573 Neigh = dlg.GetData() 1574 for neigh in Neigh: 1575 print neigh 1576 1577 dlg.Destroy() 1578 else: 1579 wx.MessageBox('No candidates found',caption='Add H atom Error',style=wx.ICON_EXCLAMATION) 1557 1580 1558 1581 def OnAtomMove(event):
Note: See TracChangeset
for help on using the changeset viewer.