- Timestamp:
- Sep 16, 2014 4:20:57 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified trunk/GSASII.py ¶
r1492 r1498 1866 1866 self.PatternTree.Bind(wx.EVT_TREE_KEY_DOWN, 1867 1867 self.OnPatternTreeKeyDown, id=wxID_PATTERNTREE) 1868 #Can't get drag/drop of tree items to work except in simple cases (e.g. Controls) 1869 # self.PatternTree.Bind(wx.EVT_TREE_BEGIN_RDRAG, 1870 # self.OnPatternTreeBeginRDrag, id=wxID_PATTERNTREE) 1871 # self.PatternTree.Bind(wx.EVT_TREE_END_DRAG, 1872 # self.OnPatternTreeEndDrag, id=wxID_PATTERNTREE) 1868 1873 self.root = self.PatternTree.AddRoot('Loaded Data: ') 1869 1874 … … 1989 1994 event.Skip() 1990 1995 1996 def OnPatternTreeBeginRDrag(self,event): 1997 # testing this - doesn't work! Binds commented out above 1998 event.Allow() 1999 self.BeginDragId = event.GetItem() 2000 print 'start',self.PatternTree.GetItemText(self.BeginDragId) 2001 self.ParentId = self.PatternTree.GetItemParent(self.BeginDragId) 2002 self.DragData = self.PatternTree.GetItemPyData(self.BeginDragId) 2003 2004 def OnPatternTreeEndDrag(self,event): 2005 # testing this - doesn't work! Binds commented out above 2006 event.Allow() 2007 self.EndDragId = event.GetItem() 2008 if self.ParentId != self.PatternTree.GetItemParent(self.EndDragId): 2009 print 'drag not allowed - wrong parent' 2010 else: 2011 Name = self.PatternTree.GetItemText(self.BeginDragId) 2012 self.PatternTree.InsertItem(self.ParentId,self.EndDragId,Name,data=None) 2013 Id = G2gd.GetPatternTreeItemId(self, self.ParentId,Name) 2014 self.PatternTree.SetItemPyData(Id,self.DragData) 2015 self.PatternTree.Delete(self.BeginDragId) 2016 print 'end',self.PatternTree.GetItemText(self.EndDragId) 2017 1991 2018 def OnPatternTreeKeyDown(self,event): 1992 ' Not sure what this does'2019 'Allows stepping through the tree with the up/down arrow keys' 1993 2020 key = event.GetKeyCode() 1994 2021 item = self.PickId … … 3275 3302 Id = self.PatternTree.AppendItem(self.root,text='Sequential results') 3276 3303 self.PatternTree.SetItemPyData(Id,{}) 3304 Controls = self.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(self,self.root, 'Controls')) 3305 Controls['ShowCell'] = True 3277 3306 self.OnFileSave(event) 3278 3307 # check that constraints are OK here -
TabularUnified trunk/GSASIIgrid.py ¶
r1496 r1498 2921 2921 self.AutoSearch = self.PeakEdit.Append(help='Automatic peak search', 2922 2922 id=wxID_AUTOSEARCH, kind=wx.ITEM_NORMAL,text='Auto search') 2923 self.PeakCopy = self.PeakEdit.Append(help='Copy peaks to other histograms',2924 id=wxID_PEAKSCOPY, kind=wx.ITEM_NORMAL,text='Peak copy')2925 2923 self.UnDo = self.PeakEdit.Append(help='Undo last least squares refinement', 2926 2924 id=wxID_UNDO, kind=wx.ITEM_NORMAL,text='UnDo') … … 2929 2927 self.PFOneCycle = self.PeakEdit.Append(id=wxID_LSQONECYCLE, kind=wx.ITEM_NORMAL,text='Peakfit one cycle', 2930 2928 help='One cycle of Peak fitting' ) 2929 self.PeakEdit.Append(id=wxID_RESETSIGGAM, kind=wx.ITEM_NORMAL, 2930 text='Reset sig and gam',help='Reset sigma and gamma to global fit' ) 2931 self.PeakCopy = self.PeakEdit.Append(help='Copy peaks to other histograms', 2932 id=wxID_PEAKSCOPY, kind=wx.ITEM_NORMAL,text='Peak copy') 2931 2933 self.SeqPeakFit = self.PeakEdit.Append(id=wxID_SEQPEAKFIT, kind=wx.ITEM_NORMAL,text='Seq PeakFit', 2932 2934 help='Sequential Peak fitting for all histograms' ) 2933 wxID_PEAKSCOPY2934 self.PeakEdit.Append(id=wxID_RESETSIGGAM, kind=wx.ITEM_NORMAL,2935 text='Reset sig and gam',help='Reset sigma and gamma to global fit' )2936 2935 self.PeakEdit.Append(id=wxID_CLEARPEAKS, kind=wx.ITEM_NORMAL,text='Clear peaks', 2937 2936 help='Clear the peak list' ) … … 3284 3283 self.TextureEdit = wx.Menu(title='') 3285 3284 self.TextureMenu.Append(menu=self.TextureEdit, title='Texture') 3286 self.TextureEdit.Append(id=wxID_REFINETEXTURE, kind=wx.ITEM_NORMAL,text='Refine texture',3287 help='Refine the texture coefficients from sequential Pawley results')3285 # self.TextureEdit.Append(id=wxID_REFINETEXTURE, kind=wx.ITEM_NORMAL,text='Refine texture', 3286 # help='Refine the texture coefficients from sequential Pawley results') 3288 3287 self.TextureEdit.Append(id=wxID_CLEARTEXTURE, kind=wx.ITEM_NORMAL,text='Clear texture', 3289 3288 help='Clear the texture coefficients' ) … … 4731 4730 Types += [wg.GRID_VALUE_FLOAT+':10,3',] 4732 4731 # add % change in Chi^2 in last cycle 4733 if histNames[0][:4] not in ['SASD','IMG '] :4732 if histNames[0][:4] not in ['SASD','IMG '] and Controls['ShowCell']: 4734 4733 colList += [[100.*data[name]['Rvals'].get('DelChi2',-1) for name in histNames]] 4735 4734 colSigs += [None] … … 4744 4743 Types += [wg.GRID_VALUE_FLOAT,] 4745 4744 # add unique cell parameters 4746 for pId in sorted(RecpCellTerms): 4747 pfx = str(pId)+'::' # prefix for A values from phase 4748 cells = [] 4749 cellESDs = [] 4750 colLabels += [pfx+cellUlbl[i] for i in uniqCellIndx[pId]] 4751 colLabels += [pfx+'Vol'] 4752 Types += (1+len(uniqCellIndx[pId]))*[wg.GRID_VALUE_FLOAT,] 4753 for name in histNames: 4754 covData = { 4755 'varyList': [Dlookup.get(striphist(v),v) for v in data[name]['varyList']], 4756 'covMatrix': data[name]['covMatrix'] 4757 } 4758 A = RecpCellTerms[pId][:] # make copy of starting A values 4759 # update with refined values 4760 for i in range(6): 4761 var = str(pId)+'::A'+str(i) 4762 if var in ESDlookup: 4763 val = data[name]['newCellDict'][ESDlookup[var]][1] # get refined value 4764 A[i] = val # override with updated value 4765 # apply symmetry 4766 Albls = [pfx+'A'+str(i) for i in range(6)] 4767 cellDict = dict(zip(Albls,A)) 4768 A,zeros = G2stIO.cellFill(pfx,SGdata[pId],cellDict,zeroDict[pId]) 4769 # convert to direct cell & add only unique values to table 4770 c = G2lat.A2cell(A) 4771 vol = G2lat.calc_V(A) 4772 cE = G2stIO.getCellEsd(pfx,SGdata[pId],A,covData) 4773 cells += [[c[i] for i in uniqCellIndx[pId]]+[vol]] 4774 cellESDs += [[cE[i] for i in uniqCellIndx[pId]]+[cE[-1]]] 4775 colList += zip(*cells) 4776 colSigs += zip(*cellESDs) 4745 if Controls['ShowCell']: 4746 for pId in sorted(RecpCellTerms): 4747 pfx = str(pId)+'::' # prefix for A values from phase 4748 cells = [] 4749 cellESDs = [] 4750 colLabels += [pfx+cellUlbl[i] for i in uniqCellIndx[pId]] 4751 colLabels += [pfx+'Vol'] 4752 Types += (1+len(uniqCellIndx[pId]))*[wg.GRID_VALUE_FLOAT,] 4753 for name in histNames: 4754 covData = { 4755 'varyList': [Dlookup.get(striphist(v),v) for v in data[name]['varyList']], 4756 'covMatrix': data[name]['covMatrix'] 4757 } 4758 A = RecpCellTerms[pId][:] # make copy of starting A values 4759 # update with refined values 4760 for i in range(6): 4761 var = str(pId)+'::A'+str(i) 4762 if var in ESDlookup: 4763 val = data[name]['newCellDict'][ESDlookup[var]][1] # get refined value 4764 A[i] = val # override with updated value 4765 # apply symmetry 4766 Albls = [pfx+'A'+str(i) for i in range(6)] 4767 cellDict = dict(zip(Albls,A)) 4768 A,zeros = G2stIO.cellFill(pfx,SGdata[pId],cellDict,zeroDict[pId]) 4769 # convert to direct cell & add only unique values to table 4770 c = G2lat.A2cell(A) 4771 vol = G2lat.calc_V(A) 4772 cE = G2stIO.getCellEsd(pfx,SGdata[pId],A,covData) 4773 cells += [[c[i] for i in uniqCellIndx[pId]]+[vol]] 4774 cellESDs += [[cE[i] for i in uniqCellIndx[pId]]+[cE[-1]]] 4775 colList += zip(*cells) 4776 colSigs += zip(*cellESDs) 4777 4777 # add the variables that were refined; change from rows to columns 4778 4778 colList += zip(*[data[name]['variables'] for name in histNames]) … … 4823 4823 G2mv.InitVars() 4824 4824 parmDict = data[name].get('parmDict') 4825 if parmDict :4825 if parmDict and Controls['ShowCell']: 4826 4826 constraintInfo = data[name].get('constraintInfo',[[],[],{},[],seqnum]) 4827 4827 groups,parmlist,constrDict,fixedList,ihst = constraintInfo … … 5159 5159 data = G2frame.PatternTree.GetItemPyData(item) 5160 5160 UpdateSeqResults(G2frame,data) 5161 elif G2frame.PatternTree.GetItemText(item) == 'Small Angle Sequential results':5162 data = G2frame.PatternTree.GetItemPyData(item)5163 UpdateSASDSeqResults(G2frame,data)5164 5161 elif G2frame.PatternTree.GetItemText(item) == 'Covariance': 5165 5162 data = G2frame.PatternTree.GetItemPyData(item) -
TabularUnified trunk/GSASIIpwdGUI.py ¶
r1496 r1498 407 407 dlg.Destroy() 408 408 SeqResult = {'histNames':names} 409 Reverse = False 410 CopyForward = False 411 choice = ['Copy from prev.',] #'Reverse sequence', 412 dlg = wx.MultiChoiceDialog(G2frame.dataFrame,'Sequential controls','Select controls',choice) 413 if dlg.ShowModal() == wx.ID_OK: 414 for sel in dlg.GetSelections(): 415 if sel: 416 CopyForward = True 417 else: 418 Reverse = True 409 419 dlg.Destroy() 410 420 dlg = wx.ProgressDialog('Sequential peak fit','Data set name = '+names[0],len(names), 411 421 style = wx.PD_ELAPSED_TIME|wx.PD_AUTO_HIDE|wx.PD_REMAINING_TIME|wx.PD_CAN_ABORT) 422 Controls = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,G2frame.root, 'Controls')) 412 423 controls = {'deriv type':'analytic','min dM/M':0.0001,} 424 Controls['ShowCell'] = False 413 425 print 'Peak Fitting with '+controls['deriv type']+' derivatives:' 414 426 oneCycle = False … … 421 433 break 422 434 PatternId = G2gd.GetPatternTreeItemId(G2frame,G2frame.root,name) 435 if i and CopyForward: 436 G2frame.PatternTree.SetItemPyData(G2gd.GetPatternTreeItemId(G2frame,PatternId, 'Peak List'),peaks) 423 437 peaks = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,PatternId, 'Peak List')) 424 438 background = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,PatternId, 'Background')) … … 444 458 print ' ***** Sequential peak fit successful *****' 445 459 finally: 446 wx.EndBusyCursor() 460 wx.EndBusyCursor() 447 461 Id = G2gd.GetPatternTreeItemId(G2frame,G2frame.root,'Sequential results') 448 462 if Id: -
TabularUnified trunk/GSASIIstrMath.py ¶
r1496 r1498 1531 1531 iFin = max(xB,min(np.searchsorted(x,refl[5]+fmax),xF)) 1532 1532 iFin2 = iFin 1533 yp[iBeg:iFin] = refl[11]*refl[9]*G2pwd.getFCJVoigt3(refl[5],refl[6],refl[7],shl,ma.getdata(x[iBeg:iFin])) #>90% of time spent here 1534 if Ka2: 1535 pos2 = refl[5]+lamRatio*tand(refl[5]/2.0) # + 360/pi * Dlam/lam * tan(th) 1536 Wd,fmin,fmax = G2pwd.getWidthsCW(pos2,refl[6],refl[7],shl) 1537 iBeg2 = max(xB,np.searchsorted(x,pos2-fmin)) 1538 iFin2 = min(np.searchsorted(x,pos2+fmax),xF) 1539 if not iBeg2+iFin2: #peak below low limit - skip peak 1540 continue 1541 elif not iBeg2-iFin2: #peak above high limit - done 1542 break 1543 yp[iBeg2:iFin2] += refl[11]*refl[9]*kRatio*G2pwd.getFCJVoigt3(pos2,refl[6],refl[7],shl,ma.getdata(x[iBeg2:iFin2])) #and here 1544 refl[8] = np.sum(np.where(ratio[iBeg:iFin2]>0.,yp[iBeg:iFin2]*ratio[iBeg:iFin2]/(refl[11]*(1.+kRatio)),0.0)) 1533 if not iBeg+iFin: #peak below low limit - skip peak 1534 continue 1535 elif not iBeg-iFin: #peak above high limit - done 1536 break 1537 elif iBeg < iFin: 1538 yp[iBeg:iFin] = refl[11]*refl[9]*G2pwd.getFCJVoigt3(refl[5],refl[6],refl[7],shl,ma.getdata(x[iBeg:iFin])) #>90% of time spent here 1539 if Ka2: 1540 pos2 = refl[5]+lamRatio*tand(refl[5]/2.0) # + 360/pi * Dlam/lam * tan(th) 1541 Wd,fmin,fmax = G2pwd.getWidthsCW(pos2,refl[6],refl[7],shl) 1542 iBeg2 = max(xB,np.searchsorted(x,pos2-fmin)) 1543 iFin2 = min(np.searchsorted(x,pos2+fmax),xF) 1544 yp[iBeg2:iFin2] += refl[11]*refl[9]*kRatio*G2pwd.getFCJVoigt3(pos2,refl[6],refl[7],shl,ma.getdata(x[iBeg2:iFin2])) #and here 1545 refl[8] = np.sum(np.where(ratio[iBeg:iFin2]>0.,yp[iBeg:iFin2]*ratio[iBeg:iFin2]/(refl[11]*(1.+kRatio)),0.0)) 1545 1546 elif 'T' in calcControls[hfx+'histType']: 1546 1547 yp = np.zeros_like(yb)
Note: See TracChangeset
for help on using the changeset viewer.