Example #1
0
    def run(self, exposure):
        """Background subtraction

        @param exposure Exposure to process
        """
        policy = self.config['background'].getPolicy()
        bg, subtracted = muDetection.estimateBackground(
            exposure, policy, subtract=self._subtract)

        if not self._subtract:
            return bg

        self.log.log(self.log.INFO, "Subtracted background")

        self.display('background', exposure=subtracted)
        return bg, subtracted
    def process(self, clipboard):
        """
        Detect sources in the worker process
        """
        self.log.log(Log.INFO, "Subtracting background in process")
        
        #grab exposure from clipboard
        exposure = clipboard.get(self.policy.get("inputKeys.exposure"))
            
        #estimate and maybe subtract the background
        background, backgroundSubtractedExposure = sourceDetection.estimateBackground(
            exposure,
            self.policy.get("parameters.backgroundPolicy"),
            self.policy.get("parameters.subtractBackground"))

        #output products
        clipboard.put(self.policy.get("outputKeys.background"), background)
        if backgroundSubtractedExposure:
            clipboard.put(self.policy.get("outputKeys.backgroundSubtractedExposure"),
                          backgroundSubtractedExposure)
    def process(self, clipboard):
        """
        Detect sources in the worker process
        """
        self.log.log(Log.INFO, "Subtracting background in process")

        #grab exposure from clipboard
        exposure = clipboard.get(self.policy.get("inputKeys.exposure"))

        #estimate and maybe subtract the background
        background, backgroundSubtractedExposure = sourceDetection.estimateBackground(
            exposure, self.policy.get("parameters.backgroundPolicy"),
            self.policy.get("parameters.subtractBackground"))

        #output products
        clipboard.put(self.policy.get("outputKeys.background"), background)
        if backgroundSubtractedExposure:
            clipboard.put(
                self.policy.get("outputKeys.backgroundSubtractedExposure"),
                backgroundSubtractedExposure)
    def process(self, clipboard):
        """
        Detect sources in the worker process
        """
        self.log.log(Log.INFO, "Detecting Sources in process")

        #grab exposure(s) from clipboard
        exposureList = []
        if self.policy.isArray("inputKeys.exposure"):
            #if more than one exposure is supplied, first
            exposureKeyList = self.policy.getArray("inputKeys.exposure")
            for key in exposureKeyList:
                exposureList.append(clipboard.get(key))

            #stack the exposures
            exposure = sourceDetection.addExposures(exposureList)
        else:
            exposure = clipboard.get(self.policy.get("inputKeys.exposure"))
            exposureList.append(exposure)

        if exposure is None:
            raise RuntimeError, "Input Exposure Missing"

        #subtract the background
        if self.policy.exists("backgroundPolicy") and self.policy.get(
                "backgroundPolicy.algorithm") != "NONE":
            background, backgroundSubtracted = sourceDetection.estimateBackground(
                exposure, self.policy.get("backgroundPolicy"), True)
        else:
            backgroundSubtracted, background = exposure, None

        #get or make a smoothing psf according to the policy
        if self.policy.exists("inputKeys.psf"):
            psf = clipboard.get(self.policy.get("inputKeys.psf"))
        elif self.policy.exists("psfPolicy"):
            psf = sourceDetection.makePsf(self.policy.get("psfPolicy"))
        else:
            psf = None

        #perform detection
        dsPositive, dsNegative = sourceDetection.detectSources(
            backgroundSubtracted, psf, self.policy.get("detectionPolicy"))

        #
        # Copy detection mask bits to the input exposure(s)
        #
        detectionMask = backgroundSubtracted.getMaskedImage().getMask()
        for e in exposureList:
            msk = e.getMaskedImage().getMask()
            msk |= detectionMask
            del msk

        del detectionMask

        #output products
        if dsPositive:
            clipboard.put(self.policy.get("outputKeys.positiveDetection"),
                          dsPositive)
        if dsNegative:
            clipboard.put(self.policy.get("outputKeys.negativeDetection"),
                          dsNegative)
        if background:
            clipboard.put(self.policy.get("outputKeys.background"), background)
        if psf:
            clipboard.put(self.policy.get("outputKeys.psf"), psf)

        clipboard.put(
            self.policy.get("outputKeys.backgroundSubtractedExposure"),
            backgroundSubtracted)
