Changeset 5524


Ignore:
Timestamp:
Mar 26, 2023 9:26:51 PM (8 months ago)
Author:
toby
Message:

Add contour plot with non-equal steps

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIdataGUI.py

    r5504 r5524  
    31843184        self.itemPicked = None
    31853185        self.Interpolate = 'nearest'
    3186         self.ContourColor = GSASIIpath.GetConfigValue('Contour_color','Paired')
     3186        self.ContourColor = GSASIIpath.GetConfigValue('Contour_color','GSPaired')
    31873187        self.VcovColor = 'RdYlGn'
    31883188        self.RamaColor = 'Blues'
     
    78957895    if kind in ['PWDR','SASD','REFD',]:
    78967896        NewPlot = True
    7897         if 'xylim' in dir(G2frame):
     7897        if 'Contour' in dir(G2frame) and G2frame.Contour:
     7898            pass
     7899        elif 'xylim' in dir(G2frame):
    78987900            NewPlot = False
    78997901        G2plt.PlotPatterns(G2frame,plotType=kind,newPlot=NewPlot)
     
    82888290        #     print('reloading G2pdG')
    82898291        G2pdG.UpdatePeakGrid(G2frame,data)
    8290         G2plt.PlotPatterns(G2frame)
     8292        newPlot = False
     8293        if hasattr(G2frame,'Contour'):
     8294            if G2frame.Contour:
     8295                G2frame.Contour = False
     8296                newPlot = True
     8297        G2plt.PlotPatterns(G2frame,newPlot)
    82918298    elif G2frame.GPXtree.GetItemText(item) == 'Background':
    82928299        G2frame.PatternId = G2frame.GPXtree.GetItemParent(item)
    82938300        data = G2frame.GPXtree.GetItemPyData(item)
    82948301        G2pdG.UpdateBackground(G2frame,data)
    8295         G2plt.PlotPatterns(G2frame)
     8302        G2plt.PlotPatterns(G2frame,True)
    82968303    elif G2frame.GPXtree.GetItemText(item) == 'Limits':
    82978304        G2frame.PatternId = G2frame.GPXtree.GetItemParent(item)
     
    83368343   
    83378344        G2pdG.UpdateSampleGrid(G2frame,data)
    8338         G2plt.PlotPatterns(G2frame,plotType=datatype)
     8345        G2plt.PlotPatterns(G2frame,True,plotType=datatype)
    83398346    elif G2frame.GPXtree.GetItemText(item) == 'Index Peak List':
    83408347        G2frame.PatternId = G2frame.GPXtree.GetItemParent(item)
     
    83508357            G2plt.PlotPowderLines(G2frame)
    83518358        else:
    8352             G2plt.PlotPatterns(G2frame)
     8359            newPlot = False
     8360            if hasattr(G2frame,'Contour'):
     8361                if G2frame.Contour:
     8362                    G2frame.Contour = False
     8363                    newPlot = True
     8364            G2plt.PlotPatterns(G2frame,newPlot)
    83538365    elif G2frame.GPXtree.GetItemText(item) == 'Unit Cells List':
    83548366        G2frame.PatternId = G2frame.GPXtree.GetItemParent(item)
     
    83778389            G2plt.PlotPowderLines(G2frame)
    83788390        else:
     8391            newPlot = False
     8392            if hasattr(G2frame,'Contour'):
     8393                if G2frame.Contour:
     8394                    G2frame.Contour = False
     8395                    newPlot = True
     8396            G2plt.PlotPatterns(G2frame,newPlot)
    83798397            G2plt.PlotPatterns(G2frame)
    83808398    elif G2frame.GPXtree.GetItemText(item) == 'Reflection Lists':   #powder reflections
     
    83868404            G2frame.RefList = list(data.keys())[0]
    83878405        G2pdG.UpdateReflectionGrid(G2frame,data)
    8388         G2plt.PlotPatterns(G2frame)
     8406        newPlot = False
     8407        if hasattr(G2frame,'Contour'):
     8408            if G2frame.Contour:
     8409                G2frame.Contour = False
     8410                newPlot = True
     8411        G2plt.PlotPatterns(G2frame,newPlot)
    83898412    elif G2frame.GPXtree.GetItemText(item) == 'Reflection List':    #HKLF reflections
    83908413        G2frame.dataWindow.HideShow.Enable(True)
  • trunk/GSASIIplot.py

    r5522 r5524  
    3434:func:`PlotXYZ`               Simple contour plot of xyz data
    3535:func:`PlotXYZvect`           Quiver Plot for 3D cartesian vectors
    36 :func:`Plot3Dxyz`             Surface Plot for 3D vectors
     36:func:`Plot3dXYZ`             Surface Plot for 3D vectors
    3737:func:`PlotAAProb`            Protein "quality" plot
    3838:func:`PlotStrain`            Plot of strain data, used for diagnostic purposes
     
    5353:func:`PlotLayers`            show layer structures as balls & sticks
    5454:func:`PlotFPAconvolutors`    plots the convolutors from Fundamental Parameters
    55 :func:'PlotClusterYYZ'        plots the result of cluster analysis
     55:func:`PlotClusterXYZ`        plots the result of cluster analysis
    5656============================  ===========================================================================
    5757
     
    327327        self.toolbar.Realize()
    328328        self.plotStyle = {'qPlot':False,'dPlot':False,'sqrtPlot':False,'sqPlot':False,
    329             'logPlot':False,'exclude':False,'partials':True}
     329            'logPlot':False,'exclude':False,'partials':True,'chanPlot':False}
    330330       
    331331        sizer=wx.BoxSizer(wx.VERTICAL)
     
    11611161    RefreshPlot()
    11621162    dlg.ShowModal()
     1163
     1164def uneqImgShow(figure,ax,Xlist,Ylist,cmap,vmin,vmax,Ylbls=[]):
     1165    '''Plots a contour plot where point spacing varies within a dataset
     1166    and where the X values may differ between histograms. Note that
     1167    the length of Xlist and Ylist must be the same and will be the number
     1168    of histograms to be plotted
     1169
     1170    :param matplotlib.figure figure:
     1171        The figure where the plot will be placed.
     1172    :param matplotlib.axes ax:
     1173        The axes where the plot will be made.
     1174    :param list Xlist:
     1175        A list of X values for each histogram.
     1176    :param list Ylist:
     1177        A list of intensities for each histogram.
     1178    :param matplotlib.colormap cmap:
     1179        The colormap used for shading intensities.
     1180    :param float vmin:
     1181        Minimum intensity.
     1182    :param float vmax: float
     1183        Maximum intensity.
     1184    :param  list Ylbls: Optional.
     1185        Label to place on each histogram. The default is [] where the axes
     1186        are labeled normally with the first histogram numbered starting at 0.
     1187    '''
     1188    def midPoints(x):
     1189        '''Return the pixel corners for a series of steps
     1190        For the series [1,2,3,5] this will be [0.5,1.5,2.5,4,6]
     1191        Note that n+1 points are returned for input of n points
     1192        '''
     1193        return np.concatenate( [[1.5*x[0] - x[1]/2],
     1194                                (x[:-1]+x[1:])/2,
     1195                                [1.5*x[-1] - x[-2]/2]] )
     1196
     1197    lenX = len(Xlist)
     1198    if lenX != len(Ylist):
     1199        raise Exception("uneqImgShow error: unequal list lengths")
     1200    figure.subplots_adjust(right=.85)
     1201    #print('vmin,vmax',vmin,vmax)
     1202    meshlist = []
     1203    for i,(X,Y) in enumerate(zip(Xlist,Ylist)):
     1204        #print(i,'X',min(X),max(X),'Y',min(Y),max(Y))
     1205        meshlist.append(
     1206            ax.pcolormesh(midPoints(X), [i-0.5,i+0.5], Y[np.newaxis,:],
     1207                      cmap=cmap,vmin=vmin,vmax=vmax))
     1208    # label y axis with provided labels
     1209    if lenX == len(Ylbls):
     1210        pos =  np.arange(lenX)
     1211        ax.set_yticks(pos,Ylbls)
     1212    # add the colorbar
     1213    ax1 = figure.add_axes([0.87, 0.1, 0.04, 0.8])
     1214    mpl.colorbar.ColorbarBase(ax1, cmap=cmap, norm=mpl.colors.Normalize(vmin,vmax))
     1215    # does not plot grid lines at present
     1216    # if mpl.rcParams['axes.grid']
     1217   
    11631218#### PlotSngl ################################################################     
    11641219def PlotSngl(G2frame,newPlot=False,Data=None,hklRef=None,Title=''):
     
    20742129    G2frame.HKL = []  # array of generated reflections
    20752130    G2frame.Extinct = [] # array of extinct reflections
    2076     PlotPatterns(G2frame,newPlot,plotType)
     2131    PlotPatterns(G2frame,plotType=plotType)
    20772132
    20782133def plotVline(Page,Plot,Lines,Parms,pos,color,pick):
     
    21172172        elif G2frame.Weight:
    21182173            G2frame.Weight = False
    2119             PlotPatterns(G2frame,newPlot=newPlot,plotType=plottype,extraKeys=extraKeys)
     2174            PlotPatterns(G2frame,plotType=plottype,extraKeys=extraKeys)
    21202175            PublishRietveldPlot(G2frame,Pattern,Plot,Page)
    21212176            G2frame.Weight = True
    2122             PlotPatterns(G2frame,newPlot=newPlot,plotType=plottype,extraKeys=extraKeys)
     2177            PlotPatterns(G2frame,plotType=plottype,extraKeys=extraKeys)
    21232178            return
    21242179        else:
     
    22292284                G2frame.SinglePlot = True               
    22302285            G2frame.Contour = not G2frame.Contour
    2231             if G2frame.Contour:
    2232                 Page.plotStyle['qPlot'] = False
    2233                 Page.plotStyle['dPlot'] = False
    22342286        elif (event.key == 'p' and 'PWDR' in plottype and G2frame.SinglePlot):
    22352287            Page.plotStyle['partials'] = not Page.plotStyle['partials']
     
    22872339            if 'PWDR' in plottype:
    22882340                Page.plotStyle['qPlot'] = not Page.plotStyle['qPlot']
    2289                 if Page.plotStyle['qPlot']:
    2290                     G2frame.Contour = False
    22912341                Page.plotStyle['dPlot'] = False
     2342                Page.plotStyle['chanPlot'] = False
    22922343            elif plottype in ['SASD','REFD']:
    22932344                Page.plotStyle['sqPlot'] = not Page.plotStyle['sqPlot']
     2345        elif event.key == 'h' and G2frame.Contour:
     2346            newPlot = True
     2347            Page.plotStyle['qPlot'] = False
     2348            Page.plotStyle['dPlot'] = False
     2349            Page.plotStyle['chanPlot'] = not Page.plotStyle['chanPlot']
     2350        elif event.key == 'e' and G2frame.Contour:
     2351            newPlot = True
     2352            G2frame.TforYaxis = not G2frame.TforYaxis
    22942353        elif event.key == 't' and 'PWDR' in plottype and not ifLimits:
    2295             if G2frame.Contour:
    2296                 G2frame.TforYaxis = not G2frame.TforYaxis
    2297             else:
    2298                 Page.plotStyle['dPlot'] = not Page.plotStyle['dPlot']
    2299                 if Page.plotStyle['dPlot']:
    2300                     G2frame.Contour = False               
    2301                 Page.plotStyle['qPlot'] = False
    2302                 newPlot = True     
     2354            newPlot = True     
     2355            Page.plotStyle['dPlot'] = not Page.plotStyle['dPlot']
     2356            Page.plotStyle['qPlot'] = False
     2357            Page.plotStyle['chanPlot'] = False
    23032358        elif event.key == 'm':
    23042359            if not G2frame.Contour:               
     
    23482403       
    23492404    def OnMotion(event):
    2350         'Update the status line with info based on the mouse position'
     2405        'PlotPatterns: Update the status line with info based on the mouse position'
    23512406        global PlotList
    23522407        SetCursor(Page)
     
    24052460                    wave = G2mth.getWave(Parms)
    24062461                    dT = tolerance*wave*90./(np.pi**2*cosd(xpos/2))
     2462            elif Page.plotStyle['chanPlot'] and G2frame.Contour:
     2463                xpos = ma.getdata(X)[min(len(X)-1,int(xpos))]
     2464                try:
     2465                    dsp = G2lat.Pos2dsp(Parms,xpos)
     2466                    q = 2.*np.pi/dsp
     2467                except:
     2468                    dsp = -1
     2469                    q = -1
    24072470            elif plottype in ['SASD','REFD']:
    24082471                q = xpos
     
    24232486                    return               
    24242487                dT = tolerance*xpos/dsp
    2425             elif G2frame.Contour and 'T' in Parms['Type'][0]:
    2426                 xpos = X[int(xpos)]                   
    2427                 dsp = G2lat.Pos2dsp(Parms,xpos)
    2428                 q = 2.*np.pi/dsp
    24292488            else:
    24302489                dsp = G2lat.Pos2dsp(Parms,xpos)
     
    24332492            if G2frame.Contour: #PWDR only
    24342493                try:
     2494                    pNum = int(ypos+.5)
     2495                    indx = abs(PlotList[pNum][1][0] - xpos).argmin() # closest point to xpos
     2496                    val = 'int={:.3g}'.format(ma.getdata(PlotList[pNum][1][1])[indx])
    24352497                    if 'T' in Parms['Type'][0]:
    2436                         statLine = 'TOF =%9.3f d=%9.5f Q=%9.5f pattern ID =%5d, %s'%(xpos,dsp,q,int(ypos+.5),PlotList[int(ypos+.5)][-1])
     2498                        statLine = 'TOF=%.3f d=%.5f Q=%.5f %s pattern ID=%d, %s'%(xpos,dsp,q,val,pNum,PlotList[pNum][-1])
    24372499                    else:
    2438                         statLine = '2-theta =%9.3f d=%9.5f Q= %9.5f pattern ID =%5d, %s'%(xpos,dsp,q,int(ypos+.5),PlotList[int(ypos+.5)][-1])
     2500                        statLine = '2-theta=%.3f d=%.5f Q=%.5f %s pattern ID=%d, %s'%(xpos,dsp,q,val,pNum,PlotList[pNum][-1])
    24392501                except IndexError:
    24402502                    pass
     
    24522514                        if Page.plotStyle['sqrtPlot']:
    24532515                            ytmp = ypos**2
    2454                         statLine = '2-theta=%.3f d=%.5f Q=%.4f Intensity=%.2f'%(xpos,dsp,q,ypos)
     2516                        statLine = '2-theta=%.3f d=%.5f Q=%.4f Intensity=%.2f'%(xpos,dsp,q,ytmp)
    24552517                    elif plottype == 'SASD':
    24562518                        statLine = 'q =%12.5g Intensity =%12.5g d =%9.1f'%(q,ypos,dsp)
     
    32673329        Page.plotStyle['qPlot'] = False
    32683330        Page.plotStyle['dPlot'] = False
     3331    # keys in use for graphics control:
     3332    #    a,b,c,d,e,f,g,i,l,m,n,o,p,q,r,s,t,u,w,x, (unused: j, k, y, z)
     3333    #    also: +,/, C,D,S,U
    32693334    if G2frame.Contour:
    32703335        Page.Choice = (' key press','b: toggle subtract background',
     
    32733338            'o: reset contour limits','g: toggle grid',
    32743339            'i: interpolation method','S: color scheme','c: contour off',
    3275             't: temperature for y-axis','s: toggle sqrt plot',
     3340            'e: toggle temperature for y-axis','s: toggle sqrt plot',
     3341            'w: toggle w(Yo-Yc) contour plot','h: toggle channel # plot',
     3342            'q: toggle Q plot','t: toggle d-spacing plot',
    32763343            'C: contour plot control window',
    3277             'w: toggle w(Yo-Yc) contour plot'
    32783344            )
    32793345    else:
     
    32923358                        '+: toggle obs line plot']
    32933359            else:
    3294                 Page.Choice += ['q: toggle q plot','s: toggle sqrt plot',
    3295                     't: toggle d-spacing plot','w: toggle (Io-Ic)/sig plot',
    3296                     '+: toggle obs line plot']
     3360                Page.Choice += [
     3361                        'q: toggle Q plot','t: toggle d-spacing plot',
     3362                        's: toggle sqrt plot','w: toggle (Io-Ic)/sig plot',
     3363                        '+: toggle obs line plot']
    32973364            if Page.plotStyle['sqrtPlot'] or Page.plotStyle['logPlot']:
    32983365                del Page.Choice[1]
     
    33993466    if timeDebug:
    34003467        print('plot build time: %.3f for %dx%d patterns'%(time.time()-time0,len(PlotList[0][1][1]),len(PlotList)))
    3401     lenX = 0
     3468    lenX = 0  # length of first histogram, used for contour plots
    34023469    Ymax = None
    34033470    for ip,Pattern in enumerate(PlotList):
     
    34213488    if Page.plotStyle['qPlot'] or plottype in ['SASD','REFD'] and not G2frame.Contour and not ifLimits:
    34223489        xLabel = r'$Q, \AA^{-1}$'
    3423     elif Page.plotStyle['dPlot'] and 'PWDR' in plottype and not G2frame.Contour and not ifLimits:
     3490    elif Page.plotStyle['dPlot'] and 'PWDR' in plottype and not ifLimits:
    34243491        xLabel = r'$d, \AA$'
     3492    elif Page.plotStyle['chanPlot'] and G2frame.Contour:
     3493        xLabel = 'Channel no.'
    34253494    else:
    34263495        if 'T' in ParmList[0]['Type'][0]:
    3427             if G2frame.Contour:
    3428                 xLabel = r'Channel no.'
    3429             else:
    3430                 xLabel = r'$TOF, \mathsf{\mu}$s'
     3496            xLabel = r'$TOF, \mathsf{\mu}$s'
    34313497        elif 'E' in ParmList[0]['Type'][0]:
    34323498            xLabel = 'E, keV'
    34333499        else:
    34343500            xLabel = r'$\mathsf{2\theta}$'
     3501
    34353502    if G2frame.Weight and not G2frame.Contour:
    34363503        Plot.set_visible(False)         #hide old plot frame, will get replaced below
     
    34773544        ContourZ = []
    34783545        ContourY = []
     3546        ContourX = None
     3547        Xlist = []
     3548        X0 = None
    34793549        Nseq = 0
    34803550    Nmax = len(PlotList)-1
    34813551    time0 = time.time()
     3552    Plot.figure.subplots_adjust(right=.95)
     3553    if G2frame.Contour and G2frame.TforYaxis:
     3554        Plot.set_ylabel('Temperature',fontsize=14)
     3555    elif G2frame.Contour:
     3556        Plot.set_ylabel('Data sequence',fontsize=14)
     3557    unequalArrays = False # set to True for contour plots with unequal pixels
     3558    avgStep = None
     3559    if G2frame.Contour:  # detect unequally spaced points in a contour plot
     3560        for N,Pattern in enumerate(PlotList):
     3561            xye = np.array(ma.getdata(Pattern[1])) # strips mask = X,Yo,W,Yc,Yb,Yd
     3562            if Page.plotStyle['qPlot'] and 'PWDR' in plottype and not ifLimits:
     3563                X = 2.*np.pi/G2lat.Pos2dsp(Parms,xye[0])
     3564            elif Page.plotStyle['dPlot'] and 'PWDR' in plottype and not ifLimits:
     3565                X = G2lat.Pos2dsp(Parms,xye[0])
     3566            else:
     3567                X = copy.deepcopy(xye[0])
     3568            if not X0:   
     3569                X0 = X[0] # save 1st point in 1st pattern
     3570            elif abs(X0 - X[0]) > 0.05 * X0:
     3571                unequalArrays = True
     3572            if Page.plotStyle['qPlot'] or Page.plotStyle['dPlot']:  # not in original units
     3573                unequalArrays = True
     3574            elif 'T' in ParmList[0]['Type'][0] and not Page.plotStyle['chanPlot']: # assume TOF is non-linear steps
     3575                unequalArrays = True
     3576            # check to see if the average step size changes across the selected patterns
     3577            elif avgStep is None and not unequalArrays:
     3578                avgStep = (X[-1]-X[0])/(len(X)-1)
     3579            elif not unequalArrays and abs(avgStep - (X[-1]-X[0])/(len(X)-1)) > 0.05 * avgStep:
     3580                unequalArrays = True
     3581
     3582    ExMask = []
    34823583    for N,Pattern in enumerate(PlotList):
    34833584        Parms = ParmList[N]
     
    34883589        if Pattern[1] is None: continue # skip over uncomputed simulations
    34893590        xye = np.array(ma.getdata(Pattern[1])) # strips mask = X,Yo,W,Yc,Yb,Yd
    3490         xye0 = Pattern[1][0]  # keeps mask
    3491         if PickId:
     3591        ExMask.append(np.full(len(xye[0]),False))
     3592        if PickId:   # when is this not true?
    34923593            ifpicked = Pattern[2] == G2frame.GPXtree.GetItemText(PatternId)
    34933594            # recompute mask from excluded regions, in case they have changed
     3595            xye0 = xye[0]  # no mask in case there are no limits
    34943596            for excl in limits[2:]:
    34953597                xye0 = ma.masked_inside(xye[0],excl[0],excl[1],copy=False)                   #excluded region mask
    3496             if not G2frame.Contour:
    3497                 xye0 = ma.masked_outside(xye[0],limits[1][0],limits[1][1],copy=False)            #now mask for limits
     3598            if unequalArrays:
     3599                if ma.is_masked(xye0):
     3600                    ExMask[N] = ma.getmask(xye0)   # save excluded regions
     3601                xye0 = ma.masked_outside(xye[0],limits[1][0],limits[1][1],copy=False) #now mask for limits
     3602                Lmask = ma.getmask(xye0)   # limits applied
     3603                ExMask[N] = ExMask[N][~Lmask] # drop points outside limits
     3604            elif not G2frame.Contour:
     3605                xye0 = ma.masked_outside(xye0,limits[1][0],limits[1][1],copy=False) #now mask for limits
     3606        else:
     3607            xye0 = Pattern[1][0]  # keeps mask
     3608            Lmask = Emask = np.full(len(xye0),False)
     3609
     3610        if G2frame.Contour:
     3611            xye0 = xye[0]   # drop mask               
     3612               
    34983613        if Page.plotStyle['qPlot'] and 'PWDR' in plottype and not ifLimits:
    34993614            X = 2.*np.pi/G2lat.Pos2dsp(Parms,xye0)
     
    35843699            Y = ma.array(Y,mask=ma.getmask(X))
    35853700               
    3586         if ifpicked:
     3701        if ifpicked and not G2frame.Contour: # draw limit & excluded region lines
    35873702            lims = limits[1:]
    35883703            if Page.plotStyle['qPlot'] and 'PWDR' in plottype and not ifLimits:
     
    35903705            elif Page.plotStyle['dPlot'] and 'PWDR' in plottype and not ifLimits:
    35913706                lims = G2lat.Pos2dsp(Parms,lims)
    3592             # plot limit lines
     3707            # limit lines
    35933708            Lines.append(Plot.axvline(lims[0][0],color='g',dashes=(5,5),
    35943709                                    picker=True,pickradius=3.))   
    35953710            Lines.append(Plot.axvline(lims[0][1],color='r',dashes=(5,5),
    35963711                                    picker=True,pickradius=3.))
    3597             # plot excluded region lines
     3712            # excluded region lines
    35983713            for i,item in enumerate(lims[1:]):
    35993714                Lines.append(Plot.axvline(item[0],color='m',dashes=(5,5),
     
    36023717                                    picker=True,pickradius=3.))
    36033718                exclLines += [2*i+2,2*i+3]
    3604         if G2frame.Contour:           
    3605             if len(X) == lenX :
    3606                 if G2frame.Weight:
    3607                     ContourZ.append((xye[1]-xye[3])*np.sqrt(xye[2]))
     3719        if G2frame.Contour:
     3720            if Page.plotStyle['chanPlot']:
     3721                if unequalArrays:
     3722                    X = np.array(range(len(X)),float)
    36083723                else:
    3609                     ContourZ.append(Y)
    3610             elif len(X) < lenX:
    3611                 Yext = np.ones(lenX)*Y[-1]
    3612                 Yext[:len(X)] = Y
     3724                    X = np.array(range(lenX),float)
     3725                    Lmask = Emask = np.full(len(X),False)
     3726            if G2frame.Weight:
     3727                Ytmp = (xye[1]-xye[3])*np.sqrt(xye[2])
     3728            else:
     3729                Ytmp = Y
     3730            # pad or truncate arrays when plotting with mpl.imshow
     3731            if unequalArrays:
     3732                ContourZ.append(Ytmp[~Lmask])
     3733            elif len(Y) < lenX:
     3734                Yext = np.ones(lenX)*Ytmp[-1]
     3735                Yext[:len(X)] = Ytmp
    36133736                ContourZ.append(Yext)
     3737            elif len(Y) > lenX:
     3738                ContourZ.append(Ytmp[:lenX])
    36143739            else:
    3615                 ContourZ.append(Y[:len(X)])
     3740                ContourZ.append(Ytmp)
     3741            #if unequalArrays and G2frame.TforYaxis:
     3742            #    TODO: could set this to temperature and then plot
     3743            #    against temperature, but this only works if patterns are sorted by T
    36163744            ContourY.append(N)
    3617             if 'C' in ParmList[0]['Type'][0]:       
     3745            if unequalArrays:
     3746                Xlist.append(X[~Lmask])
     3747            elif ContourX is None:
    36183748                ContourX = X
    3619             else: #'T'OF
    3620                 ContourX = range(lenX)
    36213749            Nseq += 1
    3622             if G2frame.TforYaxis:
    3623                 Plot.set_ylabel('Temperature',fontsize=14)
    3624             else:
    3625                 Plot.set_ylabel('Data sequence',fontsize=14)
    36263750        else:
    36273751            if not G2frame.plusPlot:
     
    39334057                else:
    39344058                    Plot.legend(handles,legends,title='Data',loc='best')
    3935                    
     4059   
    39364060    if G2frame.Contour:
    39374061        time0 = time.time()
     
    39394063        Vmin = Ymax*G2frame.Cmin
    39404064        Vmax = Ymax*G2frame.Cmax
    3941         if G2frame.Weight:
    3942             Vmin = np.min(ContourZ)
    3943             Vmax = np.max(ContourZ)
    3944         Page.Img = Plot.imshow(ContourZ,cmap=acolor,vmin=Vmin,vmax=Vmax,
    3945             interpolation=G2frame.Interpolate,extent=[ContourX[0],ContourX[-1],ContourY[0]-.5,ContourY[-1]+.5],
    3946             aspect='auto',origin='lower')
    3947         if G2frame.TforYaxis:
    3948             imgAx = Page.Img.axes
    3949             ytics = imgAx.get_yticks()
    3950             # ytics = np.where(ytics<len(Temps),ytics,-1)
    3951             # imgAx.set_yticks(ytics)
    3952             ylabs = [Temps[int(i)] for i in ytics[:-1]]
    3953             imgAx.set_yticklabels(ylabs)
    3954         Page.figure.colorbar(Page.Img)
     4065        if unequalArrays:
     4066            if G2frame.Weight: 
     4067                #Vmin = min([i.min() for i in ContourZ])
     4068                Vmin = min([ma.array(i,mask=m).min() for i,m in zip(ContourZ,ExMask)]) # don't count excluded points in limits
     4069                #Vmax = max([i.max() for i in ContourZ])
     4070                Vmax = max([ma.array(i,mask=m).max() for i,m in zip(ContourZ,ExMask)])
     4071            if G2frame.TforYaxis:
     4072                imgLbls = Temps
     4073            else:
     4074                imgLbls = []
     4075            uneqImgShow(Plot.figure,Plot,Xlist,ContourZ,cmap=acolor,
     4076                         vmin=Vmin,vmax=Vmax,Ylbls=imgLbls)
     4077            Page.Img = None   # don't have an overall image
     4078            if G2frame.TforYaxis:
     4079                Plot.yaxis.set_label_coords(-.1, .5)
     4080            else:
     4081                Plot.yaxis.set_label_coords(-.05, .5)
     4082            Plot.xaxis.set_label_coords(0.5, -.07)
     4083        else:
     4084            if G2frame.Weight:
     4085                Vmin = np.min(ContourZ)
     4086                Vmax = np.max(ContourZ)
     4087            Page.Img = Plot.imshow(ContourZ,cmap=acolor,vmin=Vmin,vmax=Vmax,
     4088                interpolation=G2frame.Interpolate,extent=[ContourX[0],ContourX[-1],ContourY[0]-.5,ContourY[-1]+.5],
     4089                aspect='auto',origin='lower')
     4090            if G2frame.TforYaxis:
     4091                imgAx = Page.Img.axes
     4092                ytics = imgAx.get_yticks()
     4093                # ytics = np.where(ytics<len(Temps),ytics,-1)
     4094                # imgAx.set_yticks(ytics)
     4095                ylabs = [Temps[int(i)] for i in ytics[:-1]]
     4096                imgAx.set_yticklabels(ylabs)
     4097            Page.figure.colorbar(Page.Img)
    39554098        if timeDebug:
    39564099            print('Contour display time: %.3f'%(time.time()-time0))
     
    60626205#### Plot3dXYZ ################################################################################
    60636206def Plot3dXYZ(G2frame,nX,nY,Zdat,labelX=r'X',labelY=r'Y',labelZ=r'Z',newPlot=False,Title='',Centro=False):
    6064    
     6207    '''Creates a surface Plot for 3D vectors'''
    60656208    def OnMotion(event):
    60666209        xpos = event.xdata
Note: See TracChangeset for help on using the changeset viewer.