Changeset 397
- Timestamp:
- Oct 21, 2011 12:15:50 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASII.py
r395 r397 344 344 DataType = DataType.strip()[0:3] #just 1st 3 chars 345 345 wx.BeginBusyCursor() 346 Sample = {'Scale':[1.0,True],'Type':'Debye-Scherrer','Absorption':[0.0,False], 347 'DisplaceX':[0.0,False],'DisplaceY':[0.0,False],'Diffuse':[], 348 'Temperature':Temperature,'Pressure':1.0,'Humidity':0.0,'Voltage':0.0,'Force':0.0, 349 'Gonio. radius':200.0,'Omega':0.0,'Chi':0.0,'Phi':0.0} 346 Sample = G2pdG.GetDefaultSample() 350 347 try: 351 348 for Item in Data: … … 762 759 Id = self.PatternTree.AppendItem(parent=self.root,text=outname) 763 760 if Id: 764 Sample = {'Scale':[1.0,True],'Type':'Debye-Scherrer','Absorption':[0.0,False], 765 'DisplaceX':[0.0,False],'DisplaceY':[0.0,False],'Diffuse':[], 766 'Temperature':300.,'Pressure':1.0,'Humidity':0.0, 767 'Voltage':0.0,'Force':0.0,'Gonio. radius':200.0, 768 'Omega':0.0,'Chi':0.0,'Phi':0.0} 761 Sample = G2pdG.SetDefaultSample() 769 762 self.PatternTree.SetItemPyData(Id,[[''],[Xsum,Ysum,Wsum,YCsum,YBsum,YDsum]]) 770 763 self.PatternTree.SetItemPyData(self.PatternTree.AppendItem(Id,text='Comments'),Comments) -
trunk/GSASIIIO.py
r391 r397 19 19 import GSASIIspc as G2spc 20 20 import GSASIIlattice as G2lat 21 import GSASIIpwdGUI as G2pdG 21 22 import GSASIIElem as G2el 22 23 import os.path as ospath … … 848 849 849 850 def SaveIntegration(self,PickId,data): 850 azms = self.Integrate[1] [:-1]851 azms = self.Integrate[1] 851 852 X = self.Integrate[2][:-1] 852 853 Xminmax = [X[0],X[-1]] … … 859 860 codes = [0 for i in range(11)] 860 861 LRazm = data['LRazimuth'] 862 Azms = [] 861 863 if data['fullIntegrate'] and data['outAzimuths'] == 1: 862 864 Azms = [45.0,] #a poor man's average? 863 for i,azm in enumerate(azms): 865 else: 866 for i,azm in enumerate(azms[:-1]): 867 Azms.append((azms[i+1]+azm)/2.) 868 for i,azm in enumerate(azms[:-1]): 864 869 item, cookie = self.PatternTree.GetFirstChild(self.root) 865 870 Id = 0 … … 869 874 Id = item 870 875 item, cookie = self.PatternTree.GetNextChild(self.root, cookie) 871 parms = ['PXC',data['wavelength'],0.0,0.99,1.0,-0.10,0.4,0.30,1.0,0.0001, azm] #set polarization for synchrotron radiation!876 parms = ['PXC',data['wavelength'],0.0,0.99,1.0,-0.10,0.4,0.30,1.0,0.0001,Azms[i]] #set polarization for synchrotron radiation! 872 877 Y = self.Integrate[0][i] 873 878 W = 1./Y #probably not true 874 Sample = {'Scale':[1.0,True],'Type':'Debye-Scherrer','Absorption':[0.0,False],'DisplaceX':[0.0,False], 875 'DisplaceY':[0.0,False],'Diffuse':[],'Temperature':300.,'Pressure':1.0,'Humidity':0.0,'Voltage':0.0,'Force':0.0} 879 Sample = G2pdG.SetDefaultSample() 876 880 if Id: 877 881 self.PatternTree.SetItemPyData(G2gd.GetPatternTreeItemId(self,Id, 'Comments'),Comments) … … 884 888 self.PatternTree.SetItemPyData(G2gd.GetPatternTreeItemId(self,Id,'Reflection Lists'),{}) 885 889 else: 886 Id = self.PatternTree.AppendItem(parent=self.root,text=name+" Azm= %.2f"%( azm))890 Id = self.PatternTree.AppendItem(parent=self.root,text=name+" Azm= %.2f"%(Azms[i])) 887 891 self.PatternTree.SetItemPyData(self.PatternTree.AppendItem(Id,text='Comments'),Comments) 888 892 self.PatternTree.SetItemPyData(self.PatternTree.AppendItem(Id,text='Limits'),[tuple(Xminmax),Xminmax]) -
trunk/GSASIIgrid.py
r395 r397 32 32 ] = [wx.NewId() for _init_coll_DrawAtom_Items in range(10)] 33 33 34 [ wxID_IMCALIBRATE, 34 [ wxID_IMCALIBRATE,wxID_IMRECALIBRATE,wxID_IMINTEGRATE, wxID_IMCLEARCALIB, 35 35 wxID_IMCOPYCONTROLS, wxID_INTEGRATEALL, wxID_IMSAVECONTROLS, wxID_IMLOADCONTROLS, 36 ] = [wx.NewId() for _init_coll_IMAGE_Items in range( 7)]36 ] = [wx.NewId() for _init_coll_IMAGE_Items in range(8)] 37 37 38 38 [ wxID_MASKCOPY, wxID_MASKSAVE, wxID_MASKLOAD, … … 204 204 parent.Append(help='Calibrate detector by fitting to calibrant lines', 205 205 id=wxID_IMCALIBRATE, kind=wx.ITEM_NORMAL,text='Calibrate') 206 parent.Append(help='Recalibrate detector by fitting to calibrant lines', 207 id=wxID_IMRECALIBRATE, kind=wx.ITEM_NORMAL,text='Realibrate') 206 208 parent.Append(help='Clear calibration data points and rings',id=wxID_IMCLEARCALIB, 207 209 kind=wx.ITEM_NORMAL,text='Clear calibration') -
trunk/GSASIIimage.py
r396 r397 376 376 tay = ma.compressed(ma.array(tay.flatten(),mask=tam)) 377 377 return zip(tax,tay) 378 379 def ImageRecalibrate(self,data): 380 import copy 381 import ImageCalibrants as calFile 382 print 'Image recalibration:' 383 time0 = time.time() 384 pixelSize = data['pixelSize'] 385 scalex = 1000./pixelSize[0] 386 scaley = 1000./pixelSize[1] 387 pixLimit = data['pixLimit'] 388 cutoff = data['cutoff'] 389 data['rings'] = [] 390 data['ellipses'] = [] 391 if not data['calibrant']: 392 print 'no calibration material selected' 393 return True 394 395 skip = data['calibskip'] 396 dmin = data['calibdmin'] 397 Bravais,Cells = calFile.Calibrants[data['calibrant']][:2] 398 HKL = [] 399 for bravais,cell in zip(Bravais,Cells): 400 A = G2lat.cell2A(cell) 401 hkl = G2lat.GenHBravais(dmin,bravais,A)[skip:] 402 HKL += hkl 403 HKL = G2lat.sortHKLd(HKL,True,False) 404 wave = data['wavelength'] 405 cent = data['center'] 406 dist = data['distance'] 407 cent = data['center'] 408 tilt = data['tilt'] 409 phi = data['rotation'] 410 for H in HKL: 411 dsp = H[3] 412 ellipse = GetEllipse(dsp,data) 413 Ring,delt = makeRing(dsp,ellipse,pixLimit,cutoff,scalex,scaley,self.ImageZ) 414 if Ring: 415 numZ = len(Ring) 416 data['rings'].append(np.array(Ring)) 417 data['ellipses'].append(copy.deepcopy(ellipse+('r',))) 418 else: 419 continue 420 rings = np.concatenate((data['rings']),axis=0) 421 p0 = [dist,cent[0],cent[1],phi,tilt] 422 result,newWave = FitDetector(rings,p0,wave) 423 data['distance'] = result[0] 424 data['center'] = result[1:3] 425 data['rotation'] = np.mod(result[3],360.0) 426 data['tilt'] = result[4] 427 N = len(data['ellipses']) 428 data['ellipses'] = [] #clear away individual ellipse fits 429 for H in HKL[:N]: 430 ellipse = GetEllipse(H[3],data) 431 data['ellipses'].append(copy.deepcopy(ellipse+('b',))) 432 433 print 'calibration time = ',time.time()-time0 434 G2plt.PlotImage(self,newImage=True) 435 return True 436 378 437 379 438 def ImageCalibrate(self,data): … … 545 604 p0 = [dist,cent[0],cent[1],phi,tilt] 546 605 result,newWave = FitDetector(rings,p0,wave) 547 # print 'Suggested new wavelength = ',('%.5f')%(newWave),' (not reliable if distance > 2m)'548 606 data['distance'] = result[0] 549 607 data['center'] = result[1:3] -
trunk/GSASIIimgGUI.py
r342 r397 215 215 data['ellipses'] = [] 216 216 self.dataFrame.ImageEdit.Enable(id=G2gd.wxID_IMCLEARCALIB,enable=False) 217 self.dataFrame.ImageEdit.Enable(id=G2gd.wxID_IMRECALIBRATE,enable=False) 217 218 G2plt.PlotExposedImage(self,event=event) 218 219 219 220 def OnCalibrate(event): 220 221 self.dataFrame.ImageEdit.Enable(id=G2gd.wxID_IMCLEARCALIB,enable=True) 222 self.dataFrame.ImageEdit.Enable(id=G2gd.wxID_IMRECALIBRATE,enable=True) 221 223 self.dataFrame.GetStatusBar().SetStatusText('Select > 4 points on 1st used ring; LB to pick, RB on point to delete else RB to finish') 222 224 self.ifGetRing = True 225 226 def OnRecalibrate(event): 227 G2img.ImageRecalibrate(self,data) 223 228 224 229 def OnIntegrate(event): … … 390 395 self.dataFrame.CreateStatusBar() 391 396 self.dataFrame.Bind(wx.EVT_MENU, OnCalibrate, id=G2gd.wxID_IMCALIBRATE) 397 self.dataFrame.Bind(wx.EVT_MENU, OnRecalibrate, id=G2gd.wxID_IMRECALIBRATE) 392 398 self.dataFrame.Bind(wx.EVT_MENU, OnClearCalib, id=G2gd.wxID_IMCLEARCALIB) 393 399 if not data['rings']: 394 400 self.dataFrame.ImageEdit.Enable(id=G2gd.wxID_IMCLEARCALIB,enable=False) 401 self.dataFrame.ImageEdit.Enable(id=G2gd.wxID_IMRECALIBRATE,enable=False) 395 402 self.dataFrame.Bind(wx.EVT_MENU, OnIntegrate, id=G2gd.wxID_IMINTEGRATE) 396 403 self.dataFrame.Bind(wx.EVT_MENU, OnIntegrateAll, id=G2gd.wxID_INTEGRATEALL) -
trunk/GSASIIphsGUI.py
r395 r397 2090 2090 G2plt.PlotStrain(self,data) 2091 2091 2092 def OnCopyData(event): 2093 #how about HKLF data? This is only for PWDR data 2094 Obj = event.GetEventObject() 2095 Obj.SetValue(False) 2096 hist = Indx[Obj.GetId()] 2097 sourceDict = UseList[hist] 2098 copyNames = ['Scale','Pref.Ori.','Size','Mustrain','HStrain','Extinction'] 2099 copyDict = {} 2100 for name in copyNames: 2101 copyDict[name] = sourceDict[name] 2102 keyList = ['All',]+UseList.keys() 2103 if UseList: 2104 copyList = [] 2105 dlg = wx.MultiChoiceDialog(self, 2106 'Copy parameters to which histograms?', 'Copy parameters', 2107 keyList, wx.CHOICEDLG_STYLE) 2108 try: 2109 if dlg.ShowModal() == wx.ID_OK: 2110 result = dlg.GetSelections() 2111 for i in result: 2112 copyList.append(keyList[i]) 2113 if 'All' in copyList: 2114 copyList = keyList[1:] 2115 for item in copyList: 2116 UseList[item].update(copyDict) 2117 UpdateDData() 2118 finally: 2119 dlg.Destroy() 2120 2092 2121 def OnScaleRef(event): 2093 2122 Obj = event.GetEventObject() … … 2302 2331 histData = UseList[item] 2303 2332 mainSizer.Add((5,5),0) 2333 2334 showSizer = wx.BoxSizer(wx.HORIZONTAL) 2304 2335 showData = wx.CheckBox(dataDisplay,-1,label=' Show '+item) 2305 2336 showData.SetValue(UseList[item]['Show']) 2306 2337 Indx[showData.GetId()] = item 2307 2338 showData.Bind(wx.EVT_CHECKBOX, OnShowData) 2308 mainSizer.Add(showData,0,wx.ALIGN_CENTER_VERTICAL) 2339 showSizer.Add(showData,0,wx.ALIGN_CENTER_VERTICAL) 2340 copyData = wx.CheckBox(dataDisplay,-1,label=' Copy?') 2341 Indx[copyData.GetId()] = item 2342 copyData.Bind(wx.EVT_CHECKBOX,OnCopyData) 2343 showSizer.Add(copyData,wx.ALIGN_CENTER_VERTICAL) 2344 mainSizer.Add(showSizer,0,wx.ALIGN_CENTER_VERTICAL) 2309 2345 mainSizer.Add((0,5),0) 2346 2310 2347 if UseList[item]['Show']: 2311 2348 scaleSizer = wx.BoxSizer(wx.HORIZONTAL) … … 2612 2649 SGData = generalData['SGData'] 2613 2650 UseList = data['Histograms'] 2651 newList = [] 2614 2652 NShkl = len(G2spc.MustrainNames(SGData)) 2615 2653 NDij = len(G2spc.HStrainNames(SGData)) 2616 2654 keyList = UseList.keys() 2617 TextList = [ ]2655 TextList = ['All PWDR'] 2618 2656 if self.PatternTree.GetCount(): 2619 2657 item, cookie = self.PatternTree.GetFirstChild(self.root) … … 2627 2665 if dlg.ShowModal() == wx.ID_OK: 2628 2666 result = dlg.GetSelections() 2629 for i in result: 2630 histoName = TextList[i] 2667 for i in result: newList.append(TextList[i]) 2668 if 'All PWDR' in newList: 2669 newList = TextList[1:] 2670 for histoName in newList: 2631 2671 pId = G2gd.GetPatternTreeItemId(self,self.root,histoName) 2632 2672 UseList[histoName] = {'Histogram':histoName,'Show':False, … … 2646 2686 def OnDataDelete(event): 2647 2687 UseList = data['Histograms'] 2648 keyList = UseList.keys()2688 keyList = ['All',]+UseList.keys() 2649 2689 keyList.sort() 2650 2690 DelList = [] … … 2657 2697 if dlg.ShowModal() == wx.ID_OK: 2658 2698 result = dlg.GetSelections() 2659 for i in result: DelList.append(keyList[i]) 2699 for i in result: 2700 DelList.append(keyList[i]) 2701 if 'All' in DelList: 2702 DelList = keyList[1:] 2660 2703 for i in DelList: 2661 2704 del UseList[i] -
trunk/GSASIIpwdGUI.py
r395 r397 43 43 else: 44 44 return False 45 45 46 def SetDefaultSample(): 47 return {'Scale':[1.0,True],'Type':'Debye-Scherrer','Absorption':[0.0,False], 48 'DisplaceX':[0.0,False],'DisplaceY':[0.0,False],'Diffuse':[], 49 'Temperature':300.,'Pressure':1.0,'Humidity':0.0, 50 'Voltage':0.0,'Force':0.0,'Gonio. radius':200.0, 51 'Omega':0.0,'Chi':0.0,'Phi':0.0} 46 52 47 53 def UpdatePeakGrid(self, data): -
trunk/GSASIIstruct.py
r395 r397 2285 2285 Ftol = Controls['min dM/M'] 2286 2286 Factor = Controls['shift factor'] 2287 try: 2288 if Controls['deriv type'] == 'analytic': 2289 result = so.leastsq(errRefine,values,Dfun=dervRefine,full_output=True, 2290 ftol=Ftol,col_deriv=True,factor=Factor, 2291 args=([Histograms,Phases],parmDict,varyList,calcControls,pawleyLookup,dlg)) 2292 ncyc = int(result[2]['nfev']/2) 2293 else: #'numeric' 2294 result = so.leastsq(errRefine,values,full_output=True,ftol=Ftol,epsfcn=1.e-8,factor=Factor, 2295 args=([Histograms,Phases],parmDict,varyList,calcControls,pawleyLookup,dlg)) 2296 ncyc = int(result[2]['nfev']/len(varyList)) 2297 # table = dict(zip(varyList,zip(values,result[0],(result[0]-values)))) 2298 # for item in table: print item,table[item] #useful debug - are things shifting? 2299 except Exception: 2300 result = [parmDict['saved values'],None] 2287 if Controls['deriv type'] == 'analytic': 2288 result = so.leastsq(errRefine,values,Dfun=dervRefine,full_output=True, 2289 ftol=Ftol,col_deriv=True,factor=Factor, 2290 args=([Histograms,Phases],parmDict,varyList,calcControls,pawleyLookup,dlg)) 2291 ncyc = int(result[2]['nfev']/2) 2292 else: #'numeric' 2293 result = so.leastsq(errRefine,values,full_output=True,ftol=Ftol,epsfcn=1.e-8,factor=Factor, 2294 args=([Histograms,Phases],parmDict,varyList,calcControls,pawleyLookup,dlg)) 2295 ncyc = int(result[2]['nfev']/len(varyList)) 2296 # table = dict(zip(varyList,zip(values,result[0],(result[0]-values)))) 2297 # for item in table: print item,table[item] #useful debug - are things shifting? 2301 2298 runtime = time.time()-begin 2302 2299 chisq = np.sum(result[2]['fvec']**2)
Note: See TracChangeset
for help on using the changeset viewer.