Changeset 837
- Timestamp:
- Jan 22, 2013 7:18:17 PM (10 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Exercises/single crystal/Ib3.hkl
r626 r837 366 366 16 2 2 859. 23. 367 367 16 3 1 41. 17. 368 0 0 0 0. 0. -
trunk/GSASIIconstrGUI.py
r836 r837 663 663 macro = [] 664 664 else: # cancel was pressed 665 mac xro = []665 macro = [] 666 666 finally: 667 667 dlg.Destroy() 668 668 return macro #advanced past 1st line 669 670 def getTextFile(): 671 defDir = os.path.join(os.path.split(__file__)[0],'GSASIImacros') 672 dlg = wx.FileDialog(G2frame,message='Choose rigid body text file', 673 defaultDir=defDir,defaultFile="",wildcard="GSAS-II text file (*.txt)|*.txt", 674 style=wx.OPEN | wx.CHANGE_DIR) 675 try: 676 if dlg.ShowModal() == wx.ID_OK: 677 txtfile = dlg.GetPath() 678 text = open(txtfile,'Ur') 679 else: # cancel was pressed 680 text = [] 681 finally: 682 dlg.Destroy() 683 return text 669 684 670 685 def OnAddRigidBody(event): … … 676 691 elif 'Z-matrix' in G2frame.dataDisplay.GetPageText(page): 677 692 AddZMatrixRB() 693 694 def OnImportRigidBody(event): 695 page = G2frame.dataDisplay.GetSelection() 696 if 'Vector' in G2frame.dataDisplay.GetPageText(page): 697 pass 698 elif 'Residue' in G2frame.dataDisplay.GetPageText(page): 699 ImportResidueRB() 700 elif 'Z-matrix' in G2frame.dataDisplay.GetPageText(page): 701 pass 702 678 703 679 704 def AddVectorRB(): … … 737 762 data['Residue'][rbId] = {'RBname':rbName,'rbXYZ':rbXYZ,'rbTypes':rbTypes, 738 763 'atNames':atNames,'rbRef':[nOrig-1,mRef-1,nRef-1],'rbSeq':rbSeq,'SelSeq':[0,0,0]} 739 print 'R esidue'+rbName+' added'764 print 'Rigid body '+rbName+' added' 740 765 macStr = macro.readline() 741 766 macro.close() 767 UpdateResidueRB() 768 769 def ImportResidueRB(): 770 AtInfo = data['Residue']['AtInfo'] 771 text = getTextFile() 772 if not text: 773 return 774 rbId = ran.randint(0,sys.maxint) 775 rbTypes = [] 776 rbXYZ = [] 777 rbSeq = [] 778 atNames = [] 779 txtStr = text.readline() 780 items = txtStr.split() 781 while len(items): 782 atName = items[0] 783 atType = items[1] 784 atNames.append(atName) 785 rbXYZ.append([float(items[i]) for i in [2,3,4]]) 786 rbTypes.append(atType) 787 if atType not in AtInfo: 788 Info = G2elem.GetAtomInfo(atType) 789 AtInfo[atType] = [Info['Drad'],Info['Color']] 790 txtStr = text.readline() 791 items = txtStr.split() 792 rbXYZ = np.array(rbXYZ)-np.array(rbXYZ[0]) 793 data['Residue'][rbId] = {'RBname':'UNKRB','rbXYZ':rbXYZ,'rbTypes':rbTypes, 794 'atNames':atNames,'rbRef':[0,1,2],'rbSeq':[],'SelSeq':[0,0,0]} 795 print 'Rigid body UNKRB added' 796 text.close() 742 797 UpdateResidueRB() 743 798 … … 1076 1131 ResidueRBSizer.Add(rbResidues(rbId,XYZ,rbData),0) 1077 1132 ResidueRBSizer.Add((5,5),0) 1078 slideSizer,angSlide = SlideSizer() 1133 if rbData['rbSeq']: 1134 slideSizer,angSlide = SlideSizer() 1079 1135 for iSeq,Seq in enumerate(rbData['rbSeq']): 1080 1136 ResidueRBSizer.Add(wx.StaticText(ResidueRBDisplay,-1,'Seq: %d'%(iSeq)), … … 1084 1140 0,wx.ALIGN_CENTER_VERTICAL) 1085 1141 ResidueRBSizer.Add(SeqSizer(angSlide,rbId,iSeq,Seq,rbData['atNames'])) 1086 ResidueRBSizer.Add(slideSizer,) 1142 if rbData['rbSeq']: 1143 ResidueRBSizer.Add(slideSizer,) 1087 1144 ResidueRBSizer.Add((5,25),) 1088 1145 ResidueRBSizer.Layout() … … 1124 1181 G2gd.SetDataMenuBar(G2frame,G2frame.dataFrame.RigidBodyMenu) 1125 1182 G2frame.dataFrame.Bind(wx.EVT_MENU, OnAddRigidBody, id=G2gd.wxID_RIGIDBODYADD) 1183 G2frame.dataFrame.Bind(wx.EVT_MENU, OnImportRigidBody, id=G2gd.wxID_RIGIDBODYIMPORT) 1126 1184 G2frame.dataDisplay = G2gd.GSNoteBook(parent=G2frame.dataFrame,size=G2frame.dataFrame.GetClientSize()) 1127 1185 -
trunk/GSASIIgrid.py
r831 r837 104 104 ] = [wx.NewId() for item in range(7)] 105 105 106 [ wxID_RIGIDBODYADD,wxID_DRAWDEFINERB, 107 ] = [wx.NewId() for item in range( 2)]106 [ wxID_RIGIDBODYADD,wxID_DRAWDEFINERB,wxID_RIGIDBODYIMPORT, 107 ] = [wx.NewId() for item in range(3)] 108 108 109 109 [ wxID_SAVESEQSEL, … … 458 458 self.RigidBodyEdit.Append(id=wxID_RIGIDBODYADD, kind=wx.ITEM_NORMAL,text='Add rigid body', 459 459 help='Add rigid body') 460 self.RigidBodyEdit.Append(id=wxID_RIGIDBODYIMPORT, kind=wx.ITEM_NORMAL,text='Import XYZ from txt file', 461 help='Import rigid body XYZ') 460 462 461 463 self.PostfillDataMenu() … … 1477 1479 HKLmax = data['HKLmax'] 1478 1480 HKLmin = data['HKLmin'] 1479 if data['ifFc']: 1480 typeChoices = ['Fosq','Fo','|DFsq|/sig','|DFsq|>sig','|DFsq|>3sig'] 1481 else: 1482 typeChoices = ['Fosq','Fo'] 1481 typeChoices = ['Fosq','Fo','|DFsq|/sig','|DFsq|>sig','|DFsq|>3sig'] 1482 # if data['ifFc']: 1483 # typeChoices = ['Fosq','Fo','|DFsq|/sig','|DFsq|>sig','|DFsq|>3sig'] 1484 # else: 1485 # typeChoices = ['Fosq','Fo'] 1483 1486 G2frame.dataDisplay = wx.Panel(G2frame.dataFrame) 1484 1487 SetDataMenuBar(G2frame) … … 1621 1624 Nvars = len(data['varyList']) 1622 1625 Rvals = data['Rvals'] 1623 text = '\nFinal residuals: \nRw p= %.3f%% \nchi**2 = %.1f \nGOF = %.2f'%(Rvals['Rwp'],Rvals['chisq'],Rvals['GOF'])1626 text = '\nFinal residuals: \nRw = %.3f%% \nchi**2 = %.1f \nGOF = %.2f'%(Rvals['Rwp'],Rvals['chisq'],Rvals['GOF']) 1624 1627 text += '\nNobs = %d \nNvals = %d'%(Rvals['Nobs'],Nvars) 1625 1628 if 'lamMax' in Rvals: -
trunk/GSASIIplot.py
r836 r837 243 243 self.G2plotNB.status.SetFields(['','HKL, Fosq, sig, Fcsq, delFsq/sig = '+HKLtxt]) 244 244 245 def OnSCKeyPress(event):246 print event.key247 248 245 try: 249 246 plotNum = self.G2plotNB.plotList.index('Structure Factors') … … 259 256 plotNum = self.G2plotNB.plotList.index('Structure Factors') 260 257 Page = self.G2plotNB.nb.GetPage(plotNum) 261 # Page.canvas.mpl_connect('key_press_event', OnSCKeyPress)262 258 Page.canvas.mpl_connect('pick_event', OnSCPick) 263 259 Page.canvas.mpl_connect('motion_notify_event', OnSCMotion) … … 275 271 FosqMax = Data['FoMax'] 276 272 FoMax = math.sqrt(FosqMax) 277 ifFc = Data['ifFc']278 273 xlabel = ['k, h=','h, k=','h, l='] 279 274 ylabel = ['l','l','k'] … … 286 281 for refl in HKLref: 287 282 H = np.array(refl[:3]) 288 sig,Fosq,Fcsq = refl[7:10]283 Fosq,sig,Fcsq = refl[5:8] 289 284 HKL.append(H) 290 285 HKLF.append([Fosq,sig,Fcsq]) 291 286 if H[izone] == Data['Layer']: 287 A = 0 292 288 B = 0 293 289 if Type == 'Fosq': … … 300 296 C = abs(A-B) 301 297 elif Type == '|DFsq|/sig': 302 A = abs(Fosq-Fcsq)/(scale*sig) 298 if sig > 0.: 299 A = abs(Fosq-Fcsq)/(scale*sig) 300 B = 0 303 301 elif Type == '|DFsq|>sig': 304 A = abs(Fosq-Fcsq)/(scale*sig) 305 if A < 1.0: A = 0 302 if sig > 0.: 303 A = abs(Fosq-Fcsq)/sig 304 if A < 1.0: A = 0 305 A /= scale 306 B = 0 306 307 elif Type == '|DFsq|>3sig': 307 A = abs(Fosq-Fcsq)/(scale*sig) 308 if A < 3.0: A = 0 308 if sig > 0.: 309 A = abs(Fosq-Fcsq)/sig 310 if A < 3.0: A = 0 311 A /= scale 312 B = 0 309 313 xy = (H[pzone[izone][0]],H[pzone[izone][1]]) 310 314 if A > 0.0: … … 324 328 Plot.set_xlim((HKLmin[pzone[izone][0]],HKLmax[pzone[izone][0]])) 325 329 Plot.set_ylim((HKLmin[pzone[izone][1]],HKLmax[pzone[izone][1]])) 326 if not newPlot: 327 Page.toolbar.push_current() 328 Plot.set_xlim(xylim[0]) 329 Plot.set_ylim(xylim[1]) 330 xylim = [] 331 Page.toolbar.push_current() 332 Page.toolbar.draw() 333 else: 334 Page.canvas.draw() 330 Page.canvas.draw() 331 # if not newPlot: 332 # Page.toolbar.push_current() 333 # Plot.set_xlim(xylim[0]) 334 # Plot.set_ylim(xylim[1]) 335 # xylim = [] 336 # Page.toolbar.push_current() 337 # Page.toolbar.draw() 338 # else: 339 # Page.canvas.draw() 335 340 336 341 ################################################################################ … … 1759 1764 G2frame.G2plotNB.status.SetFields(['','']) 1760 1765 acolor = mpl.cm.get_cmap(G2frame.VcovColor) 1761 Img = Plot.imshow(covArray,aspect='equal',cmap=acolor,interpolation='nearest',origin='lower') 1766 Img = Plot.imshow(covArray,aspect='equal',cmap=acolor,interpolation='nearest',origin='lower', 1767 vmin=-1.,vmax=1.) 1762 1768 imgAx = Img.get_axes() 1763 1769 ytics = imgAx.get_yticks() … … 2632 2638 mode = cb.GetValue() 2633 2639 if mode in ['jpeg','bmp','tiff',]: 2634 Fname = os.path.join t(Mydir,generalData['Name']+'.'+mode)2640 Fname = os.path.join(Mydir,generalData['Name']+'.'+mode) 2635 2641 size = Page.canvas.GetSize() 2636 2642 glPixelStorei(GL_UNPACK_ALIGNMENT, 1) … … 3602 3608 3603 3609 try: 3604 plotNum = G2frame.G2plotNB.plotList.index( rbData['RBname'])3610 plotNum = G2frame.G2plotNB.plotList.index('Rigid body') 3605 3611 Page = G2frame.G2plotNB.nb.GetPage(plotNum) 3606 3612 except ValueError: 3607 Plot = G2frame.G2plotNB.addOgl( rbData['RBname'])3608 plotNum = G2frame.G2plotNB.plotList.index( rbData['RBname'])3613 Plot = G2frame.G2plotNB.addOgl('Rigid body') 3614 plotNum = G2frame.G2plotNB.plotList.index('Rigid body') 3609 3615 Page = G2frame.G2plotNB.nb.GetPage(plotNum) 3610 3616 Page.views = False -
trunk/imports/G2sfact.py
r762 r837 14 14 15 15 class HKLF_ReaderClass(G2IO.ImportStructFactor): 16 'Routines to import reflections from a HKLF file'16 'Routines to import F, sig(F) reflections from a HKLF file' 17 17 def __init__(self): 18 18 super(self.__class__,self).__init__( # fancy way to self-reference 19 19 extensionlist=('.hkl','.HKL'), 20 20 strictExtension=False, 21 formatName = ' HKL',21 formatName = 'F HKL', 22 22 longFormatName = 'Simple (hkl Fo sig(Fo)) Structure factor text file' 23 23 ) … … 44 44 h,k,l,Fo,sigFo = S.split() 45 45 h,k,l = [int(h),int(k),int(l)] 46 if not any([h,k,l]): 47 break 46 48 Fo = float(Fo) 47 49 sigFo = float(sigFo) … … 56 58 traceback.print_exc(file=sys.stdout) 57 59 return False 60 61 class HKLF2_ReaderClass(G2IO.ImportStructFactor): 62 'Routines to import F**2, sig(F**2) reflections from a HKLF file' 63 def __init__(self): 64 super(self.__class__,self).__init__( # fancy way to self-reference 65 extensionlist=('.hkl','.HKL'), 66 strictExtension=False, 67 formatName = 'F**2 HKL', 68 longFormatName = 'Simple (hkl Fo**2 sig(Fo**2)) Structure factor text file' 69 ) 70 # Validate the contents 71 def ContentsValidator(self, filepointer): 72 S = filepointer.readline() 73 while '#' in S[0]: #get past comments, if any 74 S = filepointer.readline() 75 for i in range(3): # scan a few lines 76 S = S.split() 77 if len(S) != 5: return False 78 for v in S: 79 try: 80 float(v) 81 except ValueError: 82 return False 83 S = filepointer.readline() 84 return True 85 86 def Reader(self,filename,filepointer, ParentFrame=None, **unused): 87 try: 88 for S in filepointer: 89 if S[0] == '#': continue #ignore comments, if any 90 h,k,l,Fo,sigFo = S.split() 91 h,k,l = [int(h),int(k),int(l)] 92 if not any([h,k,l]): 93 break 94 Fo = float(Fo) 95 sigFo = float(sigFo) 96 # h,k,l,m,dsp,Fo2,sig,Fc2,Fot2,Fct2,phase,... 97 self.RefList.append([h,k,l,0,0,Fo,sigFo,0,Fo,0,0,[],[],0,{}]) 98 self.UpdateControls(Type='Fosq',FcalcPresent=False) # set Fobs type & if Fcalc values are loaded 99 self.UpdateParameters(Type='SXC',Wave=None) # histogram type 100 return True 101 except Exception as detail: 102 print self.formatName+' read error:'+str(detail) # for testing 103 import traceback 104 traceback.print_exc(file=sys.stdout) 105 return False -
trunk/imports/G2sfact_CIF.py
r762 r837 20 20 def __init__(self): 21 21 super(self.__class__,self).__init__( # fancy way to self-reference 22 extensionlist =('.CIF','.cif','.HKL','.hkl'),23 strictExtension =False,22 extensionlist = ('.CIF','.cif','.FCF','.fcf','.HKL','.hkl'), 23 strictExtension = False, 24 24 formatName = 'CIF', 25 25 longFormatName = 'CIF format structure factor file (.cif or .hkl)'
Note: See TracChangeset
for help on using the changeset viewer.