Changeset 5309


Ignore:
Timestamp:
Jul 11, 2022 10:21:17 AM (3 years ago)
Author:
vondreele
Message:

Add EFtable to list of returned items from G2strIO.GetPhaseData? every where - I had missed a few adding SEC data type
A little progress on Cluster Analysis

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified trunk/GSASIIIO.py

    r5253 r5309  
    14771477        self.parmDict.update(rbDict)
    14781478        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)
    14811481        self.parmDict.update(phaseDict)
    14821482        hapVary,hapDict,controlDict =  G2stIO.GetHistogramPhaseData(Phases,Histograms,Print=False,resetRefList=False)
     
    15141514        rbIds = rigidbodyDict.get('RBIds',{'Vector':[],'Residue':[]})
    15151515        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 constraints
     1516        Natoms,atomIndx,phaseVary,phaseDict,pawleyLookup,FFtables,EFtables,BLtables,MFtables,maxSSwave = \
     1517            G2stIO.GetPhaseData(Phases,RestraintDict=None,rbIds=rbIds,Print=False) # generates atom symmetry constraints
    15181518        msg = G2mv.EvaluateMultipliers(constrDict,phaseDict)
    15191519        if msg:
  • TabularUnified trunk/GSASIIconstrGUI.py

    r5305 r5309  
    389389    rbVary, rbDict = G2stIO.GetRigidBodyModels(rigidbodyDict, Print=False)
    390390    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
    394393    parmDict.update(phaseDict)
    395394    # get Hist and HAP info
     
    15791578    # create a list of the phase variables
    15801579    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)
    15841582    phaseList = []
    15851583    for item in phaseDict:
  • TabularUnified trunk/GSASIIdataGUI.py

    r5307 r5309  
    50785078        '''Returns a dict with defined phases.
    50795079        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.
    50815081        '''
    50825082        phaseData = {}
     
    52765276        rbVary,rbDict = G2stIO.GetRigidBodyModels(rigidbodyDict,Print=False)
    52775277        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)       
    52795280        hapVary,hapDict,controlDict = G2stIO.GetHistogramPhaseData(Phases,histDict,Print=False,resetRefList=False)
    52805281        histVary,histDict,controlDict = G2stIO.GetHistogramData(histDict,Print=False)
     
    56985699        ClusterData = Controls.get('Cluster Data',{'Files':[]})
    56995700        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')
    57015702            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)
    57025731         
    57035732        #fill cluster analysis data matrix here
     
    71167145        data['newLeBail'] = False
    71177146    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':[]}
    71197148   
    71207149    #end patch
     
    72057234       
    72067235        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 '])
    72087253            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')
    72107255                return
    72117256            sel = []
     
    72167261                sel = []
    72177262            dlg = G2G.G2MultiChoiceDialog(G2frame,
    7218                 'Select datasets to include.',
     7263                'Select datasets to include.\n PWDR or PDF',
    72197264                'Cluster analysis data selection',choices)
    72207265            dlg.SetSelections(sel)
    72217266            names = []
     7267            Type = ''
    72227268            if dlg.ShowModal() == wx.ID_OK:
    72237269                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
    72247275                    names.append(choices[sel])
    7225                 data['Cluster Data']['Files'] = names               
     7276                ClusData['Files'] = names
     7277                limits = GetCaLimits(names)
     7278                ClusData['Limits'] = [limits,limits]
     7279               
    72267280            dlg.Destroy()
    72277281            G2frame.SetTitleByGPX()
     7282
    72287283           
    72297284            wx.CallAfter(UpdateControls,G2frame,data)
    72307285           
    72317286        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?',
    72337288                wx.YES_NO | wx.ICON_QUESTION)
    72347289            try:
     
    72417296            ClusData['DataMatrix'] = None
    72427297           
     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               
    72437303        clusSizer = wx.BoxSizer(wx.VERTICAL)
    72447304        dataSizer = wx.BoxSizer(wx.HORIZONTAL)
    72457305        ClusData = data['Cluster Data']
     7306        Type = 'PWDR'
    72467307        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)
    72487311        else:
    72497312            lbl = 'No data selected for Cluster Analysis'
     
    72537316        dataSizer.Add(selSeqData,0,WACV)
    72547317        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']
    72577323            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)
    72597325            method = wx.ComboBox(parent=G2frame.dataWindow,choices=choice,style=wx.CB_READONLY|wx.CB_DROPDOWN)
    72607326            method.SetValue(ClusData['Method'])
     
    72627328            methsizer.Add(method,0,WACV)
    72637329            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)
    72647338        return clusSizer
    72657339       
  • TabularUnified trunk/GSASIIpwd.py

    r5308 r5309  
    26452645    return YI,WYI
    26462646
     2647#### Cluster Analysis routines ###################################################################
     2648
     2649
    26472650#### RMCutilities ################################################################################
    26482651def MakeInst(PWDdata,Name,Size,Mustrain,useSamBrd):
  • TabularUnified trunk/GSASIIstrIO.py

    r5307 r5309  
    11521152       held due to symmetry are placed in this list
    11531153    :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).
    11551155    '''
    11561156           
  • TabularUnified trunk/GSASIIstrMain.py

    r5307 r5309  
    556556    rbIds = rigidbodyDict.get('RBIds',{'Vector':[],'Residue':[]})
    557557    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,
    559559         maxSSwave) = G2stIO.GetPhaseData(Phases,restraintDict,rbIds,Print=False)
    560560    calcControls['atomIndx'] = atomIndx
    561561    calcControls['Natoms'] = Natoms
    562562    calcControls['FFtables'] = FFtables
     563    calcControls['EFtables'] = EFtables
    563564    calcControls['BLtables'] = BLtables
    564565    calcControls['MFtables'] = MFtables
     
    657658    rbVary,rbDict = G2stIO.GetRigidBodyModels(rigidbodyDict,pFile=printFile)
    658659    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')
    663662    for item in phaseVary:
    664663        if '::A0' in item:
     
    688687        G2fil.G2Print('\nRefining with '+str(histogram))
    689688        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)
    694691        ifPrint = False
    695692        if dlg:
     
    699696        calcControls['Natoms'] = Natoms
    700697        calcControls['FFtables'] = FFtables
     698        calcControls['ELtables'] = ELtables
    701699        calcControls['BLtables'] = BLtables
    702700        calcControls['MFtables'] = MFtables
Note: See TracChangeset for help on using the changeset viewer.