Changeset 3358 for trunk/GSASIIplot.py


Ignore:
Timestamp:
Apr 26, 2018 11:46:19 AM (5 years ago)
Author:
vondreele
Message:

implement new feature for image plotting - linescan; produces 1D plot of intensity along line originating at beam center.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIplot.py

    r3356 r3358  
    24702470    if G2frame.logPlot:
    24712471        Title = 'log('+Title+')'
    2472     #Plot.set_title(Title) # show title only w/o magnification
    24732472    if G2frame.plotStyle['qPlot'] or plottype in ['SASD','REFD'] and not G2frame.Contour:
    24742473        xLabel = r'$Q, \AA^{-1}$'
     
    24842483                xLabel = r'$TOF, \mathsf{\mu}$s'
    24852484    if G2frame.Weight:
    2486         Plot.tick_params('x',length=0,labelbottom=False)
    2487         Plot.tick_params('y',length=0,labelleft=False)
     2485        Plot.set_visible(False)         #hide old plot frame, will get replaced below
    24882486        GS_kw = {'height_ratios':[4, 1],}
    24892487        try:
     
    55985596    G2frame.cid = None
    55995597    #Dsp = lambda tth,wave: wave/(2.*npsind(tth/2.))
    5600     global Data,Masks,StrSta  # RVD: these are needed for multiple image controls/masks
     5598    global Data,Masks,StrSta,Plot1  # RVD: these are needed for multiple image controls/masks
    56015599    colors=['b','g','r','c','m','k']
    56025600    Data = G2frame.GPXtree.GetItemPyData(
     
    56395637                        Page.SetToolTipString('%6d deg'%(azm))
    56405638                    elif 'line1' in  str(item) or 'line2' in str(item):
    5641                         Page.SetToolTipString('%8.3f deg'%(tth))                           
     5639                        Page.SetToolTipString('%8.3f deg'%(tth))
     5640                    elif 'linescan' in str(item):
     5641                        Data['linescan'][1] = azm                       
     5642                        Page.SetToolTipString('%6.1f deg'%(azm))
    56425643            else:
    56435644                xcent,ycent = Data['center']
     
    57505751                tth,azm,D,dsp = G2img.GetTthAzmDsp(xpos,ypos,Data)
    57515752                G2frame.calibDmin.SetValue(dsp)
    5752             elif event.key == 'l':
    5753                 G2frame.logPlot = not G2frame.logPlot
    57545753            elif event.key in ['x',]:
    57555754                Data['invert_x'] = not Data['invert_x']
     
    57815780                Data['LRazimuth'][1] = int(azm)
    57825781                Data['LRazimuth'][1] %= 360
     5782            elif 'linescan' in itemPicked:
     5783                Data['linescan'][1] = azm
    57835784            else:
    57845785                return
     
    58255826            elif 'line4' in itemPicked  and 'Line2D' in itemPicked:
    58265827                pick.set_data([[arcxI[-1],arcxO[-1]],[arcyI[-1],arcyO[-1]]])
     5828            elif 'linescan' in itemPicked:
     5829                azm = Data['linescan'][1]
     5830                dspI = wave/(2.0*sind(0.1/2.0))
     5831                xyI = G2img.GetDetectorXY(dspI,azm,Data)
     5832                dspO = wave/(2.0*sind(60./2.0))
     5833                xyO = G2img.GetDetectorXY(dspO,azm,Data)
     5834                pick.set_data([[xyI[0],xyO[0]],[xyI[1],xyO[1]]])
     5835                xy = G2img.GetLineScan(G2frame.ImageZ,Data)
     5836                Plot1.cla()
     5837                Plot1.plot(xy[0],xy[1])
     5838                Page.canvas.draw()
     5839               
    58275840            Page.figure.gca().draw_artist(pick)
    58285841            Page.canvas.blit(Page.figure.gca().bbox)
     
    62496262    xylim = []
    62506263    new,plotNum,Page,Plot,lim = G2frame.G2plotNB.FindPlotTab('2D Powder Image','mpl',newImage=newImage)
     6264   
     6265    if Data.get('linescan',[False,0.])[0]:
     6266        Plot.set_visible(False)
     6267        GS_kw = {'width_ratios':[1,2],}
     6268        try:
     6269            Plot1,Plot = Page.figure.subplots(1,2,gridspec_kw=GS_kw)
     6270        except AttributeError: # figure.Figure.subplots added in MPL 2.2
     6271            Plot1,Plot = MPLsubplots(Page.figure, 1,2, gridspec_kw=GS_kw)
     6272        Plot1.set_title('Line scan at azm= %6.1f'%Data['linescan'][1])
     6273        Plot1.set_xlabel(r'$\mathsf{2\Theta}$',fontsize=12)
     6274        Plot1.set_ylabel('Intensity',fontsize=12)
     6275        xy = G2img.GetLineScan(G2frame.ImageZ,Data)
     6276        Plot1.plot(xy[0],xy[1])
     6277        Plot1.set_xlim(Data['IOtth'])
     6278        Plot1.set_xscale("linear")                                                 
    62516279    if newImage:
    62526280        G2frame.MaskKey = '' # subtitle will be removed, so turn off mode
     
    62636291    Title = G2frame.GPXtree.GetItemText(G2frame.Image)[4:]
    62646292    G2frame.G2plotNB.status.DestroyChildren() #get rid of special stuff on status bar
    6265     if G2frame.logPlot:
    6266         Title = 'log('+Title+')'
    62676293    Plot.set_title(Title)
    62686294    try:
    62696295        if G2frame.GPXtree.GetItemText(G2frame.PickId) in ['Image Controls',]:
    6270             Page.Choice = (' key press','l: log(I) on','d: set dmin','x: flip x','y: flip y',)
    6271             if G2frame.logPlot:
    6272                 Page.Choice[1] = 'l: log(I) off'
     6296            Page.Choice = (' key press','c: set beam center','d: set dmin','x: flip x','y: flip y',)
     6297#            if G2frame.logPlot:
     6298#                Page.Choice[1] = 'l: log(I) off'
    62736299            Page.keyPress = OnImPlotKeyPress
    62746300        elif G2frame.GPXtree.GetItemText(G2frame.PickId) in ['Masks',]:
    6275             Page.Choice = [' key press','l: log(I) on','a: arc mask','r: ring mask',
     6301            Page.Choice = [' key press','a: arc mask','r: ring mask',
    62766302                'p: polygon mask','f: frame mask',
    62776303                't: add spot mask at mouse position',
     
    62806306                ' (space) input the spot mask diameter']
    62816307            Page.Choice.append('s: start multiple spot mask mode') # this must be the last choice
    6282             if G2frame.logPlot:
    6283                 Page.Choice[1] = 'l: log(I) off'
    62846308            Page.keyPress = OnImPlotKeyPress
    62856309        elif G2frame.GPXtree.GetItemText(G2frame.PickId) in ['Stress/Strain',]:
     
    63156339            A = G2img.ImageCompress(MA,imScale)
    63166340            AM = G2img.ImageCompress(MaskA,imScale)
    6317             if G2frame.logPlot:
    6318                 A = np.where(A>Imin,np.where(A<Imax,A,0),0)
    6319                 A = np.where(A>0,np.log(A),0)
    6320                 AM = np.where(AM>0,np.log(AM),0)
    6321                 Imin,Imax = [np.amin(A),np.amax(A)]
    63226341            Plot.imshow(AM,aspect='equal',cmap='Reds',
    63236342                interpolation='nearest',vmin=0,vmax=2,extent=[0,Xmax,Ymax,0])
     
    63266345           
    63276346        Plot.plot(xcent,ycent,'x')
    6328         #G2frame.GPXtree.GetItemText(item)
    63296347        if Data['showLines']: # draw integration range arc/circles/lines
    63306348            LRAzim = Data['LRazimuth']                  #NB: integers
     
    63686386                ind = np.searchsorted(Azm,cake)
    63696387                Plot.plot([arcxI[ind],arcxO[ind]],[arcyI[ind],arcyO[ind]],color='k',dashes=(5,5))
     6388        if 'linescan' in Data and Data['linescan'][0]:
     6389            azm = Data['linescan'][1]
     6390            IOtth = [0.1,60.]
     6391            wave = Data['wavelength']
     6392            dspI = wave/(2.0*sind(IOtth[0]/2.0))
     6393            xyI = G2img.GetDetectorXY(dspI,azm,Data)
     6394            dspO = wave/(2.0*sind(IOtth[1]/2.0))
     6395            xyO = G2img.GetDetectorXY(dspO,azm,Data)
     6396            Plot.plot([xyI[0],xyO[0]],[xyI[1],xyO[1]],picker=3,label='linescan')
    63706397                   
    63716398        if G2frame.PickId and G2frame.GPXtree.GetItemText(G2frame.PickId) in ['Image Controls',]:
Note: See TracChangeset for help on using the changeset viewer.