Changeset 3070 for trunk/GSASIIpwdGUI.py


Ignore:
Timestamp:
Sep 13, 2017 8:53:49 AM (4 years ago)
Author:
vondreele
Message:

implement use of background pattern for PWDR data.
Used for plot & peak fitting; not Rietveld refinement
fix background parm copy issue - needed deepcopy

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIpwdGUI.py

    r3063 r3070  
    138138##### Setup routines
    139139################################################################################
     140
     141def GetFileBackground(G2frame,xye,Pattern):
     142    backfile,mult = Pattern[0]['BackFile']
     143    bxye = np.zeros(len(xye[1]))
     144    if backfile:
     145        bxye = mult*G2frame.GPXtree.GetItemPyData(G2gd.GetGPXtreeItemId(G2frame,G2frame.root,backfile))[1][1]
     146    return bxye
    140147   
    141148def IsHistogramInAnyPhase(G2frame,histoName):
     
    426433        limits = G2frame.GPXtree.GetItemPyData(G2gd.GetGPXtreeItemId(G2frame,PatternId, 'Limits'))[1]
    427434        inst,inst2 = G2frame.GPXtree.GetItemPyData(G2gd.GetGPXtreeItemId(G2frame,PatternId, 'Instrument Parameters'))
    428         profile = G2frame.GPXtree.GetItemPyData(PatternId)[1]
     435        Pattern = G2frame.GPXtree.GetItemPyData(PatternId)
     436        profile = Pattern[1]
     437        bxye = GetFileBackground(G2frame,profile,Pattern)
    429438        x0 = profile[0]
    430439        iBeg = np.searchsorted(x0,limits[0])
    431440        iFin = np.searchsorted(x0,limits[1])
    432441        x = x0[iBeg:iFin]
    433         y0 = profile[1][iBeg:iFin]
     442        y0 = (profile[1]+bxye)[iBeg:iFin]
    434443        ysig = 1.0*np.std(y0)
    435444        offset = [-1,1]
     
    567576                limits = G2frame.GPXtree.GetItemPyData(G2gd.GetGPXtreeItemId(G2frame,PatternId, 'Limits'))[1]
    568577                inst,inst2 = G2frame.GPXtree.GetItemPyData(G2gd.GetGPXtreeItemId(G2frame,PatternId, 'Instrument Parameters'))
    569                 data = G2frame.GPXtree.GetItemPyData(PatternId)[1]
     578                Pattern = G2frame.GPXtree.GetItemPyData(PatternId)
     579                data = Pattern[1]
     580                fixback = GetFileBackground(G2frame,data,Pattern)
    570581                peaks['sigDict'],result,sig,Rvals,varyList,parmDict,fullvaryList,badVary = G2pwd.DoPeakFit(FitPgm,peaks['peaks'],
    571                     background,limits,inst,inst2,data,prevVaryList,oneCycle,controls)
     582                    background,limits,inst,inst2,data,fixback,prevVaryList,oneCycle,controls)
    572583                if len(result[0]) != len(fullvaryList):
    573584                    dlg.Destroy()
     
    611622        limits = G2frame.GPXtree.GetItemPyData(G2gd.GetGPXtreeItemId(G2frame,PatternId, 'Limits'))[1]
    612623        inst,inst2 = G2frame.GPXtree.GetItemPyData(G2gd.GetGPXtreeItemId(G2frame,PatternId, 'Instrument Parameters'))
    613         data = G2frame.GPXtree.GetItemPyData(PatternId)[1]
     624        Pattern = G2frame.GPXtree.GetItemPyData(PatternId)
     625        data = Pattern[1]
     626        bxye = GetFileBackground(G2frame,data,Pattern)
    614627        dlg = wx.ProgressDialog('Residual','Peak fit Rwp = ',101.0,
    615628            style = wx.PD_ELAPSED_TIME|wx.PD_AUTO_HIDE|wx.PD_REMAINING_TIME|wx.PD_CAN_ABORT)
     
    620633            dlg.SetPosition(wx.Point(screenSize[2]-Size[0]-305,screenSize[1]+5))
    621634        try:
    622             peaks['sigDict'] = G2pwd.DoPeakFit(FitPgm,peaks['peaks'],background,limits,inst,inst2,data,[],oneCycle,controls,dlg)[0]
     635            peaks['sigDict'] = G2pwd.DoPeakFit(FitPgm,peaks['peaks'],background,limits,inst,inst2,data,bxye,[],oneCycle,controls,dlg)[0]
    623636        finally:
    624637            print 'finished'
     
    933946            Id = G2gd.GetGPXtreeItemId(G2frame,G2frame.root,item)
    934947            G2frame.GPXtree.SetItemPyData(
    935                 G2gd.GetGPXtreeItemId(G2frame,Id,'Background'),copy.copy(data))
     948                G2gd.GetGPXtreeItemId(G2frame,Id,'Background'),copy.deepcopy(data))
    936949
    937950    def OnBkgFit(event):
     
    12311244            peaksSizer.Add(peaksGrid)       
    12321245        return peaksSizer
     1246   
     1247    def BackFileSizer():
     1248       
     1249        def OnBackPWDR(event):
     1250            data[1]['background PWDR'][0] = back.GetValue()
     1251            G2plt.PlotPatterns(G2frame,plotType='PWDR')
     1252       
     1253        fileSizer = wx.BoxSizer(wx.VERTICAL)
     1254        fileSizer.Add(wx.StaticText(G2frame.dataWindow,-1,' Fixed background file:'),0,WACV)
     1255        if 'background PWDR' not in data[1]:
     1256            data[1]['background PWDR'] = ['',-1.]
     1257        backSizer = wx.BoxSizer(wx.HORIZONTAL)
     1258        Choices = ['',]+G2gd.GetGPXtreeDataNames(G2frame,['PWDR',])
     1259        Source = G2frame.GPXtree.GetItemText(G2frame.PatternId)
     1260        Choices.pop(Choices.index(Source))
     1261        back = wx.ComboBox(parent=G2frame.dataWindow,value=data[1]['background PWDR'][0],choices=Choices,
     1262            style=wx.CB_READONLY|wx.CB_DROPDOWN)
     1263        back.Bind(wx.EVT_COMBOBOX,OnBackPWDR)
     1264        backSizer.Add(back)
     1265        backSizer.Add(wx.StaticText(G2frame.dataWindow,-1,' multiplier'),0,WACV)
     1266        backMult = G2G.ValidatedTxtCtrl(G2frame.dataWindow,data[1]['background PWDR'],1,nDig=(10,3))
     1267        backSizer.Add(backMult,0,WACV)
     1268        fileSizer.Add(backSizer)
     1269        return fileSizer
    12331270
    12341271    # UpdateBackground execution starts here
     
    12541291    mainSizer.Add((0,5),0)
    12551292    mainSizer.Add(PeaksSizer())
     1293    mainSizer.Add((0,5),0)
     1294    mainSizer.Add(BackFileSizer())
    12561295    G2frame.dataWindow.SetDataSize()
    12571296       
Note: See TracChangeset for help on using the changeset viewer.