예제 #1
0
 def DebugInfo(name):
     di = lsstDebug.getInfo(name)
     #di.display = True # N.b. lsstDebug.Info(name) would call us recursively
     if name == "lsst.pipe.tasks.matchBackgrounds":
         di.display = False
         di.savefig = True
         di.savefits = False
         di.figpath = "/lsst/home/yusra/figures/"
     if name == "lsst.obs.sdss.selectFluxMag0":
         di.display = True
     if name == "lsst.ip.diffim.psfMatch":
         di.display = True                 # global; _solve function
         di.maskTransparency = 80          # ds9 mask transparency
         di.displayCandidates = True       # show all the candidates and residuals
         di.displayKernelBasis = True      # show kernel basis functions
         di.displayKernelMosaic = True     # show kernel realized across the image
         di.plotKernelSpatialModel = False # show coefficients of spatial model
         di.showBadCandidates = True       # show the bad candidates (red) along with good (green)
     elif name == "lsst.ip.diffim.imagePsfMatch":
         di.display = False                # global
         di.maskTransparency = 80          # ds9 mask transparency
         di.displayTemplate = True         # show full (remapped) template
         di.displaySciIm = True            # show science image to match to
         di.displaySpatialCells = True     # show spatial cells
         di.displayDiffIm = True           # show difference image
         di.showBadCandidates = True       # show the bad candidates (red) along with good (green)
     elif name == "lsst.pipe.tasks.imageDifference":
         di.display =True                # global
         di.maskTransparency = 50          # ds9 mask transparency
         di.showPixelResiduals = True      # histograms of diffim / sqrt(variance)
         di.showDiaSources = True          # display diffim-detected sources
         
     return di
예제 #2
0
def MyInfo(name):
    #print 'MyInfo:', name
    di = lsstDebug.getInfo(name)
    #if name == 'lsst.meas.algorithms.measurement':
    #    di.display = True
    if name == '__main__':
        #di.display = True
        pass
    return di
def MyInfo(name):
    #print 'MyInfo:', name
    di = lsstDebug.getInfo(name)
    #if name == 'lsst.meas.algorithms.measurement':
    #    di.display = True
    if name == '__main__':
        #di.display = True
        pass
    return di
def detectAndMeasureWithDM():

    ### what file are you going to look at? This should be in fits format.
    ### The test image included in this example contains stars and galaxies in the center only. 
    imagefile = "test_image_stars.fits"
    
    ### open the file in the stack format
    exposure = afwImage.ExposureF(imagefile)
    im = exposure.getMaskedImage().getImage()

    ### display the original image
    frame = 0
    ds9.mtv(exposure, frame=frame, title="Original Image"); frame+=1



    ### Subtract background. 
    ### To do this, we'll set up a grid of 64x64 pixel areas across th eimage
    ### Fit the second moment of the pixels in each (which should be bg-dominated) and a fit a smooth function
    ### Subtract this function. 
    print "** subtracting background"
    #back_size = 256 ## dunno what this is
    #back_ctrl = afwMath.BackgroundControl(im.getWidth()//back_size+1, im.getHeight()//back_size +1)
    #back_obj = afwMath.makeBackground(im, back_ctrl)
    #im -=back_obj.getImageF("LINEAR")
    
    im -= float(np.median(im.getArray()))
    ds9.mtv(exposure, frame=frame, title="Background removed"); frame+=1

    ### Set up the schema
    schema = afwTable.SourceTable.makeMinimalSchema()
    schema.setVersion(0)

    
    ### Create the detection task
    config = SourceDetectionTask.ConfigClass()
    config.reEstimateBackground = False
    detectionTask = SourceDetectionTask(config=config, schema=schema)

    ### create the measurement task
    config = SourceMeasurementTask.ConfigClass()
    config.slots.psfFlux = "flux.sinc"  # use of the psf flux is hardcoded in secondMomentStarSelector
    measureTask = SourceMeasurementTask(schema, config=config)
    
    ### Create the measurePsf task
    config = MeasurePsfTask.ConfigClass()
    starSelector = config.starSelector.apply()
    starSelector.name = "objectSize"
    #starSelector.config.badFlags = ["flags.pixel.edge",  "flags.pixel.cr.center",
    #                                "flags.pixel.interpolated.center", "flags.pixel.saturated.center"]
    psfDeterminer = config.psfDeterminer.apply()
    psfDeterminer.config.sizeCellX = 128
    psfDeterminer.config.sizeCellY = 128
    psfDeterminer.config.nStarPerCell = 1
    psfDeterminer.config.spatialOrder = 1
    psfDeterminer.config.nEigenComponents = 3
    measurePsfTask = MeasurePsfTask(config=config, schema=schema)

    ### Create the output table
    tab = afwTable.SourceTable.make(schema)


    lsstDebug.getInfo(MeasurePsfTask).display=True
    
    ### Process the data
    print "*** running detection task..."
    sources = detectionTask.run(tab, exposure, sigma=2).sources
    print "*** running measure task..."
    measureTask.measure(exposure, sources)
    print "*** running measurePsf task..."
    result = measurePsfTask.run(exposure, sources)
    
    psf = result.psf
    cellSet = result.cellSet

    ### Look at the psf
    psfIm = psf.computeImage()
    ds9.mtv(psfIm, frame=frame, title = "Psf Image"); frame+=1

    ### render it on a grid
    import lsst.meas.algorithms.utils as measUtils
    cellSet = result.cellSet
    measUtils.showPsfMosaic(exposure, psf=psf, frame=frame); frame += 1
    
    with ds9.Buffering():
        for s in sources:
            xy = s.getCentroid()
            ds9.dot('+', *xy, ctype=ds9.GREEN, frame=frame)
            if s.get("calib.psf.candidate"):
                ds9.dot('x', *xy, ctype=ds9.YELLOW, frame=frame)
            if s.get("calib.psf.used"):
                ds9.dot('o', *xy, size=4, ctype=ds9.RED, frame=frame)
               

    """
예제 #5
0
 def DebugInfo(name):
     di = lsstDebug.getInfo(
         name)  # N.b. lsstDebug.Info(name) would call us recursively
     if name == "lsst.ip.isr.fringe":
         di.plot = True
     return di
예제 #6
0
 def DebugInfo(name):
     di = lsstDebug.getInfo(name)        # N.b. lsstDebug.Info(name) would call us recursively
     if name == "lsst.ip.isr.fringe":
         di.plot = True
     return di