Changeset 421 for trunk/GSASIImapvars.py


Ignore:
Timestamp:
Nov 17, 2011 4:12:10 PM (10 years ago)
Author:
toby
Message:

determine uncertainties on constrained variables

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIImapvars.py

    r420 r421  
    455455    printlist = []
    456456    mapvars = GetIndependentVars()
    457     #    for varlist,mapvars,multarr,invmultarr in zip(
    458     #        dependentParmList,indParmList,arrayList,invarrayList):
    459457    for i,name in enumerate(mapvars):
    460458        if name in fixedDict: continue
     
    468466    printlist.append(3*[None])
    469467    for name,val,esd in printlist:
    470         if len(s1) > 40 or name is None:
     468        if len(s1) > 110 or name is None:
    471469            print
    472470            print s1
     
    485483        else:   
    486484            s3 += '%12.6f' % (esd)
    487            
     485
     486def ComputeDepESD(covMatrix,varyList,parmDict):
     487    '''Compute uncertainties for dependent parameters from independent ones
     488    returns a dictionary containing the esd values for dependent parameters
     489    '''
     490    sigmaDict = {}
     491    for varlist,mapvars,invmultarr in zip(dependentParmList,indParmList,invarrayList):
     492        if invmultarr is None: continue # probably not needed
     493        valuelist = [parmDict[var] for var in mapvars]
     494        # get the v-covar matrix for independent parameters
     495        vcov = np.zeros((len(mapvars),len(mapvars)))
     496        for i1,name1 in enumerate(mapvars):
     497            if name1 not in varyList: continue
     498            iv1 = varyList.index(name1)
     499            for i2,name2 in enumerate(mapvars):
     500                if name2 not in varyList: continue
     501                iv2 = varyList.index(name2)
     502                vcov[i1][i2] = covMatrix[iv1][iv2]
     503        # vec is the vector that multiplies each of the independent values
     504        for v,vec in zip(varlist,invmultarr):
     505            sigmaDict[v] = np.sqrt(np.inner(vec.T,np.inner(vcov,vec)))
     506    return sigmaDict
     507       
    488508def VarRemapShow(varyList):
    489509    '''List out the saved relationships.
Note: See TracChangeset for help on using the changeset viewer.