Changeset 699
- Timestamp:
- Aug 7, 2012 2:54:06 PM (10 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASII.py
r697 r699 2058 2058 Rw = G2str.Refine(self.GSASprojectfile,dlg) 2059 2059 finally: 2060 dlg.Destroy() 2060 dlg.Destroy() 2061 oldId = self.PatternTree.GetSelection() 2062 oldName = self.PatternTree.GetItemText(oldId) 2063 parentId = self.PatternTree.GetItemParent(oldId) 2064 parentName = '' 2065 if parentId: 2066 parentName = self.PatternTree.GetItemText(parentId) 2061 2067 dlg = wx.MessageDialog(self,'Load new result?','Refinement results, Rw =%.3f'%(Rw),wx.OK|wx.CANCEL) 2062 2068 try: … … 2074 2080 Id = item 2075 2081 item, cookie = self.PatternTree.GetNextChild(self.root, cookie) 2076 if Id: 2082 if parentName: 2083 parentId = G2gd.GetPatternTreeItemId(self, self.root, parentName) 2084 itemId = G2gd.GetPatternTreeItemId(self, parentId, oldName) 2085 self.PatternTree.SelectItem(itemId) 2086 elif Id: 2077 2087 self.PatternTree.SelectItem(Id) 2078 2088 finally: -
trunk/GSASIIgrid.py
r698 r699 76 76 77 77 [ wxID_BACKCOPY,wxID_LIMITCOPY,wxID_SAMPLECOPY, wxID_BACKFLAGCOPY, wxID_SAMPLEFLAGCOPY, 78 ] = [wx.NewId() for item in range(5)] 78 wxID_SAMPLESAVE, wxID_SAMPLELOAD, 79 ] = [wx.NewId() for item in range(7)] 79 80 80 81 [ wxID_INSTPRMRESET,wxID_CHANGEWAVETYPE,wxID_INSTCOPY, wxID_INSTFLAGCOPY, wxID_INSTLOAD, … … 349 350 self.SampleMenu.Append(menu=self.SampleEdit, title='File') 350 351 self.SampleMenu.Append(menu=MyHelp(self,helpType='Sample Parameters'),title='&Help') 352 self.SampleEdit.Append(id=wxID_SAMPLELOAD, kind=wx.ITEM_NORMAL,text='Load', 353 help='Load sample parameters from file') 354 self.SampleEdit.Append(id=wxID_SAMPLESAVE, kind=wx.ITEM_NORMAL,text='Save', 355 help='Save sample parameters to file') 351 356 self.SampleEdit.Append(id=wxID_SAMPLECOPY, kind=wx.ITEM_NORMAL,text='Copy', 352 357 help='Copy refinable sample parameters to other histograms') -
trunk/GSASIIimage.py
r698 r699 196 196 print 'Bad refinement - no result' 197 197 return result[0],wave 198 199 198 200 199 def ImageLocalMax(image,w,Xpix,Ypix): 201 200 w2 = w*2 … … 324 323 xy = fsolve(func,xy0,args=(azm,phi,R0,R1,A,B))+cent 325 324 return xy 325 326 def GetDetXYfromThAzm(Th,Azm,data): 327 dsp = data['wavelength']/(2.0*npsind(Th)) 328 329 return GetDetectorXY(dsp,azm,data) 326 330 327 331 def GetTthAzmDsp(x,y,data): … … 409 413 cent = data['center'] 410 414 dist = data['distance'] 411 cent = data['center']412 415 tilt = data['tilt'] 413 416 phi = data['rotation'] … … 746 749 def FitStrSta(Image,StrSta,Controls,Masks): 747 750 748 print Image.shape 749 print StrSta 750 print Controls 751 print Masks 751 # print 'Masks:',Masks 752 wave = Controls['wavelength'] 753 dist = Controls['distance'] 754 center = Controls['center'] 755 rot = Controls['rotation'] 756 tilt = Controls['tilt'] 757 imSize = Controls['size'] 758 pixSize = Controls['pixelSize'] 759 azmOff = Controls['azmthOff'] 760 scalex = 1000./pixSize[0] 761 scaley = 1000./pixSize[1] 762 763 for ring in StrSta['d-zero']: 764 ellipse = GetEllipse(ring['Dset'],Controls) 765 Ring,delt = makeRing(ring['Dset'],ellipse,ring['pixLimit'],ring['cutoff'],scalex,scaley,Image) 766 Ring = np.array(Ring).T 767 ring['ImxyObs'] = np.array(Ring[:2]) #need to apply masks to this to eliminate bad points 768 [x,y] = np.array(makeIdealRing(ellipse)).T 769 Tth,azm = GetTthAzm(x,y,Controls) 770 th = Tth/2. 771 th += np.sum(StrSta['strain']*calcFij(StrAta['phi'],0.,azm,th)) 772 Tth = th*2. 773 774 775 def calcFij(omg,phi,azm,th): 776 ''' Uses parameters as defined by Bob He & Kingsley Smity, Adv. in X-Ray Anal. 41, 501 (1997) 777 omg: his omega = sample omega rotation; 0 when incident beam || sample surface, 90 778 when perp. to sample surface 779 phi: his phi = sample phi rotation; usually = 0, axis rotates with omg. 780 azm: his chi = azimuth around incident beam 781 th: his theta = theta 782 ''' 783 a = npsind(th)*npcosd(omg)+npsind(azm)*npcosd(th)*npsind(omg) 784 b = -npcosd(azm)*npcosd(th) 785 c = npsind(th)*npsind(omg)-npsind(azm)*npcosd(th)*npcosd(omg) 786 d = a*npcosd(phi)-b*npsind(phi) 787 e = a*npsind(phi)+b*npcosd(phi) 788 Fij = np.array([ 789 [d**2,d*e,c*d], 790 [d*e,e**2,c*e], 791 [c*d,c*e,c**2]]) 792 return -Fij*nptand(th) 793 -
trunk/GSASIIimgGUI.py
r698 r699 1081 1081 1082 1082 def OnAppendDzero(event): 1083 data['d-zero'].append({'Dset':1.0,'Dcalc':0.0,'pixLimit':10,'cutoff':10.0,'ImxyObs':[[],[]],'Imxy calc':[[],[]]})1083 data['d-zero'].append({'Dset':1.0,'Dcalc':0.0,'pixLimit':10,'cutoff':10.0,'ImxyObs':[[],[]],'ImxyCalc':[[],[]]}) 1084 1084 UpdateStressStrain(G2frame,data) 1085 1085 … … 1155 1155 G2gd.GetPatternTreeItemId(G2frame,G2frame.Image, 'Image Controls')) 1156 1156 G2img.FitStrSta(G2frame.ImageZ,data,Controls,Masks) 1157 G2plt.PlotExposedImage(G2frame,event=event) 1157 1158 1158 1159 def SamSizer(): -
trunk/GSASIIphsGUI.py
r698 r699 288 288 parent = self.GetParent() 289 289 parent.Raise() 290 self.EndModal(wx.ID_CANCEL) 291 290 self.EndModal(wx.ID_CANCEL) 291 292 class GridFractionEditor(wg.PyGridCellEditor): 293 def __init__(self,grid): 294 wg.PyGridCellEditor.__init__(self) 295 296 def Create(self, parent, id, evtHandler): 297 self._tc = wx.TextCtrl(parent, id, "") 298 self._tc.SetInsertionPoint(0) 299 self.SetControl(self._tc) 300 301 if evtHandler: 302 self._tc.PushEventHandler(evtHandler) 303 304 self._tc.Bind(wx.EVT_CHAR, self.OnChar) 305 306 def SetSize(self, rect): 307 self._tc.SetDimensions(rect.x, rect.y, rect.width+2, rect.height+2, 308 wx.SIZE_ALLOW_MINUS_ONE) 309 310 def BeginEdit(self, row, col, grid): 311 self.startValue = grid.GetTable().GetValue(row, col) 312 self._tc.SetValue(str(self.startValue)) 313 self._tc.SetInsertionPointEnd() 314 self._tc.SetFocus() 315 self._tc.SetSelection(0, self._tc.GetLastPosition()) 316 317 def EndEdit(self, row, col, grid): 318 changed = False 319 320 val = self._tc.GetValue() 321 322 if val != self.startValue: 323 changed = True 324 if '/' in val and '.' not in val: 325 val += '.' 326 try: 327 val = float(eval(val)) 328 except (SyntaxError,NameError): 329 val = self.startValue 330 grid.GetTable().SetValue(row, col, val) # update the table 331 332 self.startValue = '' 333 self._tc.SetValue('') 334 return changed 335 336 def Reset(self): 337 self._tc.SetValue(self.startValue) 338 self._tc.SetInsertionPointEnd() 339 340 def Clone(self): 341 return GridFractionEditor(grid) 342 343 def StartingKey(self, evt): 344 self.OnChar(evt) 345 if evt.GetSkipped(): 346 self._tc.EmulateKeyPress(evt) 347 348 def OnChar(self, evt): 349 key = evt.GetKeyCode() 350 if key > 255: 351 evt.Skip() 352 return 353 char = chr(key) 354 if char in '.+-/0123456789': 355 self._tc.WriteText(char) 356 else: 357 evt.Skip() 358 292 359 def FindAtomIndexByIDs(atomData,IDs,Draw=True): 293 360 indx = [] … … 1140 1207 colType = colLabels.index('Type') 1141 1208 colSS = colLabels.index('site sym') 1209 colX = colLabels.index('x') 1142 1210 colIA = colLabels.index('I/A') 1143 1211 colU11 = colLabels.index('U11') 1144 1212 colUiso = colLabels.index('Uiso') 1213 attr = wx.grid.GridCellAttr() 1214 attr.SetEditor(GridFractionEditor(Atoms)) 1215 for c in range(colX,colX+3): 1216 Atoms.SetColAttr(c, attr) 1145 1217 for i in range(colU11-1,colU11+6): 1146 1218 Atoms.SetColSize(i,50) -
trunk/GSASIIplot.py
r696 r699 2101 2101 if G2frame.PatternTree.GetItemText(G2frame.PickId) in 'Stress/Strain': 2102 2102 print 'plot stress/strain stuff' 2103 print StrSta 2103 for ring in StrSta['d-zero']: 2104 for xring,yring in ring['ImxyObs'].T: 2105 Plot.plot(xring,yring,'r+') 2106 for xring,yring in ring['ImxyCalc'].T: 2107 Plot.add_artist(Polygon(ring['ImxyCalc'].T,ec='b',fc='none')) 2108 Plot.plot(xring,yring) 2104 2109 #masks - mask lines numbered after integration limit lines 2105 2110 spots = Masks['Points'] -
trunk/GSASIIpwdGUI.py
r697 r699 993 993 copyNames += addNames 994 994 return histType,copyNames 995 996 def OnSampleSave(event): 997 '''Respond to the Sample Parameters Operations/Save menu 998 item: writes current parameters to a .samprm file 999 ''' 1000 dlg = wx.FileDialog(G2frame, 'Choose GSAS-II sample parameters file', '.', '', 1001 'sample parameter files (*.samprm)|*.samprm',wx.FD_SAVE|wx.FD_OVERWRITE_PROMPT|wx.CHANGE_DIR) 1002 try: 1003 if dlg.ShowModal() == wx.ID_OK: 1004 filename = dlg.GetPath() 1005 # make sure extension is .samprm 1006 filename = os.path.splitext(filename)[0]+'.samprm' 1007 File = open(filename,'w') 1008 File.write("#GSAS-II sample parameter file; do not add/delete or change order of items!\n") 1009 File.write("'Type':'"+str(data['Type'])+"'\n") 1010 File.write("'Gonio. radius':"+str(data['Gonio. radius'])+"\n") 1011 File.close() 1012 finally: 1013 dlg.Destroy() 1014 1015 1016 def OnSampleLoad(event): 1017 '''Loads sample parameters from a G2 .samprm file 1018 in response to the Sample Parameters-Operations/Load menu 1019 1020 Note that similar code is found in ReadPowderInstprm (GSASII.py) 1021 ''' 1022 dlg = wx.FileDialog(G2frame, 'Choose GSAS-II sample parameters file', '.', '', 1023 'sample parameter files (*.samprm)|*.samprm',wx.OPEN|wx.CHANGE_DIR) 1024 try: 1025 if dlg.ShowModal() == wx.ID_OK: 1026 filename = dlg.GetPath() 1027 File = open(filename,'r') 1028 S = File.readline() 1029 newItems = {} 1030 while S: 1031 if S[0] == '#': 1032 S = File.readline() 1033 continue 1034 [item,val] = S[:-1].split(':') 1035 newItems[item.strip("'")] = eval(val) 1036 S = File.readline() 1037 File.close() 1038 print newItems 1039 data.update(newItems) 1040 G2frame.PatternTree.SetItemPyData(G2gd.GetPatternTreeItemId(G2frame,G2frame.PatternId,'Sample Parameters'),data) 1041 UpdateSampleGrid(G2frame,data) 1042 finally: 1043 dlg.Destroy() 995 1044 996 1045 def OnSampleCopy(event): … … 1085 1134 G2frame.Bind(wx.EVT_MENU, OnSampleCopy, id=G2gd.wxID_SAMPLECOPY) 1086 1135 G2frame.Bind(wx.EVT_MENU, OnSampleFlagCopy, id=G2gd.wxID_SAMPLEFLAGCOPY) 1136 G2frame.Bind(wx.EVT_MENU, OnSampleSave, id=G2gd.wxID_SAMPLESAVE) 1137 G2frame.Bind(wx.EVT_MENU, OnSampleLoad, id=G2gd.wxID_SAMPLELOAD) 1087 1138 if not G2frame.dataFrame.GetStatusBar(): 1088 1139 Status = G2frame.dataFrame.CreateStatusBar()
Note: See TracChangeset
for help on using the changeset viewer.