Example #5
0
    numPos = len(posSources.getFootprints()) if posSources is not None else 0
    numNeg = len(negSources.getFootprints()) if negSources is not None else 0
    print 'Detected', numPos, 'pos and', numNeg, 'neg'
    footprintSet = posSources
    del negSources

    for fp in footprintSet.getFootprints():
        print 'footprint', fp
        print 'npix', fp.getNpix()

    # phot.py
    bgconf = muDetection.BackgroundConfig()
    print 'Background config:', bgconf
    subtract = True
    bg, subtracted = muDetection.estimateBackground(exposure,
                                                    bgconf,
                                                    subtract=subtract)
    print 'bg', bg
    exposure = subtracted

    # phot.py
    #sources = self.measure(exposure, footprintSet, psf, apcorr=apcorr, wcs=wcs)
    footprints = []
    num = len(footprintSet.getFootprints())
    print 'Measuring', num, 'sources'
    footprints.append([footprintSet.getFootprints(), False])
    measconf = measAlg.MeasureSourcesConfig()
    sources = muMeasurement.sourceMeasurement(exposure, psf, footprints,
                                              measconf)
    muMeasurement.computeSkyCoords(wcs, sources)
Example #6
0
	posSources, negSources = muDetection.detectSources(exposure, psf, detconf)
	numPos = len(posSources.getFootprints()) if posSources is not None else 0
	numNeg = len(negSources.getFootprints()) if negSources is not None else 0
	print 'Detected', numPos, 'pos and', numNeg, 'neg'
	footprintSet = posSources
	del negSources

	for fp in footprintSet.getFootprints():
		print 'footprint', fp
		print 'npix', fp.getNpix()

	# phot.py
	bgconf = muDetection.BackgroundConfig()
	print 'Background config:', bgconf
	subtract = True
	bg, subtracted = muDetection.estimateBackground(exposure, bgconf, subtract=subtract)
	print 'bg', bg
	exposure = subtracted

	# phot.py
	#sources = self.measure(exposure, footprintSet, psf, apcorr=apcorr, wcs=wcs)
	footprints = []
	num = len(footprintSet.getFootprints())
	print 'Measuring', num, 'sources'
	footprints.append([footprintSet.getFootprints(), False])
	measconf = measAlg.MeasureSourcesConfig()
	sources = muMeasurement.sourceMeasurement(exposure, psf, footprints, measconf)
	muMeasurement.computeSkyCoords(wcs, sources)

	# calibrate.py
	#psf, cellSet = self.psf(exposure, sources)
    def process(self, clipboard):
        """
        Detect sources in the worker process
        """
        self.log.log(Log.INFO, "Detecting Sources in process")
        
        #grab exposure(s) from clipboard
        exposureList = []        
        if self.policy.isArray("inputKeys.exposure"):
            #if more than one exposure is supplied, first
            exposureKeyList = self.policy.getArray("inputKeys.exposure")
            for key in exposureKeyList:
                exposureList.append(clipboard.get(key))                        
    
            #stack the exposures
            exposure = sourceDetection.addExposures(exposureList)
        else:                    
            exposure = clipboard.get(self.policy.get("inputKeys.exposure"))
            exposureList.append(exposure)
       
        if exposure is None:
            raise RuntimeError, "Input Exposure Missing"
            
        #subtract the background
        if self.policy.exists("backgroundPolicy") and self.policy.get("backgroundPolicy.algorithm") != "NONE":
            background, backgroundSubtracted = sourceDetection.estimateBackground(
                exposure, self.policy.get("backgroundPolicy"), True)
        else:
            backgroundSubtracted, background = exposure, None

        #get or make a smoothing psf according to the policy
        if self.policy.exists("inputKeys.psf"):
            psf = clipboard.get(self.policy.get("inputKeys.psf"))
        elif self.policy.exists("psfPolicy"):
            psf = sourceDetection.makePsf(self.policy.get("psfPolicy"))
        else:
            psf = None
            
        #perform detection
        dsPositive, dsNegative = sourceDetection.detectSources(
            backgroundSubtracted, psf, self.policy.get("detectionPolicy"))        

        #
        # Copy detection mask bits to the input exposure(s)
        #
        detectionMask = backgroundSubtracted.getMaskedImage().getMask()
        for e in exposureList:
            msk = e.getMaskedImage().getMask()
            msk |= detectionMask
            del msk

        del detectionMask


        #output products
        if dsPositive:
            clipboard.put(
                self.policy.get("outputKeys.positiveDetection"), dsPositive)
        if dsNegative:
            clipboard.put(
                self.policy.get("outputKeys.negativeDetection"), dsNegative)
        if background:
            clipboard.put(self.policy.get("outputKeys.background"), background)
        if psf:
            clipboard.put(self.policy.get("outputKeys.psf"), psf)

        clipboard.put(self.policy.get("outputKeys.backgroundSubtractedExposure"),
                      backgroundSubtracted)