Changeset 3255


Ignore:
Timestamp:
Feb 2, 2018 11:46:30 PM (5 years ago)
Author:
toby
Message:

add code to update phase parms from sequential fit

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIdataGUI.py

    r3254 r3255  
    47394739        self.PrefillDataMenu(self.SequentialMenu)
    47404740        self.SequentialFile = wx.Menu(title='')
    4741         self.SequentialMenu.Append(menu=self.SequentialFile, title='Columns')
    4742         self.SequentialFile.Append(G2G.wxID_SELECTUSE,'Select used''Select rows to be used in plots/equation fitting')
    4743         self.SequentialFile.Append(G2G.wxID_RENAMESEQSEL,'Rename selected',
     4741        self.SequentialMenu.Append(menu=self.SequentialFile, title='Columns/Rows')
     4742        self.SequentialFile.Append(G2G.wxID_SELECTUSE,'Set used...',
     4743            'Dialog to select rows for plots/equation fitting')
     4744        G2G.Define_wxId('wxID_UPDATESEQSEL')
     4745        self.SequentialFile.Append(G2G.wxID_UPDATESEQSEL,'Update phase from selected',
     4746            'Update phase information from selected row')
     4747        self.SequentialFile.AppendSeparator()
     4748        self.SequentialFile.Append(G2G.wxID_PLOTSEQSEL,'Plot selected cols',
     4749            'Plot selected sequential refinement columns')
     4750        self.SequentialFile.Append(G2G.wxID_RENAMESEQSEL,'Rename selected cols',
    47444751            'Rename selected sequential refinement columns')
    47454752        self.SequentialFile.Append(G2G.wxID_SAVESEQSEL,'Save selected as text',
    47464753            'Save selected sequential refinement results as a text file')
     4754        self.SequentialFile.Append(G2G.wxID_SAVESEQSELCSV,'Save selected as CSV',
     4755            'Save selected sequential refinement columns as a CSV spreadsheet file')
     4756        self.SequentialFile.Append(G2G.wxID_AVESEQSEL,'Compute average',
     4757            'Compute average for selected parameter')           
     4758        self.SequentialFile.Append(G2G.wxID_ORGSEQINC,'Hide columns...',
     4759            'Select columns to remove from displayed table')
     4760        self.SequentialFile.AppendSeparator()       
    47474761        self.SequentialFile.Append(G2G.wxID_SAVESEQCSV,'Save all as CSV',
    47484762            'Save all sequential refinement results as a CSV spreadsheet file')
    4749         self.SequentialFile.Append(G2G.wxID_SAVESEQSELCSV,'Save selected as CSV',
    4750             'Save selected sequential refinement results as a CSV spreadsheet file')
    4751         self.SequentialFile.Append(G2G.wxID_PLOTSEQSEL,'Plot selected',
    4752             'Plot selected sequential refinement results')
    4753         self.SequentialFile.Append(G2G.wxID_AVESEQSEL,'Compute average','Compute average for selected parameter')           
    47544763#        self.SequentialFile.Append(id=G2G.wxID_ORGSEQSEL, kind=wx.ITEM_NORMAL,text='Reorganize',
    47554764#            help='Reorganize variables where variables change')
    4756         self.SequentialFile.Append(G2G.wxID_ORGSEQINC,'Hide columns...','Select columns to remove from displayed table')
    47574765        self.SequentialPvars = wx.Menu(title='')
    47584766        self.SequentialMenu.Append(menu=self.SequentialPvars, title='Pseudo Vars')
     
    47954803                    item = submenu.Append(wx.ID_ANY,obj.formatName,obj.longFormatName)
    47964804                    self.SeqExportLookup[item.GetId()] = (obj,lbl) # lookup table for submenu item
     4805                    # Bind is in UpdateSeqResults
    47974806       
    47984807        self.PostfillDataMenu()
     
    64346443#        print (r,val)
    64356444        G2frame.SeqTable.SetValue(r,0, val)
     6445
     6446    def OnSelectUpdate(event):
     6447        '''Update all phase parameters from a selected column in the Sequential Table.
     6448        If no histogram is selected (or more than one), ask the user to make a selection.
     6449
     6450        Loosely based on :func:`GSASIIstrIO.SetPhaseData`
     6451        '''
     6452        rows = G2frame.dataDisplay.GetSelectedRows()
     6453        if len(rows) == 1:
     6454            sel = rows[0]
     6455        else:
     6456            dlg = G2G.G2SingleChoiceDialog(G2frame, 'Select histogram to use for update',
     6457                                           'Select row',histNames)
     6458            if dlg.ShowModal() == wx.ID_OK:
     6459                sel = dlg.GetSelection()
     6460                dlg.Destroy()
     6461            else:
     6462                dlg.Destroy()
     6463                return
     6464        parmDict = data[histNames[sel]]['parmDict']
     6465        Histograms,Phases = G2frame.GetUsedHistogramsAndPhasesfromTree()
     6466        for Phase in Phases:
     6467            General = Phase['General']
     6468            SGData = General['SGData']
     6469            Atoms = Phase['Atoms']
     6470            cell = General['Cell']
     6471            pId = Phase['pId']
     6472            pfx = str(pId)+'::'
     6473            if cell[0]:
     6474                A,sigA = G2stIO.cellFill(pfx,SGData,parmDict,{})
     6475                cell[1:7] = G2lat.A2cell(A)
     6476                cell[7] = G2lat.calc_V(A)
     6477            textureData = General['SH Texture']   
     6478            if textureData['Order']:
     6479                SHtextureSig = {}
     6480                for name in ['omega','chi','phi']:
     6481                    aname = pfx+'SH '+name
     6482                    textureData['Sample '+name][1] = parmDict[aname]
     6483                for name in textureData['SH Coeff'][1]:
     6484                    aname = pfx+name
     6485                    textureData['SH Coeff'][1][name] = parmDict[aname]
     6486            ik = 6  #for Pawley stuff below
     6487            if General.get('Modulated',False):
     6488                ik = 7
     6489            # how are these updated?
     6490            #General['SuperVec']
     6491            #RBModels = Phase['RBModels']
     6492            if Phase['General'].get('doPawley'):
     6493                pawleyRef = Phase['Pawley ref']
     6494                for i,refl in enumerate(pawleyRef):
     6495                    key = pfx+'PWLref:'+str(i)
     6496                    refl[ik] = parmDict[key]
     6497                    if key in sigDict:
     6498                        refl[ik+1] = sigDict[key]
     6499                    else:
     6500                        refl[ik+1] = 0
     6501                continue
     6502            General['Mass'] = 0.
     6503            cx,ct,cs,cia = General['AtomPtrs']
     6504            for i,at in enumerate(Atoms):
     6505                names = {cx:pfx+'Ax:'+str(i),cx+1:pfx+'Ay:'+str(i),cx+2:pfx+'Az:'+str(i),cx+3:pfx+'Afrac:'+str(i),
     6506                    cia+1:pfx+'AUiso:'+str(i),cia+2:pfx+'AU11:'+str(i),cia+3:pfx+'AU22:'+str(i),cia+4:pfx+'AU33:'+str(i),
     6507                    cia+5:pfx+'AU12:'+str(i),cia+6:pfx+'AU13:'+str(i),cia+7:pfx+'AU23:'+str(i),
     6508                    cx+4:pfx+'AMx:'+str(i),cx+5:pfx+'AMy:'+str(i),cx+6:pfx+'AMz:'+str(i)}
     6509                for ind in range(cx,cx+4):
     6510                    at[ind] = parmDict[names[ind]]
     6511                if at[cia] == 'I':
     6512                    at[cia+1] = parmDict[names[cia+1]]
     6513                else:
     6514                    for ind in range(cia+2,cia+8):
     6515                        at[ind] = parmDict[names[ind]]
     6516                if General['Type'] == 'magnetic':
     6517                    for ind in range(cx+4,cx+7):
     6518                        at[ind] = parmDict[names[ind]]
     6519                ind = General['AtomTypes'].index(at[ct])
     6520                General['Mass'] += General['AtomMass'][ind]*at[cx+3]*at[cx+5]
     6521                if General.get('Modulated',False):
     6522                    AtomSS = at[-1]['SS1']
     6523                    waveType = AtomSS['waveType']
     6524                    for Stype in ['Sfrac','Spos','Sadp','Smag']:
     6525                        Waves = AtomSS[Stype]
     6526                        for iw,wave in enumerate(Waves):
     6527                            stiw = str(i)+':'+str(iw)
     6528                            if Stype == 'Spos':
     6529                                if waveType in ['ZigZag','Block',] and not iw:
     6530                                    names = ['Tmin:'+stiw,'Tmax:'+stiw,'Xmax:'+stiw,'Ymax:'+stiw,'Zmax:'+stiw]
     6531                                else:
     6532                                    names = ['Xsin:'+stiw,'Ysin:'+stiw,'Zsin:'+stiw,
     6533                                        'Xcos:'+stiw,'Ycos:'+stiw,'Zcos:'+stiw]
     6534                            elif Stype == 'Sadp':
     6535                                names = ['U11sin:'+stiw,'U22sin:'+stiw,'U33sin:'+stiw,
     6536                                    'U12sin:'+stiw,'U13sin:'+stiw,'U23sin:'+stiw,
     6537                                    'U11cos:'+stiw,'U22cos:'+stiw,'U33cos:'+stiw,
     6538                                    'U12cos:'+stiw,'U13cos:'+stiw,'U23cos:'+stiw]
     6539                            elif Stype == 'Sfrac':
     6540                                if 'Crenel' in waveType and not iw:
     6541                                    names = ['Fzero:'+stiw,'Fwid:'+stiw]
     6542                                else:
     6543                                    names = ['Fsin:'+stiw,'Fcos:'+stiw]
     6544                            elif Stype == 'Smag':
     6545                                names = ['MXsin:'+stiw,'MYsin:'+stiw,'MZsin:'+stiw,
     6546                                    'MXcos:'+stiw,'MYcos:'+stiw,'MZcos:'+stiw]
     6547                            for iname,name in enumerate(names):
     6548                                AtomSS[Stype][iw][0][iname] = parmDict[pfx+name]
    64366549   
    64376550    # lookup table for unique cell parameters by symmetry
     
    65336646    G2frame.Bind(wx.EVT_MENU, OnAveSelSeq, id=G2G.wxID_AVESEQSEL)
    65346647    #G2frame.Bind(wx.EVT_MENU, OnReOrgSelSeq, id=G2G.wxID_ORGSEQSEL)
     6648    G2frame.Bind(wx.EVT_MENU, OnSelectUpdate, id=G2G.wxID_UPDATESEQSEL)
    65356649    G2frame.Bind(wx.EVT_MENU, onSelectSeqVars, id=G2G.wxID_ORGSEQINC)
    65366650    G2frame.Bind(wx.EVT_MENU, AddNewPseudoVar, id=G2G.wxID_ADDSEQVAR)
  • trunk/GSASIIstrIO.py

    r3163 r3255  
    15961596   
    15971597def SetPhaseData(parmDict,sigDict,Phases,RBIds,covData,RestraintDict=None,pFile=None):
    1598     'needs a doc string'
     1598    '''Called after a refinement to transfer parameters from the parameter dict to
     1599    the phase(s) information read from a GPX file. Also prints values to the .lst file
     1600    '''
    15991601   
    16001602    def PrintAtomsAndSig(General,Atoms,atomsSig):
     
    18851887            iFin = min(iBeg+10,nCoeff)
    18861888           
     1889    ##########################################################################
     1890    # SetPhaseData starts here
    18871891    pFile.write('\n Phases:\n')
    18881892    for phase in Phases:
Note: See TracChangeset for help on using the changeset viewer.