Changeset 1763


Ignore:
Timestamp:
Mar 25, 2015 5:25:15 PM (7 years ago)
Author:
vondreele
Message:

new item in imgGUI - Flat Bkg; subtracted from image on display & integration

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIimgGUI.py

    r1762 r1763  
    9393    import ImageCalibrants as calFile
    9494#patch
     95    if 'Flat Bkg' not in data:
     96        data['Flat Bkg'] = 0.0
    9597    if 'GonioAngles' not in data:
    9698        data['GonioAngles'] = [0.,0.,0.]
     
    157159                    backImage += BdarkImage*BdarkScale               
    158160                sumImg += backImage*backScale
     161            sumImg -= data['Flat Bkg']
    159162            G2frame.Integrate = G2img.ImageIntegrate(sumImg,data,masks,blkSize,dlg)
    160163#            G2plt.PlotIntegration(G2frame,newPlot=True)
     
    297300                    'tilt','rotation','azmthOff','fullIntegrate','LRazimuth',
    298301                    'IOtth','outChannels','outAzimuths','invert_x','invert_y','DetDepth',
    299                     'calibskip','pixLimit','cutoff','calibdmin','chisq',
     302                    'calibskip','pixLimit','cutoff','calibdmin','chisq','Flat Bkg',
    300303                    'binType','SampleShape','PolaVal','SampleAbs','dark image','background image']
    301304                for key in keys:
     
    310313        cntlList = ['wavelength','distance','tilt','invert_x','invert_y','type',
    311314            'fullIntegrate','outChannels','outAzimuths','LRazimuth','IOtth','azmthOff','DetDepth',
    312             'calibskip','pixLimit','cutoff','calibdmin','chisq',
     315            'calibskip','pixLimit','cutoff','calibdmin','chisq','Flat Bkg',
    313316            'PolaVal','SampleAbs','dark image','background image']
    314317        dlg = wx.FileDialog(G2frame, 'Choose image controls file', '.', '',
     
    790793            data['dark image'][0] = darkImage.GetValue()
    791794            G2plt.PlotExposedImage(G2frame,event=event)
     795           
     796        def OnFlatBkg(event):
     797            try:
     798                value = float(flatbkg.GetValue())
     799                data['Flat Bkg'] = value
     800            except ValueError:
     801                pass
     802            flatbkg.SetValue("%.0f"%(data['Flat Bkg']))   
     803            G2plt.PlotExposedImage(G2frame,event=event)
    792804
    793805        def OnBackMult(event):
     
    808820            G2plt.PlotExposedImage(G2frame,event=event)
    809821       
    810         backSizer = wx.FlexGridSizer(0,4,5,5)
     822        backSizer = wx.FlexGridSizer(0,6,5,5)
    811823
    812824        backSizer.Add(wx.StaticText(G2frame.dataDisplay,-1,' Dark image'),0,WACV)
     
    822834        darkMult.Bind(wx.EVT_KILL_FOCUS,OnDarkMult)
    823835        backSizer.Add(darkMult,0,WACV)
     836        backSizer.Add(wx.StaticText(G2frame.dataDisplay,-1,' Flat Bkg: '),0,WACV)
     837        flatbkg = wx.TextCtrl(parent=G2frame.dataDisplay,value=("%.0f" % (data['Flat Bkg'])),
     838            style=wx.TE_PROCESS_ENTER)
     839        flatbkg.Bind(wx.EVT_TEXT_ENTER,OnFlatBkg)
     840        flatbkg.Bind(wx.EVT_KILL_FOCUS,OnFlatBkg)
     841        backSizer.Add(flatbkg,0,WACV)
    824842
    825843        backSizer.Add(wx.StaticText(G2frame.dataDisplay,-1,' Background image'),0,WACV)
  • trunk/GSASIIplot.py

    r1761 r1763  
    33463346        Page.canvas.SetToolTipString('')
    33473347        sizexy = Data['size']
     3348        FlatBkg = Data.get('Flat Bkg',0.)
    33483349        if event.xdata and event.ydata and len(G2frame.ImageZ):                 #avoid out of frame errors
    33493350            Page.canvas.SetToolTipString('%8.2f %8.2fmm'%(event.xdata,event.ydata))
     
    33723373                Int = 0
    33733374                if (0 <= xpix <= sizexy[0]) and (0 <= ypix <= sizexy[1]):
    3374                     Int = G2frame.ImageZ[ypix][xpix]
     3375                    Int = G2frame.ImageZ[ypix][xpix]-int(FlatBkg)
    33753376                tth,azm,D,dsp = G2img.GetTthAzmDsp(xpos,ypos,Data)
    33763377                Q = 2.*math.pi/dsp
     
    34473448            return
    34483449        pixelSize = Data['pixelSize']
     3450        FlatBkg = Data.get('Flat Bkg',0.)
    34493451        scalex = 1000./pixelSize[0]
    34503452        scaley = 1000./pixelSize[1]
     
    34603462                    Xpix = Xpos*scalex
    34613463                    Ypix = Ypos*scaley
    3462                     xpos,ypos,I,J = G2img.ImageLocalMax(G2frame.ImageZ,pixLimit,Xpix,Ypix)
     3464                    xpos,ypos,I,J = G2img.ImageLocalMax(G2frame.ImageZ-FlatBkg,pixLimit,Xpix,Ypix)
    34633465                    if I and J:
    34643466                        xpos += .5                              #shift to pixel center
     
    35253527            StrSta['d-zero'].append({'Dset':dsp,'Dcalc':0.0,'pixLimit':10,'cutoff':0.5,
    35263528                'ImxyObs':[[],[]],'ImtaObs':[[],[]],'ImtaCalc':[[],[]],'Emat':[1.0,1.0,1.0]})
    3527             R,r = G2img.MakeStrStaRing(StrSta['d-zero'][-1],G2frame.ImageZ,Data)
     3529            R,r = G2img.MakeStrStaRing(StrSta['d-zero'][-1],G2frame.ImageZ-FlatBkg,Data)
    35283530            if not len(R):
    35293531                del StrSta['d-zero'][-1]
     
    37083710    #do threshold mask - "real" mask - others are just bondaries
    37093711    Zlim = Masks['Thresholds'][1]
     3712    FlatBkg = Data.get('Flat Bkg',0.0)
    37103713    wx.BeginBusyCursor()
    37113714    try:
     
    37153718            MA = ma.masked_greater(ma.masked_less(G2frame.ImageZ,Zlim[0]),Zlim[1])
    37163719            MaskA = ma.getmaskarray(MA)
    3717             A = G2img.ImageCompress(MA,imScale)
     3720            A = G2img.ImageCompress(MA,imScale)-FlatBkg
    37183721            AM = G2img.ImageCompress(MaskA,imScale)
    37193722            if G2frame.logPlot:
Note: See TracChangeset for help on using the changeset viewer.