示例#1
0
    def testRegularizationSmallClamp(self):
        """Test that large variations between model planes are reduced.

        This also tests that noise-like pixels are not regularized.
        """
        clampFrequency = 2
        regularizationWidth = 2
        fluxRange = 10.
        modelImages = self.makeTestImages(fluxRange=fluxRange)
        dcrModels = DcrModel(modelImages=modelImages,
                             mask=self.mask,
                             effectiveWavelength=self.effectiveWavelength,
                             bandwidth=self.bandwidth)
        newModels = [model.clone() for model in dcrModels]
        templateImage = dcrModels.getReferenceImage(self.bbox)

        statsCtrl = self.prepareStats()
        dcrModels.regularizeModelFreq(newModels, self.bbox, statsCtrl,
                                      clampFrequency, regularizationWidth)
        for model, refModel in zip(newModels, dcrModels):
            # Make sure the test parameters do reduce the outliers
            self.assertGreater(np.max(refModel.array - templateImage),
                               np.max(model.array - templateImage))
            highThreshold = templateImage * clampFrequency
            highPix = model.array > highThreshold
            highPix = ndimage.morphology.binary_opening(
                highPix, iterations=regularizationWidth)
            self.assertFalse(np.all(highPix))
            lowThreshold = templateImage / clampFrequency
            lowPix = model.array < lowThreshold
            lowPix = ndimage.morphology.binary_opening(
                lowPix, iterations=regularizationWidth)
            self.assertFalse(np.all(lowPix))
    def testRegularizationSidelobes(self):
        """Test that artificial chromatic sidelobes are suppressed.
        """
        clampFrequency = 2.
        regularizationWidth = 2
        noiseLevel = 0.1
        sourceAmplitude = 100.
        modelImages = self.makeTestImages(seed=5, nSrc=5, psfSize=3., noiseLevel=noiseLevel,
                                          detectionSigma=5., sourceSigma=sourceAmplitude, fluxRange=2.)
        templateImage = np.mean([model.array for model in modelImages], axis=0)
        sidelobeImages = self.makeTestImages(seed=5, nSrc=5, psfSize=1.5, noiseLevel=noiseLevel/10.,
                                             detectionSigma=5., sourceSigma=sourceAmplitude*5., fluxRange=2.)
        statsCtrl = self.prepareStats()
        signList = [-1., 0., 1.]
        sidelobeShift = (0., 4.)
        for model, sidelobe, sign in zip(modelImages, sidelobeImages, signList):
            sidelobe.array *= sign
            model.array += applyDcr(sidelobe.array, sidelobeShift, useInverse=False)
            model.array += applyDcr(sidelobe.array, sidelobeShift, useInverse=True)

        dcrModels = DcrModel(modelImages=modelImages, mask=self.mask)
        refModels = [dcrModels[subfilter].clone() for subfilter in range(self.dcrNumSubfilters)]

        dcrModels.regularizeModelFreq(modelImages, self.bbox, statsCtrl, clampFrequency,
                                      regularizationWidth=regularizationWidth)
        for model, refModel, sign in zip(modelImages, refModels, signList):
            # Make sure the test parameters do reduce the outliers
            self.assertGreater(np.sum(np.abs(refModel.array - templateImage)),
                               np.sum(np.abs(model.array - templateImage)))
示例#3
0
    def testRegularizationSidelobes(self):
        """Test that artificial chromatic sidelobes are suppressed.
        """
        clampFrequency = 2.
        regularizationWidth = 2
        noiseLevel = 0.1
        sourceAmplitude = 100.
        modelImages = self.makeTestImages(seed=5, nSrc=5, psfSize=3., noiseLevel=noiseLevel,
                                          detectionSigma=5., sourceSigma=sourceAmplitude, fluxRange=2.)
        templateImage = np.mean([model.array for model in modelImages], axis=0)
        sidelobeImages = self.makeTestImages(seed=5, nSrc=5, psfSize=1.5, noiseLevel=noiseLevel/10.,
                                             detectionSigma=5., sourceSigma=sourceAmplitude*5., fluxRange=2.)
        statsCtrl = self.prepareStats()
        signList = [-1., 0., 1.]
        sidelobeShift = (0., 4.)
        for model, sidelobe, sign in zip(modelImages, sidelobeImages, signList):
            sidelobe.array *= sign
            model.array += applyDcr(sidelobe.array, sidelobeShift, useInverse=False)
            model.array += applyDcr(sidelobe.array, sidelobeShift, useInverse=True)

        dcrModels = DcrModel(modelImages=modelImages, mask=self.mask)
        refModels = [dcrModels[subfilter].clone() for subfilter in range(self.dcrNumSubfilters)]

        dcrModels.regularizeModelFreq(modelImages, self.bbox, statsCtrl, clampFrequency,
                                      regularizationWidth=regularizationWidth)
        for model, refModel, sign in zip(modelImages, refModels, signList):
            # Make sure the test parameters do reduce the outliers
            self.assertGreater(np.sum(np.abs(refModel.array - templateImage)),
                               np.sum(np.abs(model.array - templateImage)))
    def testRegularizationSmallClamp(self):
        """Test that large variations between model planes are reduced.

        This also tests that noise-like pixels are not regularized.
        """
        clampFrequency = 2
        regularizationWidth = 2
        fluxRange = 10.
        modelImages = self.makeTestImages(fluxRange=fluxRange)
        dcrModels = DcrModel(modelImages=modelImages, mask=self.mask)
        newModels = [model.clone() for model in dcrModels]
        templateImage = dcrModels.getReferenceImage(self.bbox)

        statsCtrl = self.prepareStats()
        dcrModels.regularizeModelFreq(newModels, self.bbox, statsCtrl, clampFrequency, regularizationWidth)
        for model, refModel in zip(newModels, dcrModels):
            # Make sure the test parameters do reduce the outliers
            self.assertGreater(np.max(refModel.array - templateImage),
                               np.max(model.array - templateImage))
            highThreshold = templateImage*clampFrequency
            highPix = model.array > highThreshold
            highPix = ndimage.morphology.binary_opening(highPix, iterations=regularizationWidth)
            self.assertFalse(np.all(highPix))
            lowThreshold = templateImage/clampFrequency
            lowPix = model.array < lowThreshold
            lowPix = ndimage.morphology.binary_opening(lowPix, iterations=regularizationWidth)
            self.assertFalse(np.all(lowPix))