Changeset 1205 for trunk/GSASIIplot.py


Ignore:
Timestamp:
Jan 23, 2014 3:15:51 PM (9 years ago)
Author:
vondreele
Message:

Add models to SASD data tree
Add error bar plotting to SASD data
Add I*Q4 option to log SASD data
got rid of the if, else blocks for all key driven toggles in G2plot

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIplot.py

    r1204 r1205  
    401401        newPlot = False
    402402        if event.key == 'w' and 'PWDR' in plottype:
    403             if G2frame.Weight:
    404                 G2frame.Weight = False
    405             else:
    406                 G2frame.Weight = True
     403            G2frame.ErrorBars = not G2frame.ErrorBars
     404            if not G2frame.Weight:
    407405                G2frame.SinglePlot = True
    408406            newPlot = True
     407        elif event.key == 'e' and 'SASD' in plottype:
     408            G2frame.ErrorBars = not G2frame.ErrorBars
    409409        elif event.key == 'b' and 'PWDR' in plottype:
    410             if G2frame.SubBack:
    411                 G2frame.SubBack = False
    412             else:
    413                 G2frame.SubBack = True
     410            G2frame.SubBack = not G2frame.SubBack
     411            if not G2frame.SubBack:
    414412                G2frame.SinglePlot = True               
    415413        elif event.key == 'n':
     
    417415                pass
    418416            else:
    419                 if G2frame.logPlot:
    420                     G2frame.logPlot = False
    421                 else:
     417                G2frame.logPlot = not G2frame.logPlot
     418                if not G2frame.logPlot:
    422419                    G2frame.Offset[0] = 0
    423                     G2frame.logPlot = True
    424420                newPlot = True
    425421        elif event.key == 'u':
    426422            if G2frame.Contour:
    427423                G2frame.Cmax = min(1.0,G2frame.Cmax*1.2)
    428             elif G2frame.logPlot:
    429                 pass
    430424            elif G2frame.Offset[0] < 100.:
    431425                G2frame.Offset[0] += 1.
     
    433427            if G2frame.Contour:
    434428                G2frame.Cmax = max(0.0,G2frame.Cmax*0.8)
    435             elif G2frame.logPlot:
    436                 pass
    437429            elif G2frame.Offset[0] > 0.:
    438430                G2frame.Offset[0] -= 1.
     
    442434            G2frame.Offset[1] += 1.
    443435        elif event.key == 'o':
     436            G2frame.Cmax = 1.0
    444437            G2frame.Offset = [0,0]
    445438        elif event.key == 'c':
    446439            newPlot = True
    447             if G2frame.Contour:
    448                 G2frame.Contour = False
    449             else:
    450                 G2frame.Contour = True
     440            G2frame.Contour = not G2frame.Contour
     441            if not G2frame.Contour:
    451442                G2frame.SinglePlot = False
    452443                G2frame.Offset = [0.,0.]
    453         elif event.key == 'q' and 'PWDR' in plottype:
    454             newPlot = True
    455             if G2frame.qPlot:
    456                 G2frame.qPlot = False
    457             else:
    458                 G2frame.qPlot = True
     444        elif event.key == 'q':
     445            if 'PWDR' in plottype:
     446                newPlot = True
     447                G2frame.qPlot = not G2frame.qPlot
     448            elif 'SASD' in plottype:
     449                newPlot = True
     450                G2frame.sqPlot = not G2frame.sqPlot       
    459451        elif event.key == 's':
    460452            if G2frame.Contour:
     
    468460                    G2frame.ContourColor = 'Paired'
    469461                dlg.Destroy()
    470             else:               
    471                 if G2frame.SinglePlot:
    472                     G2frame.SinglePlot = False
    473                 else:
    474                     G2frame.SinglePlot = True
     462            else:
     463                G2frame.SinglePlot = not G2frame.SinglePlot               
    475464            newPlot = True
    476465        elif event.key == '+':
    477466            if G2frame.PickId:
    478467                G2frame.PickId = False
    479         elif event.key == 'i':                  #for smoothing contour plot
     468        elif event.key == 'i' and G2frame.Contour:                  #for smoothing contour plot
    480469            choice = ['nearest','bilinear','bicubic','spline16','spline36','hanning',
    481470               'hamming','hermite','kaiser','quadric','catrom','gaussian','bessel',
     
    690679    G2frame.G2plotNB.status.DestroyChildren()
    691680    if G2frame.Contour:
    692         Page.Choice = (' key press','d: lower contour max','u: raise contour max',
     681        Page.Choice = (' key press','d: lower contour max','u: raise contour max','o: reset contour max',
    693682            'i: interpolation method','s: color scheme','c: contour off')
    694683    else:
    695684        if G2frame.logPlot:
    696             Page.Choice = (' key press','n: log(I) off','l: offset left','r: offset right',
    697                 'c: contour on','q: toggle q plot','s: toggle single plot','+: no selection')
     685            if 'PWDR' in plottype:
     686                Page.Choice = (' key press','n: log(I) off','l: offset left','r: offset right','o: reset offset',
     687                    'c: contour on','q: toggle q plot','s: toggle single plot','+: no selection')
     688            elif 'SASD' in plottype:
     689                Page.Choice = (' key press','n: log(I) off','l: offset left','r: offset right',
     690                    'd: offset down','u: offset up','o: reset offset','q: toggle S(q) plot',
     691                    'c: contour on','s: toggle single plot','+: no selection')
    698692        else:
    699693            if 'PWDR' in plottype:
     
    702696                    'q: toggle q plot','s: toggle single plot','w: toggle divide by sig','+: no selection')
    703697            elif 'SASD' in plottype:
    704                 Page.Choice = (' key press','l: offset left','r: offset right','d: offset down',
     698                Page.Choice = (' key press','e: toggle error bars','l: offset left','r: offset right','d: offset down',
    705699                    'u: offset up','o: reset offset','n: log(I) on','c: contour on',
    706700                    's: toggle single plot','+: no selection')
     
    779773                Plot.set_ylabel('$Intensity$',fontsize=16)
    780774            elif 'SASD' in plottype:
    781                 Plot.set_ylabel('$Intensity, cm^{-1}$',fontsize=16)
     775                if G2frame.sqPlot:
     776                    Plot.set_ylabel('$S(Q)=I*Q^{4}$',fontsize=16)
     777                else:
     778                    Plot.set_ylabel('$Intensity, cm^{-1}$',fontsize=16)
    782779        else:
    783780            Plot.set_ylabel('Normalized intensity',fontsize=16)
     
    820817            Y = xye[1]+offset*N
    821818        elif 'SASD' in plottype:
    822             Y = xye[1]*Sample['Scale'][0]+offset*N
     819            if G2frame.logPlot:
     820                if G2frame.sqPlot:
     821                    Y = xye[1]*Sample['Scale'][0]*(1.005)**(offset*N)*X**4
     822                else:
     823                    Y = xye[1]*Sample['Scale'][0]*(1.005)**(offset*N)
     824            else:
     825                Y = xye[1]*Sample['Scale'][0]+offset*N
    823826        if LimitId and ifpicked:
    824827            limits = np.array(G2frame.PatternTree.GetItemPyData(LimitId))
     
    843846                Plot.set_ylabel('Data sequence',fontsize=12)
    844847        else:
    845             X += G2frame.Offset[1]*.005*N
     848            if 'SASD' in plottype and G2frame.logPlot:
     849                X *= (1.01)**(G2frame.Offset[1]*N)
     850            else:
     851                X += G2frame.Offset[1]*.005*N
    846852            Xum = ma.getdata(X)
    847853            if ifpicked:
     
    854860                if G2frame.logPlot:
    855861                    if 'PWDR' in plottype:
    856                         Plot.semilogy(X,Y,colors[N%6]+'+',picker=3.,clip_on=False,nonposy='mask')
    857                         Plot.semilogy(X,Z,colors[(N+1)%6],picker=False,nonposy='mask')
    858                         Plot.semilogy(X,W,colors[(N+2)%6],picker=False,nonposy='mask')
     862                        Plot.set_yscale("log",nonposy='mask')
     863                        Plot.plot(X,Y,colors[N%6]+'+',picker=3.,clip_on=False)
     864                        Plot.plot(X,Z,colors[(N+1)%6],picker=False)
     865                        Plot.plot(X,W,colors[(N+2)%6],picker=False)
    859866                    elif 'SASD' in plottype:
    860                         Plot.loglog(X,Y,colors[N%6]+'+',picker=3.,clip_on=False,nonposy='mask')
    861                         Plot.loglog(X,Z,colors[(N+1)%6],picker=False,nonposy='mask')
    862                 elif G2frame.Weight:
     867                        Plot.set_xscale("log",nonposx='mask')
     868                        Plot.set_yscale("log",nonposy='mask')
     869                        if G2frame.ErrorBars:
     870                            Plot.errorbar(X,Y,yerr=np.sqrt(1./xye[2]),ecolor=colors[N%6],picker=3.,clip_on=False)
     871                        else:
     872                            Plot.plot(X,Y,colors[N%6]+'+',picker=3.,clip_on=False)
     873                        Plot.plot(X,Z,colors[(N+1)%6],picker=False)
     874                elif G2frame.Weight and 'PWDR' in plottype:
    863875                    DY = xye[1]*np.sqrt(xye[2])
    864876                    DYmax = max(DY)
     
    10581070        elif event.key == 'c':
    10591071            newPlot = True
    1060             if G2frame.Contour:
    1061                 G2frame.Contour = False
    1062             else:
    1063                 G2frame.Contour = True
     1072            G2frame.Contour = not G2frame.Contour
     1073            if not G2frame.Contour:
    10641074                G2frame.SinglePlot = False
    10651075                G2frame.Offset = [0.,0.]
     
    10751085                    G2frame.ContourColor = 'Paired'
    10761086                dlg.Destroy()
    1077             else:               
    1078                 if G2frame.SinglePlot:
    1079                     G2frame.SinglePlot = False
    1080                 else:
    1081                     G2frame.SinglePlot = True
     1087            else:
     1088                G2frame.SinglePlot = not G2frame.SinglePlot               
    10821089        elif event.key == 'i':                  #for smoothing contour plot
    10831090            choice = ['nearest','bilinear','bicubic','spline16','spline36','hanning',
     
    10921099            dlg.Destroy()
    10931100        elif event.key == 't' and not G2frame.Contour:
    1094             if G2frame.Legend:
    1095                 G2frame.Legend = False
    1096             else:
    1097                 G2frame.Legend = True
     1101            G2frame.Legend = not G2frame.Legend
    10981102        PlotISFG(G2frame,newPlot=newPlot,type=type)
    10991103       
     
    21432147    def OnKeyPress(event):
    21442148        if event.key == 's' and sampleParm:
    2145             if G2frame.xAxis:
    2146                 G2frame.xAxis = False
    2147             else:
    2148                 G2frame.xAxis = True
     2149            G2frame.xAxis = not G2frame.xAxis
    21492150            Draw(False)
    21502151    try:
     
    23052306                G2frame.StrainKey = event.key
    23062307                OnStartNewDzero(G2frame)
    2307            
    23082308               
    23092309        elif PickName == 'Image Controls':
     
    23232323                    dlg.Destroy()
    23242324            elif event.key == 'l':
    2325                 if G2frame.logPlot:
    2326                     G2frame.logPlot = False
    2327                 else:
    2328                     G2frame.logPlot = True
     2325                G2frame.logPlot = not G2frame.logPlot
    23292326            elif event.key in ['x',]:
    2330                 if Data['invert_x']:
    2331                     Data['invert_x'] = False
    2332                 else:
    2333                     Data['invert_x'] = True
     2327                Data['invert_x'] = not Data['invert_x']
    23342328            elif event.key in ['y',]:
    2335                 if Data['invert_y']:
    2336                     Data['invert_y'] = False
    2337                 else:
    2338                     Data['invert_y'] = True
     2329                Data['invert_y'] = not Data['invert_y']
    23392330        PlotImage(G2frame,newPlot=False)
    23402331           
Note: See TracChangeset for help on using the changeset viewer.