Changeset 419


Ignore:
Timestamp:
Nov 17, 2011 1:25:51 PM (10 years ago)
Author:
toby
Message:

print constraint-generated variables

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIImapvars.py

    r418 r419  
    439439    return dependentVars
    440440
     441def GetIndependentVars():
     442    '''Return a list of independent variables: e.g. variables that are
     443    created by constrains of other variables'''
     444    independentVars = []
     445    global indParmList,fixedDict
     446    for lst in indParmList:
     447        for name in lst:
     448            if name in fixedDict: continue
     449            independentVars.append(name)
     450    return independentVars
     451
     452def PrintIndependentVars(parmDict,varyList,sigDict,PrintAll=False):
     453    '''Print the values and uncertainties on the independent variables'''
     454    global dependentParmList,arrayList,invarrayList,indParmList,fixedDict
     455    printlist = []
     456    mapvars = GetIndependentVars()
     457    #    for varlist,mapvars,multarr,invmultarr in zip(
     458    #        dependentParmList,indParmList,arrayList,invarrayList):
     459    for i,name in enumerate(mapvars):
     460        if name in fixedDict: continue
     461        if PrintAll or name in varyList:
     462            sig = sigDict.get(name)
     463            printlist.append([name,parmDict[name],sig])
     464    if len(printlist) == 0: return
     465    s1 = ''
     466    print 130*'-'
     467    print "Variables generated by constraints"
     468    printlist.append(3*[None])
     469    for name,val,esd in printlist:
     470        if len(s1) > 40 or name is None:
     471            print
     472            print s1
     473            print s2
     474            print s3
     475            s1 = ''
     476            if name is None: break
     477        if s1 == "":
     478            s1 = ' name  :'
     479            s2 = ' value :'
     480            s3 = ' sig   :'
     481        s1 += '%12s' % (name)
     482        s2 += '%12.6f' % (val)
     483        if esd is None:
     484            s3 += '%12s' % ('n/a')
     485        else:   
     486            s3 += '%12.6f' % (esd)
     487           
    441488def VarRemapShow(varyList):
    442489    '''List out the saved relationships.
     
    452499    for varlist,mapvars,multarr,invmultarr in zip(
    453500        dependentParmList,indParmList,arrayList,invarrayList):
    454         i = 0
    455         for mv in mapvars:
     501        for i,mv in enumerate(mapvars):
    456502            if multarr is None:
    457503                s += '  ' + str(mv) + ' defines parameter(s): '
     
    475521            if mv in varyList: s += ' VARY'
    476522            s += '\n'
    477             i += 1
    478523    s += 'Inverse variable mapping relations:\n'
    479524    for varlist,mapvars,invmultarr in zip(dependentParmList,indParmList,invarrayList):
    480         i = 0
    481         for mv in varlist:
     525        for i,mv in enumerate(varlist):
    482526            s += '  %s = ' % mv
    483527            j = 0
     
    488532                s += '(%s * %s)' % (m,v)
    489533            s += '\n'
    490             i += 1
    491534    return s
    492535
  • trunk/GSASIIstruct.py

    r417 r419  
    25732573    SetHistogramPhaseData(parmDict,sigDict,Phases,Histograms)
    25742574    SetHistogramData(parmDict,sigDict,Histograms)
     2575    G2mv.PrintIndependentVars(parmDict,varyList,sigDict)
    25752576    SetUsedHistogramsAndPhases(GPXfile,Histograms,Phases,covData)
    25762577#for testing purposes!!!
Note: See TracChangeset for help on using the changeset viewer.