Changeset 3461


Ignore:
Timestamp:
Jul 4, 2018 8:35:03 PM (3 years ago)
Author:
toby
Message:

Add CheckAllScalePhaseFractions? to add constraint when all phase fractions are varied; Py3 fixes for seq fit equations; on update, save only when needed

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIctrlGUI.py

    r3459 r3461  
    42704270            return
    42714271        dlg.Destroy()
    4272         self.frame.OnFileSave(event)
    4273         GPX = self.frame.GSASprojectfile
    4274         GSASIIpath.svnUpdateProcess(projectfile=GPX)
     4272        if self.frame.GPXtree.GetCount() > 1:
     4273            self.frame.OnFileSave(event)
     4274            GPX = self.frame.GSASprojectfile
     4275            GSASIIpath.svnUpdateProcess(projectfile=GPX)
     4276        else:
     4277            GSASIIpath.svnUpdateProcess()
    42754278        return
    42764279
  • trunk/GSASIIobj.py

    r3458 r3461  
    23552355            if not self.freeVars[v][2]: continue
    23562356            if "::"+self.freeVars[v][0] not in varyList: continue
    2357             indx = varyList.index("::"+self.freeVars[v][0])
     2357            indx = list(varyList).index("::"+self.freeVars[v][0])
    23582358            self.freeVars[v][1] = values[indx]
    23592359
     
    23752375        exprLblList,fxnpkgdict = ret
    23762376        # check each var used in expression is defined
    2377         defined = self.assgnVars.keys() + self.freeVars.keys()
     2377        defined = list(self.assgnVars.keys()) + list(self.freeVars.keys())
    23782378        notfound = []
    23792379        for var in exprLblList:
  • trunk/GSASIIphsGUI.py

    r3459 r3461  
    2020(such as GSASIIddata).
    2121
     22Main routine here is :func:`UpdatePhaseData`, which displays the phase information
     23(called from :func:`GSASIIdataGUI:SelectDataTreeItem`).
     24
     25Other top-level routines are:
     26:func:`GetSpGrpfromUser` (called locally only);
     27:func:`FindBondsDraw` and :func:`FindBondsDrawCell` (called locally and in GSASIIplot);
     28:func:`SetPhaseWindow` (called locally and in GSASIIddataGUI and GSASIIrestrGUI, multiple locations)
     29to control scrolling.
    2230'''
    2331from __future__ import division, print_function
     
    10951103                    atomData[i][-1] = Faces
    10961104                       
     1105################################################################################
     1106################################################################################
     1107def CheckAllScalePhaseFractions(G2frame):
     1108    '''Check if scale factor and all phase fractions are refined without a constraint
     1109    for all used histograms, if so, offer the user a chance to create a constraint
     1110    on the sum of phase fractions
     1111    '''
     1112    histograms, phases = G2frame.GetUsedHistogramsAndPhasesfromTree()
     1113    for i,hist in enumerate(histograms):
     1114        CheckScalePhaseFractions(G2frame,hist,histograms,phases)
     1115       
     1116def CheckScalePhaseFractions(G2frame,hist,histograms,phases):
     1117    '''Check if scale factor and all phase fractions are refined without a constraint
     1118    for histogram hist, if so, offer the user a chance to create a constraint
     1119    on the sum of phase fractions
     1120    '''
     1121    if G2frame.testSeqRefineMode():
     1122        histStr = '*'
     1123    else:
     1124        histStr = str(histograms[hist]['hId'])
     1125    # is scale factor varied
     1126    if not histograms[hist]['Sample Parameters']['Scale'][1]:
     1127        return
     1128    # are all phase fractions varied in all used histograms
     1129    phaseCount = 0
     1130    for p in phases:
     1131        if phases[p]['Histograms'][hist]['Use'] and not phases[p]['Histograms'][hist]['Scale'][1]:
     1132            return
     1133        else:
     1134            phaseCount += 1
     1135   
     1136    # all phase fractions and scale factor varied, now scan through constraints
     1137    sub = G2gd.GetGPXtreeItemId(G2frame,G2frame.root,'Constraints')
     1138    Constraints = G2frame.GPXtree.GetItemPyData(sub)
     1139    fracConstr = False
     1140    for c in Constraints.get('HAP',[]):
     1141        if c[-1] != 'c': continue
     1142        if not c[-3]: continue
     1143        if len(c[:-3]) != phaseCount: continue
     1144        # got a constraint equation with right number of terms, is it on phase fractions for
     1145        # the correct histogram?
     1146        if all([(i[1].name == 'Scale' and i[1].varname().split(':')[1] == histStr) for i in c[:-3]]):
     1147            # got a constraint, this is OK
     1148            return
     1149    dlg = wx.MessageDialog(G2frame,
     1150                            'You are refining the scale factor and all phase fractions for histogram #'+
     1151                            histStr+'. This will produce an unstable refinement. '+
     1152                            'Do you want to constrain the sum of phase fractions?',
     1153                            'Create constraint?',
     1154                            wx.OK|wx.CANCEL)
     1155    if dlg.ShowModal() != wx.ID_OK:
     1156        dlg.Destroy()
     1157        return
     1158    dlg.Destroy()
     1159
     1160    constr = []
     1161    for p in phases:
     1162        if not phases[p]['Histograms'][hist]['Use']: continue
     1163        constr += [[1.0,G2obj.G2VarObj(':'.join((str(phases[p]['pId']),histStr,'Scale')))]]
     1164    constr += [1.0,None,'c']
     1165    Constraints['HAP'] += [constr]
     1166################################################################################
     1167################################################################################
    10971168def UpdatePhaseData(G2frame,Item,data):
    10981169    '''Create the data display window contents when a phase is clicked on
     
    92009271            return
    92019272    ChangePage(0)
     9273    CheckAllScalePhaseFractions(G2frame)
  • trunk/fsource/SConstruct

    r3436 r3461  
    378378    print('Creating '+InstallLoc)
    379379    os.makedirs(InstallLoc)
     380    fp = open(os.path.join(InstallLoc,'Build.notes.txt'),'w')
     381    fp.write('Created {} on {}\n'.format(datetime.datetime.isoformat(datetime.datetime.now()),
     382                                         platform.node()))
     383    if 'BUILDINFO' in os.environ:
     384        fp.write('{}\n'.format(os.environ['BUILDINFO']))
     385    fp.close()
Note: See TracChangeset for help on using the changeset viewer.