Changeset 4819


Ignore:
Timestamp:
Feb 17, 2021 12:52:34 PM (8 months ago)
Author:
toby
Message:

seq ref: fix & edit phase vars for 1 hist; spyder conveniences; improve filter; fix bkg copy flags bug

fail

Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIctrlGUI.py

    r4811 r4819  
    183183    pass
    184184
    185 ################################################################################
    186 #### Fixed definitions for wx Ids
    187 ################################################################################
     185#### Fixed definitions for wx Ids ################################################################################
    188186def Define_wxId(*args):
    189187    '''routine to create unique global wx Id symbols in this module.
     
    197195        exec('global '+arg+';'+arg+' = wx.NewId()')
    198196
    199 ################################################################################
    200 #### Tree Control
    201 ################################################################################
     197#### Tree Control ################################################################################
    202198class G2TreeCtrl(wx.TreeCtrl):
    203199    '''Create a wrapper around the standard TreeCtrl so we can "wrap"
     
    415411            item, cookie = self.GetNextChild(self.root, cookie)
    416412
    417 ################################################################################
    418 #### TextCtrl that stores input as entered with optional validation
    419 ################################################################################
     413#### TextCtrl that stores input as entered with optional validation ################################################################################
    420414class ValidatedTxtCtrl(wx.TextCtrl):
    421415    '''Create a TextCtrl widget that uses a validator to prevent the
     
    12751269        if num >= 0: self.SetSelection(num)
    12761270
    1277 ##############################################################
    1278 # Custom checkbox that saves values into dict/list as used
     1271#### Custom checkbox that saves values into dict/list as used ##############################################################
    12791272class G2CheckBox(wx.CheckBox):
    12801273    '''A customized version of a CheckBox that automatically initializes
     
    13081301        if self.OnChange: self.OnChange(event)
    13091302                   
    1310 ################################################################################
    1311 #### Commonly used dialogs
    1312 ################################################################################
     1303#### Commonly used dialogs ################################################################################
    13131304def CallScrolledMultiEditor(parent,dictlst,elemlst,prelbl=[],postlbl=[],
    13141305                 title='Edit items',header='',size=(300,250),
     
    13241315                              title,header,size,
    13251316                              CopyButton, ASCIIonly, **kw)
     1317    dlg.CenterOnParent()
    13261318    if dlg.ShowModal() == wx.ID_OK:
    13271319        dlg.Destroy()
     
    13491341    :param tuple dictlst: a list of dicts or lists containing values to edit
    13501342
    1351     :param tuple elemlst: a list of keys for each item in a dictlst. Must have the
    1352       same length as dictlst.
    1353 
    1354     :param wx.Frame parent: name of parent window, or may be None
    1355    
     1343    :param tuple elemlst: a list of keys/indices for items in dictlst.
     1344      Note that elemlst must have the same length as dictlst, where each
     1345      item in elemlst will will match an entry for an entry for successive
     1346      dicts/lists in dictlst.
     1347
    13561348    :param tuple prelbl: a list of labels placed before the TextCtrl for each
    13571349      item (optional)
     
    15611553###############################################  Multichoice Dialog with set all, toggle & filter options
    15621554class G2MultiChoiceDialog(wx.Dialog):
    1563     '''A dialog similar to MultiChoiceDialog except that buttons are
    1564     added to set all choices and to toggle all choices.
     1555    '''A dialog similar to wx.MultiChoiceDialog except that buttons are
     1556    added to set all choices and to toggle all choices and a filter is
     1557    available to select from available entries. Note that if multiple
     1558    entries are placed in the filter box separated by spaces, all
     1559    of the strings must be present for an item to be shown.
    15651560
    15661561    :param wx.Frame ParentFrame: reference to parent frame
     
    15771572      options to present to the user, where value_i is the default value.
    15781573      Options are listed ordered by the value_i values.
     1574    :param list selected: list of indicies for items that should be
    15791575    :param kw: optional keyword parameters for the wx.Dialog may
    15801576      be included such as size [which defaults to `(320,310)`] and
     
    15851581    '''
    15861582    def __init__(self,parent, title, header, ChoiceList, toggle=True,
    1587                  monoFont=False, filterBox=True, extraOpts={}, **kw):
     1583                 monoFont=False, filterBox=True, extraOpts={}, selected=[],
     1584                 **kw):
    15881585        # process keyword parameters, notably style
    15891586        options = {'size':(320,310), # default Frame keywords
     
    15931590        self.ChoiceList = ['%4d) %s'%(i,item) for i,item in enumerate(ChoiceList)] # numbered list of choices (list of str values)
    15941591        self.Selections = len(self.ChoiceList) * [False,] # selection status for each choice (list of bools)
     1592        for i in selected:
     1593            self.Selections[i] = True
    15951594        self.filterlist = range(len(self.ChoiceList)) # list of the choice numbers that have been filtered (list of int indices)
    15961595        self.Stride = 1
     
    16241623        self.rangeFirst = None
    16251624        self.clb = wx.CheckListBox(self, wx.ID_ANY, (30,30), wx.DefaultSize, self.ChoiceList)
     1625        self._ShowSelections()
    16261626        self.clb.Bind(wx.EVT_CHECKLISTBOX,self.OnCheck)
    16271627        if monoFont:
     
    17951795        self.GetSelections() # record current selections
    17961796        txt = self.filterBox.GetValue()
     1797        txt = txt.lower()
    17971798        self.clb.Clear()
    17981799       
     
    18001801        self.filterlist = []
    18011802        if txt:
    1802             txt = txt.lower()
    18031803            ChoiceList = []
    18041804            for i,item in enumerate(self.ChoiceList):
    1805                 if item.lower().find(txt) != -1:
     1805                for t in txt.split():
     1806                    if item.lower().find(t) == -1:
     1807                        break
     1808                else:
    18061809                    ChoiceList.append(item)
    18071810                    self.filterlist.append(i)
     
    22052208        dlg.Destroy()
    22062209
    2207 ###############################################################
    2208 #        Single choice Dialog with filter options
     2210#####  Single choice Dialog with filter options ###############################################################
    22092211class G2SingleChoiceDialog(wx.Dialog):
    22102212    '''A dialog similar to wx.SingleChoiceDialog except that a filter can be
     
    44484450            return None
    44494451
    4450 ################################################################################
    4451 #####  Customized Grid Support
    4452 ################################################################################           
     4452#####  Customized Grid Support ################################################################################           
    44534453class GSGrid(wg.Grid):
    44544454    '''Basic wx.Grid implementation
     
    47734773            evt.StopPropagation()
    47744774
    4775 ################################################################################
    4776 #####  Get an output file or directory
    4777 ################################################################################           
     4775#####  Get an output file or directory ################################################################################
    47784776def askSaveFile(G2frame,defnam,extension,longFormatName,parent=None):
    47794777    '''Ask the user to supply a file name
     
    48294827    return filename
    48304828
    4831 ################################################################################
    4832 #####  Customized Notebook
    4833 ################################################################################           
     4829#####  Customized Notebook ################################################################################           
    48344830class GSNoteBook(wx.aui.AuiNotebook):
    48354831    '''Notebook used in various locations; implemented with wx.aui extension
     
    48964892    #         return attr
    48974893           
    4898 ################################################################################
    4899 #### Help support routines
    4900 ################################################################################
     4894#### Help support routines ################################################################################
    49014895class MyHelp(wx.Menu):
    49024896    '''
     
    53875381    return s.encode('ascii','replace')
    53885382       
    5389 ######################################################################
    5390 # wx classes for reading various types of data files
    5391 ######################################################################
     5383# wx classes for reading various types of data files ######################################################################
    53925384def BlockSelector(ChoiceList, ParentFrame=None,title='Select a block',
    53935385    size=None, header='Block Selector',useCancel=True):
     
    60015993
    60025994################################################################################
    6003 ################################################################################
    60045995class SortableLstCtrl(wx.Panel):
    60055996    '''Creates a read-only table with sortable columns. Sorting is done by
     
    61196110    print('docs build kludge for G2LstCtrl')
    61206111   
    6121 ################################################################################
    6122 #### Display Help information
    6123 ################################################################################
     6112#### Display Help information ################################################################################
    61246113# define some globals
    61256114htmlPanel = None
     
    62216210            webbrowser.open(pfx+URL, new=0, autoraise=True)
    62226211
    6223 ################################################################################
    6224 #### Tutorials support
    6225 ################################################################################
     6212#### Tutorials support ################################################################################
    62266213G2BaseURL = "https://subversion.xray.aps.anl.gov/pyGSAS"
    62276214tutorialIndex = (
     
    67616748        except KeyError:
    67626749            pass
    6763 ################################################################################
    6764 # Autoload PWDR files
    6765 ################################################################################
     6750
     6751### Autoload PWDR files ################################################################################
    67666752AutoLoadWindow = None
    67676753
     
    71697155    AutoLoadWindow = dlg # save window reference
    71707156
    7171 ################################################################################
    7172 # Deal with Origin 1/2 ambiguities
    7173 ################################################################################
     7157# Deal with Origin 1/2 ambiguities ################################################################################
    71747158def ChooseOrigin(G2frame,rd):   
    71757159    # make copy of Phase but shift atoms Origin 1->2
  • trunk/GSASIIdataGUI.py

    r4809 r4819  
    151151    return None
    152152
    153 ################################################################################
    154 #### class definitions used for main GUI
    155 ################################################################################
    156                
     153#### class definitions used for main GUI ######################################     
    157154class MergeDialog(wx.Dialog):
    158155    ''' HKL transformation & merge dialog
     
    513510              '\nhttps://gsas-ii.readthedocs.io/en/latest/GSASIIGUI.html#GSASIIdataGUI.versionDict')
    514511
    515 ###############################################################################
    516 #### GUI creation
    517 ###############################################################################
     512#### GUI creation #############################################################
    518513def GSASIImain(application):
    519514    '''Start up the GSAS-II GUI'''                       
     
    644639    application.GetTopWindow().Show(True)
    645640
    646 ################################################################################
    647 #### Create main frame (window) for GUI
    648 ################################################################################
     641#### Create main frame (window) for GUI #######################################
    649642class GSASII(wx.Frame):
    650643    '''Define the main GSAS-II frame and its associated menu items.
     
    27252718        data.append('Notebook entry @ %s: %s'%(time.ctime(),text))   
    27262719                   
    2727 ###############################################################################
    2728 #Command logging
    2729 ###############################################################################
    2730 
     2720
     2721### Command logging ###########################################################
    27312722    def OnMacroRecordStatus(self,event,setvalue=None):
    27322723        '''Called when the record macro menu item is used which toggles the
     
    29542945        # self.ExportLookup[item.GetId()] = 'powder'
    29552946
    2956 ###############################################################################
    2957 # Exporters
    2958 ###############################################################################
    2959                            
     2947# Exporters ###################################################################
    29602948    def _Add_ExportMenuItems(self,parent):
    29612949        # item = parent.Append(
     
    31463134                    print('Value for config {} {} is invalid'.format(var,GSASIIpath.GetConfigValue(var)))
    31473135                    win.Center()
    3148 ################################################################################
    3149 #### init_vars
    3150 ################################################################################
     3136                   
     3137#### init_vars ################################################################
    31513138    def init_vars(self):
    31523139        # initialize default values for GSAS-II "global" variables (saved in main Frame)
     
    32403227        self.dataDisplay = None
    32413228        self.init_vars()
    3242                        
     3229       
     3230        if GSASIIpath.GetConfigValue('Starting_directory'):
     3231            try:
     3232                pth = GSASIIpath.GetConfigValue('Starting_directory')
     3233                pth = os.path.expanduser(pth)
     3234                os.chdir(pth)
     3235                self.LastGPXdir = pth
     3236            except:
     3237                print('Ignoring Config Starting_directory value: '+
     3238                      GSASIIpath.GetConfigValue('Starting_directory'))
    32433239        arg = sys.argv
    32443240        if len(arg) > 1 and arg[1]:
     
    32633259                import traceback
    32643260                print (traceback.format_exc())
    3265                
    3266         if GSASIIpath.GetConfigValue('Starting_directory'):
    3267             try:
    3268                 pth = GSASIIpath.GetConfigValue('Starting_directory')
    3269                 pth = os.path.expanduser(pth)
    3270                 os.chdir(pth)
    3271                 self.LastGPXdir = pth
    3272             except:
    3273                 print('Ignoring Config Starting_directory value: '+
    3274                       GSASIIpath.GetConfigValue('Starting_directory'))
    3275 
     3261        elif any('SPYDER' in name for name in os.environ):
     3262            self.OnFileReopen(None)
     3263           
    32763264    def GetTreeItemsList(self,item):
    32773265        return self.GPXtree._getTreeItemsList(item)
     
    54345422        G2IO.SaveMultipleImg(self)
    54355423
    5436 ################################################################################
    5437 # Data window side of main GUI
    5438 ################################################################################
     5424# Data window side of main GUI ################################################
    54395425class G2DataWindow(wx.ScrolledWindow):      #wxscroll.ScrolledPanel):
    54405426    '''Create the data item window as well as the menu. Note that
     
    57305716        self.SequentialFile.Append(G2G.wxID_UPDATESEQSEL,'Update phase from selected',
    57315717            'Update phase information from selected row')
     5718        G2G.Define_wxId('wxID_EDITSEQSELPHASE')
     5719        self.SequentialFile.Append(G2G.wxID_EDITSEQSELPHASE,'Edit phase parameters in selected',
     5720            'Edit phase information from selected row')
    57325721        self.SequentialFile.AppendSeparator()
    57335722        self.SequentialFile.Append(G2G.wxID_PLOTSEQSEL,'Plot selected cols',
     
    64476436    # end of GSAS-II menu definitions
    64486437   
    6449 ################################################################################
    6450 #####  Notebook Tree Item editor
    6451 ################################################################################                 
     6438#####  Notebook Tree Item editor ##############################################
    64526439def UpdateNotebook(G2frame,data):
    64536440    '''Called when the data tree notebook entry is selected. Allows for
     
    64716458    G2frame.dataWindow.GetSizer().Add(text,1,wx.ALL|wx.EXPAND)
    64726459
    6473 ################################################################################
    6474 #####  Comments
    6475 ################################################################################       
     6460#####  Comments ###############################################################
    64766461def UpdateComments(G2frame,data):
    64776462    '''Place comments into the data window
     
    64916476
    64926477           
    6493 ################################################################################
    6494 #####  Controls Tree Item editor
    6495 ################################################################################           
     6478#####  Controls Tree Item editor ##############################################
    64966479def UpdateControls(G2frame,data):
    64976480    '''Edit overall GSAS-II controls in main Controls data tree entry
     
    67836766    G2frame.SendSizeEvent()
    67846767   
    6785 ################################################################################
    6786 #####  Display of Sequential Results
    6787 ################################################################################           
    6788        
     6768
     6769#####  Display of Sequential Results ##########################################
    67896770def UpdateSeqResults(G2frame,data,prevSize=None):
    67906771    """
     
    77417722                            for iname,name in enumerate(names):
    77427723                                AtomSS[Stype][iw][0][iname] = parmDict[pfx+name]
    7743    
     7724                               
     7725    def OnEditSelectPhaseVars(event):
     7726        '''Select phase parameters in a selected histogram in a sequential
     7727        fit. This allows the user to set their value(s)
     7728        '''
     7729        rows = G2frame.dataDisplay.GetSelectedRows()
     7730        if len(rows) == 1:
     7731            sel = rows[0]
     7732        else:
     7733            dlg = G2G.G2SingleChoiceDialog(G2frame, 'Select histogram to use for update',
     7734                                           'Select row',histNames)
     7735            if dlg.ShowModal() == wx.ID_OK:
     7736                sel = dlg.GetSelection()
     7737                dlg.Destroy()
     7738            else:
     7739                dlg.Destroy()
     7740                return
     7741        parmDict = data[histNames[sel]]['parmDict']
     7742        # narrow down to items w/o a histogram & having float values
     7743        phaseKeys = [i for i in parmDict if ':' in i and i.split(':')[1] == '']
     7744        phaseKeys = [i for i in phaseKeys if type(parmDict[i]) not in (int,str,bool) ]
     7745        dlg = G2G.G2MultiChoiceDialog(G2frame, 'Choose phase parmDict items to set',
     7746                                      'Choose items to edit', phaseKeys)
     7747        if dlg.ShowModal() == wx.ID_OK:
     7748            select = dlg.GetSelections()
     7749            dlg.Destroy()
     7750        else:
     7751            dlg.Destroy()
     7752            return
     7753        if len(select) == 0: return
     7754        l = [phaseKeys[i] for i in select]
     7755        d = {i:parmDict[i] for i in l}
     7756        val = G2G.CallScrolledMultiEditor(G2frame,len(l)*[d],l,l,CopyButton=True)
     7757        if val:
     7758            for key in d: # update values shown in table
     7759                if parmDict[key] == d[key]: continue
     7760                if key in data[histNames[sel]]['varyList']:
     7761                    i = data[histNames[sel]]['varyList'].index(key)
     7762                    data[histNames[sel]]['variables'][i] = d[key]
     7763                    data[histNames[sel]]['sig'][i] = 0
     7764                if key in data[histNames[sel]].get('depParmDict',{}):
     7765                    data[histNames[sel]]['depParmDict'][key] = (d[key],0)
     7766            parmDict.update(d) # update values used in next fit
     7767        wx.CallAfter(UpdateSeqResults,G2frame,data) # redisplay variables
     7768        return
     7769           
     7770##### UpdateSeqResults: start processing sequential results here ##########
    77447771    # lookup table for unique cell parameters by symmetry
    77457772    cellGUIlist = [
     
    77567783    cellUlbl = ('a','b','c',u'\u03B1',u'\u03B2',u'\u03B3') # unicode a,b,c,alpha,beta,gamma
    77577784
    7758     #======================================================================
    7759     # start processing sequential results here (UpdateSeqResults)
    7760     #======================================================================
    77617785    if not data:
    77627786        print ('No sequential refinement results')
     
    78397863    #G2frame.Bind(wx.EVT_MENU, OnReOrgSelSeq, id=G2G.wxID_ORGSEQSEL)
    78407864    G2frame.Bind(wx.EVT_MENU, OnSelectUpdate, id=G2G.wxID_UPDATESEQSEL)
     7865    G2frame.Bind(wx.EVT_MENU, OnEditSelectPhaseVars, id=G2G.wxID_EDITSEQSELPHASE)
    78417866    G2frame.Bind(wx.EVT_MENU, onSelectSeqVars, id=G2G.wxID_ORGSEQINC)
    78427867    G2frame.Bind(wx.EVT_MENU, AddNewPseudoVar, id=G2G.wxID_ADDSEQVAR)
     
    79027927    #else:
    79037928    #    G2frame.dataWindow.SequentialFile.Enable(G2G.wxID_ORGSEQSEL,False)
    7904     #-----------------------------------------------------------------------------------
    7905     # build up the data table by columns -----------------------------------------------
     7929    ######  build up the data table by columns -----------------------------------------------
    79067930    histNames = foundNames
    79077931    nRows = len(histNames)
     
    82528276    G2frame.dataWindow.SetDataSize()
    82538277
    8254 ################################################################################
    8255 #####  Main PWDR panel
    8256 ################################################################################           
    8257        
     8278#####  Main PWDR panel ########################################################   
    82588279def UpdatePWHKPlot(G2frame,kind,item):
    82598280    '''Called when the histogram main tree entry is called. Displays the
     
    86818702        wx.CallAfter(G2frame.GPXtree.SelectItem,item)
    86828703                 
    8683 ################################################################################
    8684 #####  Data (GPX) tree routines
    8685 ################################################################################           
    8686        
     8704#####  Data (GPX) tree routines ###############################################       
    86878705def GetGPXtreeDataNames(G2frame,dataTypes):
    86888706    '''Finds all items in tree that match a 4 character prefix
  • trunk/GSASIIddataGUI.py

    r4801 r4819  
    3030import GSASIIctrlGUI as G2G
    3131import GSASIIpy3 as G2py3
     32import GSASIIdataGUI as G2gd
    3233
    3334WACV = wx.ALIGN_CENTER_VERTICAL
     
    3839                'rho':[],'rhoMax':0.,'mapSize':10.0,'cutOff':50.,'Flip':False}
    3940
    40 ################################################################################
    41 ##### DData routines
    42 ################################################################################       
     41##### DData routines ################################################################################       
    4342def UpdateDData(G2frame,DData,data,hist='',Scroll=0):
    4443    '''Display the Diffraction Data associated with a phase
     
    229228        Obj = event.GetEventObject()
    230229        UseList[G2frame.hist]['Pref.Ori.'][2] = Obj.GetValue()
    231            
     230
     231    def OnAddFixed(event):
     232        fixedVars = UseList[G2frame.hist].get('FixedSeqVars',[])
     233        SeqId = G2gd.GetGPXtreeItemId(G2frame, G2frame.root, 'Sequential results')
     234        seqData = G2frame.GPXtree.GetItemPyData(SeqId)
     235        if G2frame.hist not in seqData:
     236            print('Strange: '+G2frame.hist+' not found')
     237            return
     238        parmDict = seqData[G2frame.hist].get('parmDict',[])
     239        # narrow down to items w/o a histogram & having float values
     240        phaseKeys = [i for i in parmDict if ':' in i and i.split(':')[1] == '']
     241        phaseKeys = [i for i in phaseKeys if type(parmDict[i]) not in (int,str,bool)]
     242        if len(phaseKeys) == 0: return
     243        selected = []
     244        for i,key in enumerate(phaseKeys):
     245            if key in fixedVars: selected.append(i)
     246        dlg = G2G.G2MultiChoiceDialog(G2frame, 'Choose phase vars to fix for this histogram only',
     247                                      'Choose items to edit', phaseKeys,selected=selected)
     248        if dlg.ShowModal() == wx.ID_OK:
     249            sel = dlg.GetSelections()
     250            dlg.Destroy()
     251        else:
     252            dlg.Destroy()
     253            return
     254        UseList[G2frame.hist]['FixedSeqVars'] = [phaseKeys[i] for i in sel]
     255        wx.CallLater(100,RepaintHistogramInfo,DData.GetScrollPos(wx.VERTICAL))
     256
    232257    def SetPOCoef(Order,hist):
    233258        cofNames = G2lat.GenSHCoeff(SGData['SGLaue'],'0',Order,False)     #cylindrical & no M
     
    868893        if 'Fix FXU' not in UseList[G2frame.hist]:
    869894            UseList[G2frame.hist]['Fix FXU'] = ' '
     895        if 'FixedSeqVars' not in UseList[G2frame.hist]:
     896            UseList[G2frame.hist]['FixedSeqVars'] = []
    870897        if 'Flack' not in UseList[G2frame.hist]:
    871898            UseList[G2frame.hist]['Flack'] = [0.0,False]
     
    892919                G2frame.SetStatusText('To reset LeBail, cycle LeBail check box.',1)
    893920        bottomSizer.Add(useBox,0,wx.TOP|wx.BOTTOM|wx.LEFT,5)
    894         fixBox = wx.BoxSizer(wx.HORIZONTAL)
    895         parmChoice = [' ','X','XU','U','F','FX','FXU','FU']
    896         if generalData['Type'] == 'magnetic':
    897             parmChoice += ['M','MX','MXU','MU','MF','MFX','MFXU','MFU']
    898         fixBox.Add(wx.StaticText(DData,label=' In sequential refinement, fix these in '+generalData['Name']+' for this histogram: '),0,WACV)
    899         fixVals = wx.ComboBox(DData,value=UseList[G2frame.hist]['Fix FXU'],choices=parmChoice,
    900             style=wx.CB_DROPDOWN)
    901         fixVals.Bind(wx.EVT_COMBOBOX,OnFixVals)
    902         fixBox.Add(fixVals,0,WACV)
    903         bottomSizer.Add(fixBox)
    904         #TODO - put Sequential refinement fix F? fix X? fix U? CheckBox here
     921        if G2frame.testSeqRefineMode():
     922            bottomSizer.Add(wx.StaticText(DData,label='     Sequential Refinemment Options'))
     923            parmChoice = [' ','X','XU','U','F','FX','FXU','FU']
     924            if generalData['Type'] == 'magnetic':
     925                parmChoice += ['M','MX','MXU','MU','MF','MFX','MFXU','MFU']
     926            fixBox = wx.BoxSizer(wx.HORIZONTAL)
     927            fixBox.Add(wx.StaticText(DData,label='     Fix these var types: '),0,WACV)
     928            fixVals = wx.ComboBox(DData,value=UseList[G2frame.hist]['Fix FXU'],choices=parmChoice,
     929                style=wx.CB_DROPDOWN)
     930            fixVals.Bind(wx.EVT_COMBOBOX,OnFixVals)
     931            fixBox.Add(fixVals,0,WACV)
     932            fixBox.Add(wx.StaticText(DData,label=' in phase '+generalData['Name']+' for this histogram'),0,WACV)
     933            bottomSizer.Add(fixBox)
     934            SeqId = G2gd.GetGPXtreeItemId(G2frame, G2frame.root, 'Sequential results')
     935            if SeqId:
     936                fixBox = wx.BoxSizer(wx.HORIZONTAL)
     937                fixBox.Add(wx.StaticText(DData,label='     Specific phase variables to fix for this histogram: '),0,WACV)
     938                addFixed = wx.Button(DData,wx.ID_ANY,label='Select Vars')
     939                fixBox.Add(addFixed,0,WACV)
     940                addFixed.Bind(wx.EVT_BUTTON,OnAddFixed)
     941                fixedVars = UseList[G2frame.hist].get('FixedSeqVars',[])
     942                if len(fixedVars):
     943                    fixBox.Add(wx.StaticText(DData,label=' (currently {} fixed)'.format(len(fixedVars))),0,WACV)
     944            bottomSizer.Add(fixBox)
    905945       
    906946        bottomSizer.Add(ScaleSizer(),0,wx.BOTTOM,5)
  • trunk/GSASIImath.py

    r4811 r4819  
    338338        # complete current cycle
    339339        deltaChi2 = (chisq0-chisq1)/chisq0
    340         if Print and n-len(indices):
     340        if n-len(indices):
    341341            G2fil.G2Print(
    342342                'Cycle %d: %.2fs Chi2: %.5g; Obs: %d; Lam: %.3g Del: %.3g; drop=%d, SVD=%d'%
    343343                (icycle,time.time()-time0,chisq1,Nobs,lamMax,deltaChi2,n-len(indices),Nzeros))
    344         elif Print:
     344        else:
    345345            G2fil.G2Print(
    346346                'Cycle %d: %.2fs, Chi**2: %.5g for %d obs., Lambda: %.3g,  Delta: %.3g, SVD=%d'%
     
    350350        if deltaChi2 < ftol:
    351351            ifConverged = True
    352             if Print: G2fil.G2Print("converged")
     352            G2fil.G2Print("converged")
    353353            break
    354354        icycle += 1
  • trunk/GSASIIphsGUI.py

    r4818 r4819  
    100100    GkDelta = chr(0x0394)
    101101    Angstr = chr(0x00c5)   
    102 ################################################################################
    103 #### phase class definitions
    104 ################################################################################
     102
     103#### phase class definitions ################################################################################
    105104class SymOpDialog(wx.Dialog):
    106105    '''Class to select a symmetry operator
     
    95929591        sourceDict = copy.deepcopy(data['Histograms'][hist])
    95939592        if 'HKLF' in sourceDict['Histogram']:
    9594             copyNames = ['Scale','Extinction','Babinet','Flack','Twins','Fix FXU']
     9593            copyNames = ['Extinction','Babinet','Flack','Twins']
    95959594        else:  #PWDR 
    9596             copyNames = ['Scale','Pref.Ori.','Size','Mustrain','HStrain','Extinction','Babinet','LeBail','newLeBail','Fix FXU','Layer Disp']
     9595            copyNames = ['Pref.Ori.','Size','Mustrain','HStrain','Extinction','Babinet','LeBail','newLeBail','Layer Disp']
     9596        copyNames += ['Scale','Fix FXU','FixedSeqVars']
    95979597        copyDict = {}
    9598         for name in copyNames:
    9599             copyDict[name] = sourceDict[name]        #force copy
     9598        for name in copyNames:
     9599            if name not in sourceDict: continue
     9600            copyDict[name] = copy.deepcopy(sourceDict[name])        #force copy
    96009601        dlg = G2G.G2MultiChoiceDialog(G2frame,u'Copy phase/histogram parameters\nfrom '+hist[5:][:35],
    96019602                'Copy phase/hist parameters', keyList)
     
    96129613        copyDict = {}
    96139614        if 'HKLF' in sourceDict['Histogram']:
    9614             copyNames = ['Scale','Extinction','Babinet','Flack','Twins','Fix FXU']
     9615            copyNames = ['Extinction','Babinet','Flack','Twins']
    96159616        else:  #PWDR 
    9616             copyNames = ['Scale','Pref.Ori.','Size','Mustrain','HStrain','Extinction','Babinet','Fix FXU','Layer Disp']
     9617            copyNames = ['Pref.Ori.','Size','Mustrain','HStrain','Extinction','Babinet','Layer Disp']
     9618        copyNames += ['Scale','Fix FXU','FixedSeqVars']
    96179619        babNames = ['BabA','BabU']
    96189620        for name in copyNames:
     9621            if name not in sourceDict: continue
    96199622            if name in ['Scale','Extinction','HStrain','Flack','Twins','Layer Disp']:
    96209623                if name == 'Extinction' and 'HKLF' in sourceDict['Histogram']:
     
    96409643                for bab in babNames:
    96419644                    copyDict[name][bab] = sourceDict[name][bab][1]
    9642             elif name == 'Fix FXU':
    9643                 copyDict[name] = sourceDict[name]                     
     9645            elif name == 'Fix FXU' or name == 'FixedSeqVars':
     9646                copyDict[name] = copy.deepcopy(sourceDict[name])                   
    96449647        keyList = G2frame.dataWindow.HistsInPhase[:]
    96459648        if hist in keyList: keyList.remove(hist)
     
    96549657                    item = keyList[sel]
    96559658                    for name in copyNames:
     9659                        if name not in sourceDict: continue
    96569660                        if name in ['Scale','Extinction','HStrain','Flack','Twins','Layer Disp']:
    96579661                            if name == 'Extinction' and 'HKLF' in sourceDict['Histogram']:
     
    96819685                            for bab in babNames:
    96829686                                data['Histograms'][item][name][bab][1] = copy.deepcopy(copyDict[name][bab])
    9683                         elif name == 'Fix FXU':
     9687                        elif name == 'Fix FXU' or name == 'FixedSeqVars':
    96849688                            data['Histograms'][item][name] = copy.deepcopy(sourceDict[name])                     
    96859689        finally:
     
    96959699            return
    96969700        if 'HKLF' in sourceDict['Histogram']:
    9697             copyNames = ['Scale','Extinction','Babinet','Flack','Twins','Fix FXU']
     9701            copyNames = ['Extinction','Babinet','Flack','Twins']
    96989702        else:  #PWDR 
    9699             copyNames = ['Scale','Pref.Ori.','Size','Mustrain','HStrain','Extinction','Babinet','LeBail','newLeBail','Fix FXU','Layer Disp']
     9703            copyNames = ['Pref.Ori.','Size','Mustrain','HStrain','Extinction','Babinet','LeBail','newLeBail','Layer Disp']
     9704        copyNames += ['Scale','Fix FXU','FixedSeqVars']           
    97009705        dlg = G2G.G2MultiChoiceDialog(G2frame,'Select which parameters to copy',
    97019706            'Select phase data parameters', copyNames)
     
    97099714        copyDict = {}
    97109715        for parm in selectedItems:
     9716            if parm not in sourceDict: continue
    97119717            copyDict[parm] = copy.deepcopy(sourceDict[parm])
    97129718        dlg = G2G.G2MultiChoiceDialog(G2frame,u'Copy selected phase/histogram parameters\nfrom '+hist[5:][:35],
     
    97559761                            'HStrain':[NDij*[0.0,],NDij*[False,]],
    97569762                            'Layer Disp':[0.0,False],                         
    9757                             'Extinction':[0.0,False],'Babinet':{'BabA':[0.0,False],'BabU':[0.0,False]},'Fix FXU':' '}
     9763                            'Extinction':[0.0,False],'Babinet':{'BabA':[0.0,False],'BabU':[0.0,False]},'Fix FXU':' ','FixedSeqVars':[]}
    97589764                        refList = G2frame.GPXtree.GetItemPyData(G2gd.GetGPXtreeItemId(G2frame,Id,'Reflection Lists'))
    97599765                        refList[generalData['Name']] = {}                       
     
    1089010896            RigidBodies.atomsGrid.Bind(wg.EVT_GRID_LABEL_LEFT_CLICK,OnRowSelect)
    1089110897            choiceeditor = wg.GridCellChoiceEditor(
    10892                 data['testRBObj']['availAtoms'], False)
     10898                data['testRBObj']['availAtoms']+['Create new'], False)
    1089310899            RigidBodies.atomsGrid.SetTable(RigidBodies.atomsTable,True)
    1089410900            # make all grid entries read only
  • trunk/GSASIIpwdGUI.py

    r4810 r4819  
    11681168            for term in backDict['peaksList']:
    11691169                PKflags.append(term[1::2])
    1170         FBflag = backDict['background PWDR'][2]
     1170        FBflag = bool(backDict['background PWDR'][2])
    11711171        hst = G2frame.GPXtree.GetItemText(G2frame.PatternId)
    11721172        histList = GetHistsLikeSelected(G2frame)
     
    11941194                for i,term in enumerate(bkDict['peaksList']):
    11951195                    term[1::2] = copy.copy(PKflags[i])
    1196             backData[1]['background PWDR'] = copy.copy(FBflag)
     1196            try:
     1197                backData[1]['background PWDR'][2] = FBflag
     1198            except:
     1199                backData[1]['background PWDR'] = ['',-1.,False]
    11971200           
    11981201    def OnBackCopy(event):
  • trunk/GSASIIstrMain.py

    r4789 r4819  
    505505    '''
    506506    Removes unused parameters from phase varylist if phase not in histogram
    507     #TODO - implement "Fix FXU" for seq refinement here - done?
     507    for seq refinement removes vars in "Fix FXU" and "FixedSeqVars" here
    508508    '''
    509509    NewVary = []
     
    522522            if 'M' in FixVals:
    523523                newVary = [item for item in newVary if not 'AM' in item]
     524            removeVars = Phases[phase]['Histograms'][histogram].get('FixedSeqVars',[])
     525            newVary = [item for item in newVary if item not in removeVars]
    524526            NewVary += newVary
    525527    return NewVary
     
    604606            G2fil.G2Print("Error: not found!")
    605607            continue
    606     #TODO - implement "Fix FXU" for seq refinement here - done?
    607608        hId = Histograms[histogram]['hId']
    608609        redphaseVary = phaseCheck(phaseVary,Phases,histogram)
Note: See TracChangeset for help on using the changeset viewer.