Changeset 747


Ignore:
Timestamp:
Aug 31, 2012 7:44:10 PM (10 years ago)
Author:
vondreele
Message:

fix to Pawley estimate - subtract background
get neg weight on penalty derivs

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIphsGUI.py

    r746 r747  
    38603860                    FWHM = max(0.001,G2pwd.getFWHM(pos,Inst))/2.
    38613861                    dx = xdata[0][indx+1]-xdata[0][indx]
    3862                     ref[6] = FWHM*xdata[1][indx]*cosd(pos/2.)**3/dx
     3862                    ref[6] = FWHM*(xdata[1][indx]-xdata[4][indx])*cosd(pos/2.)**3/dx
    38633863                    Lorenz = 1./(2.*sind(xdata[0][indx]/2.)**2*cosd(xdata[0][indx]/2.))           #Lorentz correction
    38643864                    pola,dIdPola = G2pwd.Polarization(Inst['Polariz.'],xdata[0][indx],Inst['Azimuth'])
  • trunk/GSASIIpwd.py

    r736 r747  
    10131013    parmdict.update(zip(varylist,values))
    10141014   
     1015def SetBackgroundParms(Background):
     1016    if len(Background) == 1:            # fix up old backgrounds
     1017        BackGround.append({'nDebye':0,'debyeTerms':[]})
     1018    bakType,bakFlag = Background[0][:2]
     1019    backVals = Background[0][3:]
     1020    backNames = ['Back:'+str(i) for i in range(len(backVals))]
     1021    Debye = Background[1]           #also has background peaks stuff
     1022    backDict = dict(zip(backNames,backVals))
     1023    backVary = []
     1024    if bakFlag:
     1025        backVary = backNames
     1026
     1027    backDict['nDebye'] = Debye['nDebye']
     1028    debyeDict = {}
     1029    debyeList = []
     1030    for i in range(Debye['nDebye']):
     1031        debyeNames = ['DebyeA:'+str(i),'DebyeR:'+str(i),'DebyeU:'+str(i)]
     1032        debyeDict.update(dict(zip(debyeNames,Debye['debyeTerms'][i][::2])))
     1033        debyeList += zip(debyeNames,Debye['debyeTerms'][i][1::2])
     1034    debyeVary = []
     1035    for item in debyeList:
     1036        if item[1]:
     1037            debyeVary.append(item[0])
     1038    backDict.update(debyeDict)
     1039    backVary += debyeVary
     1040
     1041    backDict['nPeaks'] = Debye['nPeaks']
     1042    peaksDict = {}
     1043    peaksList = []
     1044    for i in range(Debye['nPeaks']):
     1045        peaksNames = ['BkPkpos:'+str(i),'BkPkint:'+str(i),'BkPksig:'+str(i),'BkPkgam:'+str(i)]
     1046        peaksDict.update(dict(zip(peaksNames,Debye['peaksList'][i][::2])))
     1047        peaksList += zip(peaksNames,Debye['peaksList'][i][1::2])
     1048    peaksVary = []
     1049    for item in peaksList:
     1050        if item[1]:
     1051            peaksVary.append(item[0])
     1052    backDict.update(peaksDict)
     1053    backVary += peaksVary   
     1054    return bakType,backDict,backVary
     1055           
    10151056def DoPeakFit(FitPgm,Peaks,Background,Limits,Inst,data,oneCycle=False,controls=None,dlg=None):
    10161057   
    1017     def SetBackgroundParms(Background):
    1018         if len(Background) == 1:            # fix up old backgrounds
    1019             BackGround.append({'nDebye':0,'debyeTerms':[]})
    1020         bakType,bakFlag = Background[0][:2]
    1021         backVals = Background[0][3:]
    1022         backNames = ['Back:'+str(i) for i in range(len(backVals))]
    1023         Debye = Background[1]           #also has background peaks stuff
    1024         backDict = dict(zip(backNames,backVals))
    1025         backVary = []
    1026         if bakFlag:
    1027             backVary = backNames
    1028 
    1029         backDict['nDebye'] = Debye['nDebye']
    1030         debyeDict = {}
    1031         debyeList = []
    1032         for i in range(Debye['nDebye']):
    1033             debyeNames = ['DebyeA:'+str(i),'DebyeR:'+str(i),'DebyeU:'+str(i)]
    1034             debyeDict.update(dict(zip(debyeNames,Debye['debyeTerms'][i][::2])))
    1035             debyeList += zip(debyeNames,Debye['debyeTerms'][i][1::2])
    1036         debyeVary = []
    1037         for item in debyeList:
    1038             if item[1]:
    1039                 debyeVary.append(item[0])
    1040         backDict.update(debyeDict)
    1041         backVary += debyeVary
    1042    
    1043         backDict['nPeaks'] = Debye['nPeaks']
    1044         peaksDict = {}
    1045         peaksList = []
    1046         for i in range(Debye['nPeaks']):
    1047             peaksNames = ['BkPkpos:'+str(i),'BkPkint:'+str(i),'BkPksig:'+str(i),'BkPkgam:'+str(i)]
    1048             peaksDict.update(dict(zip(peaksNames,Debye['peaksList'][i][::2])))
    1049             peaksList += zip(peaksNames,Debye['peaksList'][i][1::2])
    1050         peaksVary = []
    1051         for item in peaksList:
    1052             if item[1]:
    1053                 peaksVary.append(item[0])
    1054         backDict.update(peaksDict)
    1055         backVary += peaksVary   
    1056         return bakType,backDict,backVary           
    10571058       
    10581059    def GetBackgroundParms(parmList,Background):
  • trunk/GSASIIstruct.py

    r746 r747  
    19091909def penaltyDeriv(pNames,pVal,Phases,parmDict,varyList):
    19101910    pDerv = np.zeros((len(varyList),len(pVal)))
     1911    negWt = {}
     1912    for phase in Phases:
     1913        negWt[Phases[phase]['pId']] = np.sqrt(Phases[phase]['General']['Pawley neg wt'])
    19111914    for i,item in enumerate(varyList):
    1912         if item in pNames:           
    1913             pDerv[i][pNames.index(item)] -= 2.*parmDict[item]
     1915        if item in pNames:
     1916            pId = int(item.split(':')[0])
     1917            pDerv[i][pNames.index(item)] -= 2.*negWt[pId]*parmDict[item]
    19141918    return pDerv
    19151919
     
    31993203    pDict,pVals = penaltyFxn(Phases,parmdict,varylist)
    32003204    if np.sum(pVals):
    3201         print 'Penalty function :',np.sum(pVals)
     3205        print 'Penalty function :',np.sum(pVals),' on ',len(pVals),' terms'
    32023206        M = np.concatenate((M,pVals))
    32033207    return M
Note: See TracChangeset for help on using the changeset viewer.