Changeset 4870 for trunk


Ignore:
Timestamp:
Mar 31, 2021 7:19:27 PM (2 years ago)
Author:
toby
Message:

problem with limits applied to plotting of wrong histogram; add normalized plotting

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIplot.py

    r4858 r4870  
    21912191        elif event.key in ['+','=']:
    21922192            G2frame.plusPlot = not G2frame.plusPlot
     2193        elif event.key == '/':
     2194            Page.plotStyle['Normalize'] = not Page.plotStyle['Normalize']
    21932195        elif event.key == 'i' and G2frame.Contour:                  #for smoothing contour plot
    21942196            choice = ['nearest','bilinear','bicubic','spline16','spline36','hanning',
     
    29812983            'refDelt':0.1*Ymax,})
    29822984#end patch
     2985    if 'Normalize' not in Page.plotStyle:
     2986        Page.plotStyle['Normalize'] = False
    29832987    # reset plot when changing between different data types
    29842988    try:
     
    31303134                Page.Choice = Page.Choice+ \
    31313135                    ['u/U: offset up/10x','d/D: offset down/10x','l: offset left','r: offset right',
    3132                      'o: reset offset','f: select data',]
    3133            
     3136                     'o: reset offset','f: select data',
     3137                     '/: normalize']
    31343138        elif plottype in ['SASD','REFD']:
    31353139            Page.Choice = [' key press',
     
    31713175                G2frame.PatternId, 'Instrument Parameters'))
    31723176            Sample = G2frame.GPXtree.GetItemPyData(G2gd.GetGPXtreeItemId(G2frame,G2frame.PatternId, 'Sample Parameters'))
     3177            Limits = G2frame.GPXtree.GetItemPyData(G2gd.GetGPXtreeItemId(G2frame,G2frame.PatternId, 'Limits'))
    31733178            ParmList = [Parms,]
    31743179            SampleList = [Sample,]
     3180            LimitsList = [Limits,]
    31753181            Title = data[0].get('histTitle')
    31763182            if not Title:
     
    31873193        ParmList = []
    31883194        SampleList = []
     3195        LimitsList = []
    31893196        Temps = []
    31903197        # loop through tree looking for matching histograms to plot
     
    32103217            SampleList.append(G2frame.GPXtree.GetItemPyData(G2gd.GetGPXtreeItemId(G2frame,
    32113218                pid, 'Sample Parameters')))
     3219            LimitsList.append(G2frame.GPXtree.GetItemPyData(G2gd.GetGPXtreeItemId(G2frame,
     3220                pid, 'Limits')))
    32123221            Temps.append('%.1fK'%SampleList[-1]['Temperature'])
    32133222        if not G2frame.Contour:
     
    32153224            ParmList.reverse()
    32163225            SampleList.reverse()
     3226            LimitsList.reverse()
    32173227    if timeDebug:
    32183228        print('plot build time: %.3f for %dx%d patterns'%(time.time()-time0,len(PlotList[0][1][1]),len(PlotList)))
     
    32613271    else:
    32623272        Plot.set_xlabel(xLabel,fontsize=16)
    3263     if 'T' in ParmList[0]['Type'][0]:
     3273    if 'T' in ParmList[0]['Type'][0] or (Page.plotStyle['Normalize'] and not G2frame.SinglePlot):
    32643274        if Page.plotStyle['sqrtPlot']:
    32653275            Plot.set_ylabel(r'$\sqrt{Normalized\ intensity}$',fontsize=16)
     
    32963306        Parms = ParmList[N]
    32973307        Sample = SampleList[N]
     3308        limits = np.array(LimitsList[N])
    32983309        ifpicked = False
    3299         LimitId = 0
    33003310        NoffY = offsetY*(Nmax-N)
    33013311        if Pattern[1] is None: continue # skip over uncomputed simulations
     
    33043314        if PickId:
    33053315            ifpicked = Pattern[2] == G2frame.GPXtree.GetItemText(PatternId)
    3306             LimitId = G2gd.GetGPXtreeItemId(G2frame,G2frame.PatternId,'Limits')
    3307             limits = G2frame.GPXtree.GetItemPyData(LimitId)
    33083316            # recompute mask from excluded regions, in case they have changed
    33093317            excls = limits[2:]
     
    33993407            Y = ma.array(Y,mask=ma.getmask(X))
    34003408               
    3401         if LimitId and ifpicked:
    3402             limits = np.array(G2frame.GPXtree.GetItemPyData(LimitId))
     3409        #if LimitId and ifpicked:
     3410        #    limits = np.array(G2frame.GPXtree.GetItemPyData(LimitId))
     3411        if ifpicked:
    34033412            lims = limits[1]
    34043413            if Page.plotStyle['qPlot'] and 'PWDR' in plottype and not ifLimits:
     
    35603569                        Plot.plot(X,ZB,colors[2],picker=False,label=incCptn('calc'))
    35613570                else:  # not logPlot
     3571                    ymax = 1.
     3572                    if Page.plotStyle['Normalize'] and Y.max() != 0 and not G2frame.SinglePlot:
     3573                        ymax = Y.max()
    35623574                    if G2frame.SubBack:
    35633575                        if 'PWDR' in plottype:
    3564                             ObsLine = Plot.plot(Xum,Y,color=colors[0],marker=pP,
     3576                            ObsLine = Plot.plot(Xum,Y/ymax,color=colors[0],marker=pP,
    35653577                                picker=False,clip_on=Clip_on,label=incCptn('obs-bkg'))  #Io-Ib
    35663578                            if np.any(Z):       #only if there is a calc pattern
    3567                                 CalcLine = Plot.plot(X,Z-W,colors[1],picker=False,label=incCptn('calc-bkg'))               #Ic-Ib
     3579                                CalcLine = Plot.plot(X,(Z-W)/ymax,colors[1],picker=False,label=incCptn('calc-bkg'))               #Ic-Ib
    35683580                        else:
    35693581                            Plot.plot(X,YB,color=colors[0],marker=pP,
     
    35723584                    else:
    35733585                        if 'PWDR' in plottype:
    3574                             ObsLine = Plot.plot(Xum,Y,color=colors[0],marker=pP,
     3586                            ObsLine = Plot.plot(Xum,Y/ymax,color=colors[0],marker=pP,
    35753587                                picker=True,pickradius=3.,clip_on=Clip_on,label=incCptn('obs'))    #Io
    3576                             CalcLine = Plot.plot(X,Z,colors[1],picker=False,label=incCptn('calc'))                 #Ic
     3588                            CalcLine = Plot.plot(X,Z/ymax,colors[1],picker=False,label=incCptn('calc'))                 #Ic
    35773589                        else:
    35783590                            Plot.plot(X,YB,color=colors[0],marler=pP,
     
    35803592                            Plot.plot(X,ZB,colors[2],picker=False,label=incCptn('calc'))
    35813593                    if 'PWDR' in plottype and (G2frame.SinglePlot and G2frame.plusPlot):
    3582                         BackLine = Plot.plot(X,W,colors[2],picker=False,label=incCptn('bkg'))                 #Ib
     3594                        BackLine = Plot.plot(X,W/ymax,colors[2],picker=False,label=incCptn('bkg'))                 #Ib
    35833595                        if not G2frame.Weight and np.any(Z):
    3584                             DifLine = Plot.plot(X,D,colors[3],
     3596                            DifLine = Plot.plot(X,D/ymax,colors[3],
    35853597                                picker=True,pickradius=1.,label=incCptn('diff'))                 #Io-Ic
    35863598                    Plot.axhline(0.,color='k',label='_zero')
     
    36173629                       
    36183630            else:   #not picked
     3631                ymax = 1.
     3632                if Page.plotStyle['Normalize'] and Y.max() != 0:
     3633                    ymax = Y.max()
    36193634                icolor = 256*N//len(PlotList)
    36203635                if Page.plotStyle['logPlot']:
     
    36353650                else:
    36363651                    if 'PWDR' in plottype:
    3637                         Plot.plot(X,Y,color=mcolors.cmap(icolor),picker=False)
     3652                        Plot.plot(X,Y/ymax,color=mcolors.cmap(icolor),picker=False)
    36383653                    elif plottype in ['SASD','REFD']:
    36393654                        try:
Note: See TracChangeset for help on using the changeset viewer.