Changeset 4065


Ignore:
Timestamp:
Jul 17, 2019 11:48:22 AM (4 years ago)
Author:
vondreele
Message:

background plotting stuff (incomplete)

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIplot.py

    r4062 r4065  
    18461846        elif event.key == 'b':
    18471847            G2frame.SubBack = not G2frame.SubBack
    1848             if not G2frame.SubBack:
    1849                 G2frame.SinglePlot = True               
     1848#            if not G2frame.SubBack:
     1849#                G2frame.SinglePlot = True               
    18501850        elif event.key == 'n':
    18511851            if G2frame.Contour:
     
    28112811    DifLine = ['']
    28122812    if G2frame.Contour:
    2813         Page.Choice = (' key press',
     2813        Page.Choice = (' key press','b: toggle subtract background',
    28142814            'd: lower contour max','u: raise contour max',
    28152815            'D: lower contour min','U: raise contour min',
     
    29502950    elif Page.plotStyle.get('WgtDiagnostic',False):
    29512951        Title = 'Scaling diagnostic for '+Title
     2952    if G2frame.SubBack:
     2953        Title += ' - background'
    29522954    if Page.plotStyle['qPlot'] or plottype in ['SASD','REFD'] and not G2frame.Contour:
    29532955        xLabel = r'$Q, \AA^{-1}$'
     
    30873089            multArray = ma.getdata(multArray)
    30883090        if 'PWDR' in plottype:
     3091            YI = xye[1]
     3092            if G2frame.SubBack:
     3093                YI -= xye[5]
    30893094            if Page.plotStyle['sqrtPlot']:
    30903095                olderr = np.seterr(invalid='ignore') #get around sqrt(-ve) error
    3091                 Y = np.where(xye[1]>=0.,np.sqrt(xye[1]),-np.sqrt(-xye[1]))+NoffY*Ymax/100.0
     3096                Y = np.where(YI>=0.,np.sqrt(YI),-np.sqrt(-YI))+NoffY*Ymax/100.0
    30923097                np.seterr(invalid=olderr['invalid'])
    30933098            elif Page.plotStyle.get('WgtDiagnostic',False):
    30943099                Y = xye[1]*xye[2]
    3095             elif 'PWDR' in plottype and G2frame.SinglePlot and not (
    3096                 Page.plotStyle['logPlot'] or Page.plotStyle['sqrtPlot'] or G2frame.Contour):
    3097                 Y = xye[1]*multArray+NoffY*Ymax/100.0
     3100            elif 'PWDR' in plottype and G2frame.SinglePlot and not \
     3101                (Page.plotStyle['logPlot'] or Page.plotStyle['sqrtPlot'] or G2frame.Contour):
     3102                Y = YI*multArray+NoffY*Ymax/100.0
    30983103            else:
    3099                 Y = xye[1]+NoffY*Ymax/100.0
     3104                Y = YI+NoffY*Ymax/100.0
    31003105        elif plottype in ['SASD','REFD']:
    31013106            if plottype == 'SASD':
     
    31233128            if lenX == len(X):
    31243129                ContourY.append(N)
    3125                 ContourZ.append(Y)
     3130                if G2frame.SubBack:
     3131                    ContourZ.append(Y)
     3132                else:
     3133                    ContourZ.append(Y)
    31263134                if 'C' in ParmList[0]['Type'][0]:       
    31273135                    ContourX = X
  • trunk/GSASIIpwdGUI.py

    r4064 r4065  
    11951195            G2frame.GPXtree.SetItemPyData(
    11961196                G2gd.GetGPXtreeItemId(G2frame,Id,'Background'),copy.deepcopy(data))
     1197            CalcBack(Id)
    11971198           
    11981199    def OnBackSave(event):
     
    12541255        finally:
    12551256            dlg.Destroy()
     1257        CalcBack(G2frame.PatternId)
    12561258        G2plt.PlotPatterns(G2frame,plotType='PWDR')
    12571259        wx.CallLater(100,UpdateBackground,G2frame,newback)
     
    14091411        def AfterChange(invalid,value,tc):
    14101412            if invalid: return
    1411             CalcBack()
     1413            CalcBack(G2frame.PatternId)
    14121414            G2plt.PlotPatterns(G2frame,plotType='PWDR')
    14131415           
     
    14541456                    del(data[1]['debyeTerms'][-1])
    14551457            if N == 0:
    1456                 CalcBack()
     1458                CalcBack(G2frame.PatternId)
    14571459                G2plt.PlotPatterns(G2frame,plotType='PWDR')               
    14581460            wx.CallAfter(UpdateBackground,G2frame,data)
     
    14771479       
    14781480        def OnCellChange(event):
    1479             CalcBack()
     1481            CalcBack(G2frame.PatternId)
    14801482            G2plt.PlotPatterns(G2frame,plotType='PWDR')               
    14811483
     
    15201522                    del(data[1]['peaksList'][-1])
    15211523            if N == 0:
    1522                 CalcBack()
     1524                CalcBack(G2frame.PatternId)
    15231525                G2plt.PlotPatterns(G2frame,plotType='PWDR')               
    15241526            wx.CallAfter(UpdateBackground,G2frame,data)
     
    15431545                           
    15441546        def OnCellChange(event):
    1545             CalcBack()
     1547            CalcBack(G2frame.PatternId)
    15461548            G2plt.PlotPatterns(G2frame,plotType='PWDR')               
    15471549
     
    16191621        return fileSizer
    16201622   
    1621     def CalcBack():
    1622             PatternId = G2frame.PatternId
     1623    def CalcBack(PatternId=G2frame.PatternId):
    16231624            limits = G2frame.GPXtree.GetItemPyData(G2gd.GetGPXtreeItemId(G2frame,PatternId, 'Limits'))[1]
    16241625            inst,inst2 = G2frame.GPXtree.GetItemPyData(G2gd.GetGPXtreeItemId(G2frame,PatternId, 'Instrument Parameters'))
     1626            backData = G2frame.GPXtree.GetItemPyData(G2gd.GetGPXtreeItemId(G2frame,PatternId, 'Background'))
    16251627            dataType = inst['Type'][0]
    16261628            insDict = {inskey:inst[inskey][1] for inskey in inst}
     
    16291631            parmDict.update(bakDict)
    16301632            parmDict.update(insDict)
    1631             limits = G2frame.GPXtree.GetItemPyData(G2gd.GetGPXtreeItemId(G2frame,PatternId, 'Limits'))[1]
    1632             pwddata = G2frame.GPXtree.GetItemPyData(PatternId)[1]
    1633             xBeg = np.searchsorted(pwddata[0],limits[0])
    1634             xFin = np.searchsorted(pwddata[0],limits[1])
    1635             fixBack = data[1]['background PWDR']
    1636             Id = G2gd.GetGPXtreeItemId(G2frame,G2frame.root,data[1]['background PWDR'][0])
     1633            pwddata = G2frame.GPXtree.GetItemPyData(PatternId)
     1634            xBeg = np.searchsorted(pwddata[1][0],limits[0])
     1635            xFin = np.searchsorted(pwddata[1][0],limits[1])
     1636            fixBack = backData[1]['background PWDR']
     1637            Id = G2gd.GetGPXtreeItemId(G2frame,G2frame.root,fixBack[0])
    16371638            fixData = G2frame.GPXtree.GetItemPyData(Id)
    16381639            fixedBkg = {'_fixedVary':False,'_fixedMult':fixBack[1],'_fixedValues':fixData[1][1][xBeg:xFin]}
    16391640            try:    #typically bad grid value
    1640                 pwddata[4][xBeg:xFin] = G2pwd.getBackground('',parmDict,bakType,dataType,pwddata[0][xBeg:xFin],fixedBkg)[0]
     1641                pwddata[1][4][xBeg:xFin] = G2pwd.getBackground('',parmDict,bakType,dataType,pwddata[1][0][xBeg:xFin],fixedBkg)[0]
    16411642            except:
    16421643                pass
Note: See TracChangeset for help on using the changeset viewer.