Changeset 5309
- Timestamp:
- Jul 11, 2022 10:21:17 AM (3 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified trunk/GSASIIIO.py ¶
r5253 r5309 1477 1477 self.parmDict.update(rbDict) 1478 1478 rbIds = rigidbodyDict.get('RBIds',{'Vector':[],'Residue':[]}) 1479 Natoms,atomIndx,phaseVary,phaseDict,pawleyLookup,FFtables, BLtables,MFtables,maxSSwave = G2stIO.GetPhaseData(1480 Phases,RestraintDict=None,rbIds=rbIds,Print=False)1479 Natoms,atomIndx,phaseVary,phaseDict,pawleyLookup,FFtables,EFtables,BLtables,MFtables,maxSSwave = \ 1480 G2stIO.GetPhaseData(Phases,RestraintDict=None,rbIds=rbIds,Print=False) 1481 1481 self.parmDict.update(phaseDict) 1482 1482 hapVary,hapDict,controlDict = G2stIO.GetHistogramPhaseData(Phases,Histograms,Print=False,resetRefList=False) … … 1514 1514 rbIds = rigidbodyDict.get('RBIds',{'Vector':[],'Residue':[]}) 1515 1515 rbVary,rbDict = G2stIO.GetRigidBodyModels(rigidbodyDict,Print=False) # done twice, needed? 1516 Natoms,atomIndx,phaseVary,phaseDict,pawleyLookup,FFtables, BLtables,MFtables,maxSSwave = G2stIO.GetPhaseData(1517 Phases,RestraintDict=None,rbIds=rbIds,Print=False) # generates atom symmetry constraints1516 Natoms,atomIndx,phaseVary,phaseDict,pawleyLookup,FFtables,EFtables,BLtables,MFtables,maxSSwave = \ 1517 G2stIO.GetPhaseData(Phases,RestraintDict=None,rbIds=rbIds,Print=False) # generates atom symmetry constraints 1518 1518 msg = G2mv.EvaluateMultipliers(constrDict,phaseDict) 1519 1519 if msg: -
TabularUnified trunk/GSASIIconstrGUI.py ¶
r5305 r5309 389 389 rbVary, rbDict = G2stIO.GetRigidBodyModels(rigidbodyDict, Print=False) 390 390 parmDict.update(rbDict) 391 (Natoms, atomIndx, phaseVary, phaseDict, pawleyLookup, FFtables, 392 BLtables, MFtables, maxSSwave) = G2stIO.GetPhaseData( 393 Phases, RestraintDict=None, rbIds=rbIds, Print=False) # generates atom symmetry constraints 391 (Natoms,atomIndx,phaseVary,phaseDict,pawleyLookup,FFtables,EFtables,BLtables,MFtables,maxSSwave) = \ 392 G2stIO.GetPhaseData(Phases,RestraintDict=None,rbIds=rbIds,Print=False) # generates atom symmetry constraints 394 393 parmDict.update(phaseDict) 395 394 # get Hist and HAP info … … 1579 1578 # create a list of the phase variables 1580 1579 symHolds = [] 1581 (Natoms,atomIndx,phaseVary,phaseDict,pawleyLookup,FFtable,BLtable, 1582 MFtable,maxSSwave) = G2stIO.GetPhaseData( 1583 Phases,rbIds=rbIds,Print=False,symHold=symHolds) 1580 (Natoms,atomIndx,phaseVary,phaseDict,pawleyLookup,FFtable,EFtable,BLtable,MFtable,maxSSwave) = \ 1581 G2stIO.GetPhaseData(Phases,rbIds=rbIds,Print=False,symHold=symHolds) 1584 1582 phaseList = [] 1585 1583 for item in phaseDict: -
TabularUnified trunk/GSASIIdataGUI.py ¶
r5307 r5309 5078 5078 '''Returns a dict with defined phases. 5079 5079 Note routine :func:`GSASIIstrIO.GetPhaseData` also exists to 5080 get same info from GPX file.5080 get same kind of info from GPX file & put in a list of 9 items. 5081 5081 ''' 5082 5082 phaseData = {} … … 5276 5276 rbVary,rbDict = G2stIO.GetRigidBodyModels(rigidbodyDict,Print=False) 5277 5277 rbIds = rigidbodyDict.get('RBIds',{'Vector':[],'Residue':[]}) 5278 Natoms,atomIndx,phaseVary,phaseDict,pawleyLookup,FFtable,BLtable,MFtable,maxSSwave = G2stIO.GetPhaseData(Phases,RestraintDict=None,rbIds=rbIds,Print=False) 5278 Natoms,atomIndx,phaseVary,phaseDict,pawleyLookup,FFtable,EFtable,BLtable,MFtable,maxSSwave = \ 5279 G2stIO.GetPhaseData(Phases,RestraintDict=None,rbIds=rbIds,Print=False) 5279 5280 hapVary,hapDict,controlDict = G2stIO.GetHistogramPhaseData(Phases,histDict,Print=False,resetRefList=False) 5280 5281 histVary,histDict,controlDict = G2stIO.GetHistogramData(histDict,Print=False) … … 5698 5699 ClusterData = Controls.get('Cluster Data',{'Files':[]}) 5699 5700 if not len(ClusterData['Files']): 5700 G2G.G2MessageBox(self,'No PWDR data selected for Cluster Analysis','No Cluster Analysis')5701 G2G.G2MessageBox(self,'No PWDR or PDF data selected for Cluster Analysis','No Cluster Analysis') 5701 5702 return 5703 5704 Limits = ClusterData['Limits'][1] 5705 Start = True 5706 nFiles = len(ClusterData['Files']) 5707 try: 5708 for iname,name in enumerate(ClusterData['Files']): 5709 item = GetGPXtreeItemId(self,self.root,name) 5710 if 'PWDR' in name: 5711 x = self.GPXtree.GetItemPyData(item)[1][0] 5712 y = self.GPXtree.GetItemPyData(item)[1][1] 5713 else: 5714 PDFControls = self.GPXtree.GetItemPyData(GetGPXtreeItemId(self, item,'PDF Controls')) 5715 x = PDFControls['G(R)'][1][0] 5716 y = PDFControls['G(R)'][1][1] 5717 iBeg = np.searchsorted(x,Limits[0]) 5718 iFin = np.searchsorted(x,Limits[1]) 5719 if Start: 5720 CAmatrix = np.empty((nFiles,iFin-iBeg+1)) 5721 CAmatrix[iname] = y[iBeg:iFin+1] 5722 Start = False 5723 else: 5724 CAmatrix[iname] = y[iBeg:iFin+1] 5725 except ValueError: 5726 G2G.G2MessageBox(self,'Data arrays are mismatched in length \n or have different step sizes', 5727 'No Cluster Analysis possible') 5728 return 5729 5730 print(CAmatrix.shape) 5702 5731 5703 5732 #fill cluster analysis data matrix here … … 7116 7145 data['newLeBail'] = False 7117 7146 if 'Cluster Data' not in data: 7118 data['Cluster Data'] = {'Files':[],'DataMatrix':None,'Method':' Distances'}7147 data['Cluster Data'] = {'Files':[],'DataMatrix':None,'Method':'euclidean','Limits':[]} 7119 7148 7120 7149 #end patch … … 7205 7234 7206 7235 def OnSelectData(event): 7207 choices = GetGPXtreeDataNames(G2frame,['PWDR',]) 7236 7237 def GetCaLimits(names): 7238 ''' scan through data selected for cluster analysis to find highest lower & lowest upper limits 7239 param: data dict: Cluster analysis info 7240 ''' 7241 limits = [0.,1000.0] 7242 for name in names: 7243 item = GetGPXtreeItemId(G2frame,G2frame.root,name) 7244 if 'PWDR' in name: 7245 x = G2frame.GPXtree.GetItemPyData(item)[1][0] 7246 else: 7247 PDFControls = G2frame.GPXtree.GetItemPyData(GetGPXtreeItemId(G2frame, item,'PDF Controls')) 7248 x = PDFControls['G(R)'][1][0] 7249 limits = [max(np.min(x),limits[0]),min(np.max(x),limits[1])] 7250 return limits 7251 7252 choices = GetGPXtreeDataNames(G2frame,['PWDR','PDF ']) 7208 7253 if len(choices) == 0: 7209 G2G.G2MessageBox(G2frame,'No PWDR histograms found for cluster analysis.','No Histograms')7254 G2G.G2MessageBox(G2frame,'No PWDR or PDF histograms found for cluster analysis.','No Histograms') 7210 7255 return 7211 7256 sel = [] … … 7216 7261 sel = [] 7217 7262 dlg = G2G.G2MultiChoiceDialog(G2frame, 7218 'Select datasets to include. ',7263 'Select datasets to include.\n PWDR or PDF', 7219 7264 'Cluster analysis data selection',choices) 7220 7265 dlg.SetSelections(sel) 7221 7266 names = [] 7267 Type = '' 7222 7268 if dlg.ShowModal() == wx.ID_OK: 7223 7269 for sel in dlg.GetSelections(): 7270 if not Type: 7271 Type = choices[sel].split()[0] 7272 if Type != choices[sel].split()[0]: 7273 G2G.G2MessageBox(G2frame,'Histogram types not all the same; revise selection','Histogram type mismatch') 7274 return 7224 7275 names.append(choices[sel]) 7225 data['Cluster Data']['Files'] = names 7276 ClusData['Files'] = names 7277 limits = GetCaLimits(names) 7278 ClusData['Limits'] = [limits,limits] 7279 7226 7280 dlg.Destroy() 7227 7281 G2frame.SetTitleByGPX() 7282 7228 7283 7229 7284 wx.CallAfter(UpdateControls,G2frame,data) 7230 7285 7231 7286 def OnClusterMethod(event): 7232 dlg = wx.MessageDialog(G2frame,'Do you really want to clear the cluster data?','Clear cluster data matrix ',7287 dlg = wx.MessageDialog(G2frame,'Do you really want to clear the cluster data?','Clear cluster data matrix?', 7233 7288 wx.YES_NO | wx.ICON_QUESTION) 7234 7289 try: … … 7241 7296 ClusData['DataMatrix'] = None 7242 7297 7298 def CheckLimits(invalid,value,tc): 7299 if ClusData['Limits'][1][1] < ClusData['Limits'][1][0]: 7300 ClusData['Limits'][1] = [ClusData['Limits'][1][1],ClusData['Limits'][1][0]] 7301 wx.CallAfter(UpdateControls,G2frame,data) 7302 7243 7303 clusSizer = wx.BoxSizer(wx.VERTICAL) 7244 7304 dataSizer = wx.BoxSizer(wx.HORIZONTAL) 7245 7305 ClusData = data['Cluster Data'] 7306 Type = 'PWDR' 7246 7307 if len(ClusData['Files']): 7247 lbl = 'Cluster Analysis with '+str(len(ClusData['Files']))+' datasets' 7308 if 'PDF' in ClusData['Files'][0]: 7309 Type = 'PDF' 7310 lbl = 'Cluster Analysis with %d %s datasets: '%(len(ClusData['Files']),Type) 7248 7311 else: 7249 7312 lbl = 'No data selected for Cluster Analysis' … … 7253 7316 dataSizer.Add(selSeqData,0,WACV) 7254 7317 clusSizer.Add(dataSizer) 7255 if len(ClusData['Files']): 7256 choice = ['Correlation Coeffs.','Distances','Angles',] 7318 if len(ClusData['Files']): 7319 choice = ['braycurtis', 'canberra', 'chebyshev', 'cityblock', 'correlation', 'cosine', \ 7320 'dice', 'euclidean', 'hamming', 'jaccard', 'jensenshannon', 'kulsinski', \ 7321 'kulczynski1', 'mahalanobis', 'matching', 'minkowski', 'rogerstanimoto', \ 7322 'russellrao', 'seuclidean', 'sokalmichener', 'sokalsneath', 'sqeuclidean', 'yule'] 7257 7323 methsizer = wx.BoxSizer(wx.HORIZONTAL) 7258 methsizer.Add(wx.StaticText(G2frame.dataWindow,label='Select cluster analysis data method '),0,WACV)7324 methsizer.Add(wx.StaticText(G2frame.dataWindow,label='Select cluster analysis data method: '),0,WACV) 7259 7325 method = wx.ComboBox(parent=G2frame.dataWindow,choices=choice,style=wx.CB_READONLY|wx.CB_DROPDOWN) 7260 7326 method.SetValue(ClusData['Method']) … … 7262 7328 methsizer.Add(method,0,WACV) 7263 7329 clusSizer.Add(methsizer) 7330 limitSizer = wx.BoxSizer(wx.HORIZONTAL) 7331 limitSizer.Add(wx.StaticText(G2frame.dataWindow,label='Enter cluster analysis data limits: '),0,WACV) 7332 limitSizer.Add(G2G.ValidatedTxtCtrl(G2frame.dataWindow,ClusData['Limits'][1],0,nDig=(10,3), 7333 xmin=ClusData['Limits'][0][0],xmax=ClusData['Limits'][0][1],OnLeave=CheckLimits),0,WACV) 7334 limitSizer.Add(G2G.ValidatedTxtCtrl(G2frame.dataWindow,ClusData['Limits'][1],1,nDig=(10,3), 7335 xmin=ClusData['Limits'][0][0],xmax=ClusData['Limits'][0][1],OnLeave=CheckLimits),0,WACV) 7336 clusSizer.Add(limitSizer) 7337 clusSizer.Add(wx.StaticText(G2frame.dataWindow,label='(Examine any %s plot for reasonable limits) '%Type),0,WACV) 7264 7338 return clusSizer 7265 7339 -
TabularUnified trunk/GSASIIpwd.py ¶
r5308 r5309 2645 2645 return YI,WYI 2646 2646 2647 #### Cluster Analysis routines ################################################################### 2648 2649 2647 2650 #### RMCutilities ################################################################################ 2648 2651 def MakeInst(PWDdata,Name,Size,Mustrain,useSamBrd): -
TabularUnified trunk/GSASIIstrIO.py ¶
r5307 r5309 1152 1152 held due to symmetry are placed in this list 1153 1153 :returns: lots of stuff: Natoms,atomIndx,phaseVary,phaseDict,pawleyLookup, 1154 FFtables, BLtables,MFtables,maxSSwave (see code for details).1154 FFtables,EFtables,BLtables,MFtables,maxSSwave (see code for details). 1155 1155 ''' 1156 1156 -
TabularUnified trunk/GSASIIstrMain.py ¶
r5307 r5309 556 556 rbIds = rigidbodyDict.get('RBIds',{'Vector':[],'Residue':[]}) 557 557 rbVary,rbDict = G2stIO.GetRigidBodyModels(rigidbodyDict,Print=False) 558 (Natoms,atomIndx,phaseVary,phaseDict,pawleyLookup,FFtables, BLtables,MFtables,558 (Natoms,atomIndx,phaseVary,phaseDict,pawleyLookup,FFtables,EFtables,BLtables,MFtables, 559 559 maxSSwave) = G2stIO.GetPhaseData(Phases,restraintDict,rbIds,Print=False) 560 560 calcControls['atomIndx'] = atomIndx 561 561 calcControls['Natoms'] = Natoms 562 562 calcControls['FFtables'] = FFtables 563 calcControls['EFtables'] = EFtables 563 564 calcControls['BLtables'] = BLtables 564 565 calcControls['MFtables'] = MFtables … … 657 658 rbVary,rbDict = G2stIO.GetRigidBodyModels(rigidbodyDict,pFile=printFile) 658 659 G2mv.InitVars() 659 (Natoms,atomIndx,phaseVary,phaseDict,pawleyLookup, 660 FFtables,BLtables,MFtables,maxSSwave) = G2stIO.GetPhaseData( 661 Phases,restraintDict,rbIds,Print=False,pFile=printFile, 662 seqHistName='All') 660 (Natoms,atomIndx,phaseVary,phaseDict,pawleyLookup,FFtables,EFtables,BLtables,MFtables,maxSSwave) = \ 661 G2stIO.GetPhaseData(Phases,restraintDict,rbIds,Print=False,pFile=printFile,seqHistName='All') 663 662 for item in phaseVary: 664 663 if '::A0' in item: … … 688 687 G2fil.G2Print('\nRefining with '+str(histogram)) 689 688 G2mv.InitVars() 690 (Natoms,atomIndx,phaseVary,phaseDict,pawleyLookup, 691 FFtables,BLtables,MFtables,maxSSwave) = G2stIO.GetPhaseData( 692 Phases,restraintDict,rbIds,Print=False,pFile=printFile, 693 seqHistName=histogram) 689 (Natoms,atomIndx,phaseVary,phaseDict,pawleyLookup,FFtables,ELtables,BLtables,MFtables,maxSSwave) = \ 690 G2stIO.GetPhaseData(Phases,restraintDict,rbIds,Print=False,pFile=printFile,seqHistName=histogram) 694 691 ifPrint = False 695 692 if dlg: … … 699 696 calcControls['Natoms'] = Natoms 700 697 calcControls['FFtables'] = FFtables 698 calcControls['ELtables'] = ELtables 701 699 calcControls['BLtables'] = BLtables 702 700 calcControls['MFtables'] = MFtables
Note: See TracChangeset
for help on using the changeset viewer.