Changeset 1715


Ignore:
Timestamp:
Mar 16, 2015 2:17:24 PM (9 years ago)
Author:
vondreele
Message:

make plot styles global instead of individual; now qplot, dplot work for multiplots

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASII.py

    r1713 r1715  
    20972097        self.undofile = ''
    20982098        self.TreeItemDelete = False
    2099 #        self.Offset = [0.0,0.0]
    2100 #        self.delOffset = .02
    2101 #        self.refOffset = -1.0
    2102 #        self.refDelt = .01
     2099        self.plotStyle = {'qPlot':False,'dPlot':False,'sqrtPlot':False}
    21032100        self.Weight = False
    21042101        self.IfPlot = False
  • trunk/GSASIIplot.py

    r1694 r1715  
    955955    if 'Offset' not in data[0] and plotType in ['PWDR','SASD']:     #plot offset data
    956956        data[0].update({'Offset':[0.0,0.0],'delOffset':0.02,'refOffset':-1.0,
    957             'refDelt':0.01,'qPlot':False,'dPlot':False,'sqrtPlot':False})
     957            'refDelt':0.01,})
    958958        G2frame.PatternTree.SetItemPyData(G2frame.PickId,data)
    959959#end patch
     
    996996                dlg.Destroy()
    997997            elif G2frame.SinglePlot:
    998                 Pattern[0]['sqrtPlot'] = not Pattern[0]['sqrtPlot']
    999                 if Pattern[0]['sqrtPlot']:
     998                G2frame.plotStyle['sqrtPlot'] = not G2frame.plotStyle['sqrtPlot']
     999                if G2frame.plotStyle['sqrtPlot']:
    10001000                    Pattern[0]['delOffset'] = .002
    10011001                    Pattern[0]['refOffset'] = -1.0
     
    10341034            if 'PWDR' in plottype:
    10351035                newPlot = True
    1036                 Pattern[0]['qPlot'] = not Pattern[0]['qPlot']
    1037                 Pattern[0]['dPlot'] = False
     1036                G2frame.plotStyle['qPlot'] = not G2frame.plotStyle['qPlot']
     1037                G2frame.plotStyle['dPlot'] = False
    10381038            elif 'SASD' in plottype:
    10391039                newPlot = True
    1040                 G2frame.sqPlot = not G2frame.sqPlot
     1040                G2frame.plotStyle['sqPlot'] = not G2frame.plotStyle['sqPlot']
    10411041        elif event.key == 't' and 'PWDR' in plottype:
    1042             Pattern[0]['dPlot'] = not Pattern[0]['dPlot']
    1043             Pattern[0]['qPlot'] = False
     1042            G2frame.plotStyle['dPlot'] = not G2frame.plotStyle['dPlot']
     1043            G2frame.plotStyle['qPlot'] = False
    10441044            newPlot = True     
    10451045        elif event.key == 'm':
    1046             Pattern[0]['sqrtPlot'] = False
     1046            G2frame.plotStyle['sqrtPlot'] = False
    10471047            G2frame.SinglePlot = not G2frame.SinglePlot               
    10481048            newPlot = True
     
    10741074            try:
    10751075                Parms,Parms2 = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,G2frame.PatternId, 'Instrument Parameters'))
    1076                 if Pattern[0]['qPlot'] and 'PWDR' in plottype:
     1076                if G2frame.plotStyle['qPlot'] and 'PWDR' in plottype:
    10771077                    q = xpos
    10781078                    dsp = 2.*np.pi/q
     
    10841084                    q = xpos
    10851085                    dsp = 2.*np.pi/q
    1086                 elif Pattern[0]['dPlot']:
     1086                elif G2frame.plotStyle['dPlot']:
    10871087                    dsp = xpos
    10881088                    q = 2.*np.pi/dsp
     
    11031103                    if 'C' in Parms['Type'][0]:
    11041104                        if 'PWDR' in plottype:
    1105                             if Pattern[0]['sqrtPlot']:
     1105                            if G2frame.plotStyle['sqrtPlot']:
    11061106                                G2frame.G2plotNB.status.SetStatusText('2-theta =%9.3f d =%9.5f q = %9.5f sqrt(Intensity) =%9.2f'%(xpos,dsp,q,ypos),1)
    11071107                            else:
     
    11101110                            G2frame.G2plotNB.status.SetStatusText('q =%12.5g Intensity =%12.5g d =%9.1f'%(q,ypos,dsp),1)
    11111111                    else:
    1112                         if Pattern[0]['sqrtPlot']:
     1112                        if G2frame.plotStyle['sqrtPlot']:
    11131113                            G2frame.G2plotNB.status.SetStatusText('TOF =%9.3f d =%9.5f q =%9.5f sqrt(Intensity) =%9.2f'%(xpos,dsp,q,ypos),1)
    11141114                        else:
     
    11611161            if ind.all() != [0] and ObsLine[0].get_label() in str(pick):                                    #picked a data point
    11621162                data = G2frame.PatternTree.GetItemPyData(G2frame.PickId)
    1163                 if Pattern[0]['qPlot']:                              #qplot - convert back to 2-theta
     1163                if G2frame.plotStyle['qPlot']:                              #qplot - convert back to 2-theta
    11641164                    xy[0] = G2lat.Dsp2pos(Parms,2*np.pi/xy[0])
    1165                 elif Pattern[0]['dPlot']:                            #dplot - convert back to 2-theta
     1165                elif G2frame.plotStyle['dPlot']:                            #dplot - convert back to 2-theta
    11661166                    xy[0] = G2lat.Dsp2pos(Parms,xy[0])
    11671167                XY = G2mth.setPeakparms(Parms,Parms2,xy[0],xy[1])
     
    11761176                LimitId = G2gd.GetPatternTreeItemId(G2frame,PatternId, 'Limits')
    11771177                data = G2frame.PatternTree.GetItemPyData(LimitId)
    1178                 if Pattern[0]['qPlot']:                              #qplot - convert back to 2-theta
     1178                if G2frame.plotStyle['qPlot']:                              #qplot - convert back to 2-theta
    11791179                    xy[0] = G2lat.Dsp2pos(Parms,2*np.pi/xy[0])
    1180                 elif Pattern[0]['dPlot']:                            #dplot - convert back to 2-theta
     1180                elif G2frame.plotStyle['dPlot']:                            #dplot - convert back to 2-theta
    11811181                    xy[0] = G2lat.Dsp2pos(Parms,xy[0])
    11821182                if G2frame.ifGetExclude:
     
    12391239                id = lineNo/2+1
    12401240                id2 = lineNo%2
    1241                 if Pattern[0]['qPlot'] and 'PWDR' in plottype:
     1241                if G2frame.plotStyle['qPlot'] and 'PWDR' in plottype:
    12421242                    data[id][id2] = G2lat.Dsp2pos(Parms,2.*np.pi/xpos)
    1243                 elif Pattern[0]['dPlot'] and 'PWDR' in plottype:
     1243                elif G2frame.plotStyle['dPlot'] and 'PWDR' in plottype:
    12441244                    data[id][id2] = G2lat.Dsp2pos(Parms,xpos)
    12451245                else:
     
    12581258                    del data['peaks'][lineNo-2]
    12591259                else:
    1260                     if Pattern[0]['qPlot']:
     1260                    if G2frame.plotStyle['qPlot']:
    12611261                        data['peaks'][lineNo-2][0] = G2lat.Dsp2pos(Parms,2.*np.pi/xpos)
    1262                     elif Pattern[0]['dPlot']:
     1262                    elif G2frame.plotStyle['dPlot']:
    12631263                        data['peaks'][lineNo-2][0] = G2lat.Dsp2pos(Parms,xpos)
    12641264                    else:
     
    14291429        Title = 'log('+Title+')'
    14301430    Plot.set_title(Title)
    1431     if Pattern[0]['qPlot'] or 'SASD' in plottype and not G2frame.Contour:
     1431    if G2frame.plotStyle['qPlot'] or 'SASD' in plottype and not G2frame.Contour:
    14321432        Plot.set_xlabel(r'$Q, \AA^{-1}$',fontsize=16)
    1433     elif Pattern[0]['dPlot'] and 'PWDR' in plottype and not G2frame.Contour:
     1433    elif G2frame.plotStyle['dPlot'] and 'PWDR' in plottype and not G2frame.Contour:
    14341434        Plot.set_xlabel(r'$d, \AA$',fontsize=16)
    14351435    else:
     
    14491449        if 'C' in ParmList[0]['Type'][0]:
    14501450            if 'PWDR' in plottype:
    1451                 if Pattern[0]['sqrtPlot']:
     1451                if G2frame.plotStyle['sqrtPlot']:
    14521452                    Plot.set_ylabel(r'$\sqrt{Intensity}$',fontsize=16)
    14531453                else:
     
    14591459                    Plot.set_ylabel(r'$Intensity, cm^{-1}$',fontsize=16)
    14601460        else:
    1461             if Pattern[0]['sqrtPlot']:
     1461            if G2frame.plotStyle['sqrtPlot']:
    14621462                Plot.set_ylabel(r'$\sqrt{Normalized\ intensity}$',fontsize=16)
    14631463            else:
     
    14861486            for excl in excls:
    14871487                xye[0] = ma.masked_inside(xye[0],excl[0],excl[1])
    1488         if Pattern[0]['qPlot'] and 'PWDR' in plottype:
     1488        if G2frame.plotStyle['qPlot'] and 'PWDR' in plottype:
    14891489            Id = G2gd.GetPatternTreeItemId(G2frame,G2frame.root, Pattern[2])
    14901490            X = 2.*np.pi/G2lat.Pos2dsp(Parms,xye[0])
    1491         elif Pattern[0]['dPlot'] and 'PWDR' in plottype:
     1491        elif G2frame.plotStyle['dPlot'] and 'PWDR' in plottype:
    14921492            Id = G2gd.GetPatternTreeItemId(G2frame,G2frame.root, Pattern[2])
    14931493            X = G2lat.Pos2dsp(Parms,xye[0])
     
    14971497            lenX = len(X)
    14981498        if 'PWDR' in plottype:
    1499             if Pattern[0]['sqrtPlot']:
     1499            if G2frame.plotStyle['sqrtPlot']:
    15001500                olderr = np.seterr(invalid='ignore') #get around sqrt(-ve) error
    15011501                Y = np.where(xye[1]>=0.,np.sqrt(xye[1]),-np.sqrt(-xye[1]))
     
    15121512            limits = np.array(G2frame.PatternTree.GetItemPyData(LimitId))
    15131513            lims = limits[1]
    1514             if Pattern[0]['qPlot'] and 'PWDR' in plottype:
     1514            if G2frame.plotStyle['qPlot'] and 'PWDR' in plottype:
    15151515                lims = 2.*np.pi/G2lat.Pos2dsp(Parms,lims)
    1516             elif Pattern[0]['dPlot'] and 'PWDR' in plottype:
     1516            elif G2frame.plotStyle['dPlot'] and 'PWDR' in plottype:
    15171517                lims = G2lat.Pos2dsp(Parms,lims)
    15181518            Lines.append(Plot.axvline(lims[0],color='g',dashes=(5,5),picker=3.))   
     
    15401540            DifLine = ['']
    15411541            if ifpicked:
    1542                 if Pattern[0]['sqrtPlot']:
     1542                if G2frame.plotStyle['sqrtPlot']:
    15431543                    olderr = np.seterr(invalid='ignore') #get around sqrt(-ve) error
    15441544                    Z = np.where(xye[3]>=0.,np.sqrt(xye[3]),-np.sqrt(-xye[3]))
     
    15471547                    Z = xye[3]+offsetY*N*Ymax/100.0
    15481548                if 'PWDR' in plottype:
    1549                     if Pattern[0]['sqrtPlot']:
     1549                    if G2frame.plotStyle['sqrtPlot']:
    15501550                        olderr = np.seterr(invalid='ignore') #get around sqrt(-ve) error
    15511551                        W = np.where(xye[4]>=0.,np.sqrt(xye[4]),-np.sqrt(-xye[4]))
     
    16361636                    data = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,PatternId, 'Peak List'))
    16371637                    for item in data['peaks']:
    1638                         if Pattern[0]['qPlot']:
     1638                        if G2frame.plotStyle['qPlot']:
    16391639                            Lines.append(Plot.axvline(2.*np.pi/G2lat.Pos2dsp(Parms,item[0]),color=colors[N%6],picker=2.))
    1640                         elif Pattern[0]['dPlot']:
     1640                        elif G2frame.plotStyle['dPlot']:
    16411641                            Lines.append(Plot.axvline(G2lat.Pos2dsp(Parms,item[0]),color=colors[N%6],picker=2.))
    16421642                        else:
     
    16691669            for peak in peaks[0]:
    16701670                if peak[2]:
    1671                     if Pattern[0]['qPlot']:
     1671                    if G2frame.plotStyle['qPlot']:
    16721672                        Plot.axvline(2.*np.pi/G2lat.Pos2dsp(Parms,peak[0]),color='b')
    1673                     if Pattern[0]['dPlot']:
     1673                    if G2frame.plotStyle['dPlot']:
    16741674                        Plot.axvline(G2lat.Pos2dsp(Parms,peak[0]),color='b')
    16751675                    else:
     
    16791679                if len(hkl) > 6 and hkl[3]:
    16801680                    clr = 'g'
    1681                 if Pattern[0]['qPlot']:
     1681                if G2frame.plotStyle['qPlot']:
    16821682                    Plot.axvline(2.*np.pi/G2lat.Pos2dsp(Parms,hkl[-2]),color=clr,dashes=(5,5))
    1683                 if Pattern[0]['dPlot']:
     1683                if G2frame.plotStyle['dPlot']:
    16841684                    Plot.axvline(G2lat.Pos2dsp(Parms,hkl[-2]),color=clr,dashes=(5,5))
    16851685                else:
     
    17011701                    peak = np.array([[peak[4],peak[5]] for peak in peaks])
    17021702                pos = Pattern[0]['refOffset']-pId*Ymax*Pattern[0]['refDelt']*np.ones_like(peak)
    1703                 if Pattern[0]['qPlot']:
     1703                if G2frame.plotStyle['qPlot']:
    17041704                    Plot.plot(2*np.pi/peak.T[0],pos,refColors[pId%6]+'|',mew=1,ms=8,picker=3.,label=phase)
    1705                 elif Pattern[0]['dPlot']:
     1705                elif G2frame.plotStyle['dPlot']:
    17061706                    Plot.plot(peak.T[0],pos,refColors[pId%6]+'|',mew=1,ms=8,picker=3.,label=phase)
    17071707                else:
  • trunk/GSASIIspc.py

    r1709 r1715  
    16681668                    CSI['Sadp'][0][i+6] = [0,0,0]
    16691669                    CSI['Sadp'][1][i+6] = [0.,0.,0.]
    1670         else:
    1671                        
     1670        else:                       
    16721671            for i in range(6):
    16731672                if np.allclose(dU[i,i,:],dUT[i,i,:]*sdet):
Note: See TracChangeset for help on using the changeset viewer.