Changeset 1058


Ignore:
Timestamp:
Sep 18, 2013 12:17:34 PM (10 years ago)
Author:
vondreele
Message:

implement save of Pawley covariances for MC/SA

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIImath.py

    r1056 r1058  
    25632563                    Cart = np.array(RBRes['rbXYZ'])
    25642564                    for itor,seq in enumerate(RBRes['rbSeq']):
    2565                         tName = pfx+'Tor'+str(itor)
    2566                         QuatA = AVdeg2Q(parmDict[tName],Cart[seq[0]]-Cart[seq[1]])
     2565                        QuatA = AVdeg2Q(parmDict[pfx+'Tor'+str(itor)],Cart[seq[0]]-Cart[seq[1]])
    25672566                        for ride in seq[3]:
    25682567                            Cart[ride] = prodQVQ(QuatA,Cart[ride]-Cart[seq[1]])+Cart[seq[1]]
     
    26302629        '''       
    26312630        global tsum
     2631        parmDict.update(dict(zip(varyList,values)))             #update parameter tables
    26322632        t0 = time.time()
    2633         parmDict.update(dict(zip(varyList,values)))             #update parameter tables
    26342633        Xdata = GetAtomTX(RBdata,parmDict)[1]                   #get new atom coords from RB
     2634        tsum += (time.time()-t0)
    26352635        allX = getAllX(Xdata,SGM,SGT)                           #fill unit cell - dups. OK
    26362636        MDval = parmDict['0:MDval']                             #get March-Dollase coeff
     
    26492649        refList[6] = refList[4]-refList[5]
    26502650        M = np.inner(refList[6],np.inner(rcov,refList[6]))
    2651         tsum += (time.time()-t0)
    26522651#        print M,parmDict['sumFosq'],np.sum(refList[6]**2),np.sum(refList[4]**2)
    26532652#        print np.sum(refList[6]**2)/np.sum(refList[4]**2)
     
    27322731        rcov /= Rnorm
    27332732    elif 'Pawley' in reflName:  #need a bail out if Pawley cov matrix doesn't exist.
    2734         covMatrix = covData['covMatrix']
    27352733        vList = covData['varyList']
    27362734        for iref,refI in enumerate(reflData):
     
    27432741        nRef = len(refs)
    27442742        pfx = str(data['pId'])+'::PWLref:'
    2745         rcov = np.zeros((nRef,nRef))       
    2746         for iref,refI in enumerate(refs):
    2747             I = refI[5]
    2748             nameI = pfx+str(I)
    2749             if nameI in vList:
    2750                 Iindx = vList.index(nameI)
    2751                 rcov[iref][iref] = covMatrix[Iindx][Iindx]
    2752                 for jref,refJ in enumerate(refs[:iref]):
    2753                     J = refJ[5]
    2754                     nameJ = pfx+str(J)
    2755                     try:
    2756                         rcov[iref][jref] = covMatrix[vList.index(nameI)][vList.index(nameJ)]
    2757                     except ValueError:
    2758                         rcov[iref][jref] = rcov[iref][jref-1]
    2759             else:
    2760                 rcov[iref] = rcov[iref-1]
    2761                 rcov[iref][iref] = rcov[iref-1][iref-1]
    2762         rcov += (rcov.T-np.diagflat(np.diagonal(rcov)))
    2763         Rdiag = np.sqrt(np.diag(rcov))
    2764         Rnorm = np.outer(Rdiag,Rdiag)
    2765         rcov /= Rnorm
     2743        if covData['freshCOV'] and generalData['doPawley']:
     2744            covMatrix = covData['covMatrix']
     2745            rcov = np.zeros((nRef,nRef))       
     2746            for iref,refI in enumerate(refs):
     2747                I = refI[5]
     2748                nameI = pfx+str(I)
     2749                if nameI in vList:
     2750                    Iindx = vList.index(nameI)
     2751                    rcov[iref][iref] = covMatrix[Iindx][Iindx]
     2752                    for jref,refJ in enumerate(refs[:iref]):
     2753                        J = refJ[5]
     2754                        nameJ = pfx+str(J)
     2755                        try:
     2756                            rcov[iref][jref] = covMatrix[vList.index(nameI)][vList.index(nameJ)]
     2757                        except ValueError:
     2758                            rcov[iref][jref] = rcov[iref][jref-1]
     2759                else:
     2760                    rcov[iref] = rcov[iref-1]
     2761                    rcov[iref][iref] = rcov[iref-1][iref-1]
     2762            rcov += (rcov.T-np.diagflat(np.diagonal(rcov)))
     2763            Rdiag = np.sqrt(np.diag(rcov))
     2764            Rnorm = np.outer(Rdiag,Rdiag)
     2765            rcov /= Rnorm
     2766            MCSA['rcov'] = rcov
     2767            covData['freshCOV'] = False
     2768        else:
     2769            rcov = MCSA['rcov']
    27662770    elif 'HKLF' in reflName:
    27672771        for ref in reflData:
  • trunk/GSASIIstrMain.py

    r1028 r1058  
    179179               'varyListStart':varyListStart,
    180180               'covMatrix':covMatrix,'title':GPXfile,'newAtomDict':newAtomDict,
    181                'newCellDict':newCellDict}
     181               'newCellDict':newCellDict,'freshCOV':True}
    182182    # add the uncertainties into the esd dictionary (sigDict)
    183183    sigDict.update(G2mv.ComputeDepESD(covMatrix,varyList,parmDict))
Note: See TracChangeset for help on using the changeset viewer.