Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DM-22814: Remove afw APIs deprecated in DM-17566 #168

Merged
merged 1 commit into from
Nov 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion examples/crossCorrelation.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,9 @@ def testAutoCorrelation(orderMake, orderFit, inMi=None, display=False):
spatialKernel.setSpatialParameters(kCoeffs)

cMi = afwImage.MaskedImageF(inMi.getDimensions())
afwMath.convolve(cMi, inMi, spatialKernel, True)
convolutionControl = afwMath.ConvolutionControl()
convolutionControl.setDoNormalize(True)
afwMath.convolve(cMi, inMi, spatialKernel, convolutionControl)

if display:
afwDisplay.Display(frame=1).mtv(inMi.getImage())
Expand Down
4 changes: 3 additions & 1 deletion examples/modelPsfMatchTask.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ def createImageAndKernel(sigma, psfSize, image):
psf = measAlg.KernelPsf(kernel)

cim = afwImage.ImageF(image.getDimensions())
afwMath.convolve(cim, image, kernel, True)
convolutionControl = afwMath.ConvolutionControl()
convolutionControl.setDoNormalize(True)
afwMath.convolve(cim, image, kernel, convolutionControl)

# Trim off the border pixels
bbox = kernel.shrinkBBox(cim.getBBox(afwImage.LOCAL))
Expand Down
4 changes: 3 additions & 1 deletion examples/spatialKernel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ int main() {
std::shared_ptr<afwImage::MaskedImage<PixelT>> mimg2(
new afwImage::MaskedImage<PixelT>(mimg1->getDimensions())
);
afwMath::convolve(*mimg2, *mimg1, *spatialKernel, false);
afwMath::ConvolutionControl convolutionControl;
convolutionControl.setDoNormalize(false);
afwMath::convolve(*mimg2, *mimg1, *spatialKernel, convolutionControl);
mimg1->writeFits("mimg1");
mimg2->writeFits("mimg2");

Expand Down
8 changes: 6 additions & 2 deletions python/lsst/ip/diffim/diffimTools.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,9 @@ def makeFakeKernelSet(sizeCell=128, nCell=3,
gaussFunction = afwMath.GaussianFunction2D(tGaussianWidth, tGaussianWidth)
gaussKernel = afwMath.AnalyticKernel(gaussKernelWidth, gaussKernelWidth, gaussFunction)
cim = afwImage.ImageF(tim.getDimensions())
afwMath.convolve(cim, tim, gaussKernel, True)
convolutionControl = afwMath.ConvolutionControl()
convolutionControl.setDoNormalize(True)
afwMath.convolve(cim, tim, gaussKernel, convolutionControl)
tim = cim

# Trim off border pixels
Expand All @@ -221,7 +223,9 @@ def makeFakeKernelSet(sizeCell=128, nCell=3,
sKernel = afwMath.LinearCombinationKernel(basisList[:nToUse], polyFunc)
sKernel.setSpatialParameters(kCoeffs[:nToUse])
sim = afwImage.ImageF(tim.getDimensions())
afwMath.convolve(sim, tim, sKernel, True)
convolutionControl = afwMath.ConvolutionControl()
convolutionControl.setDoNormalize(True)
afwMath.convolve(sim, tim, sKernel, convolutionControl)

# Get the good subregion
bbox = sKernel.shrinkBBox(sim.getBBox(afwImage.LOCAL))
Expand Down
5 changes: 3 additions & 2 deletions python/lsst/ip/diffim/imagePsfMatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -557,8 +557,9 @@ def matchMaskedImages(self, templateMaskedImage, scienceMaskedImage, candidateLi
spatialSolution, psfMatchingKernel, backgroundModel = self._solve(kernelCellSet, basisList)

psfMatchedMaskedImage = afwImage.MaskedImageF(templateMaskedImage.getBBox())
doNormalize = False
afwMath.convolve(psfMatchedMaskedImage, templateMaskedImage, psfMatchingKernel, doNormalize)
convolutionControl = afwMath.ConvolutionControl()
convolutionControl.setDoNormalize(False)
afwMath.convolve(psfMatchedMaskedImage, templateMaskedImage, psfMatchingKernel, convolutionControl)
return pipeBase.Struct(
matchedImage=psfMatchedMaskedImage,
psfMatchingKernel=psfMatchingKernel,
Expand Down
5 changes: 3 additions & 2 deletions python/lsst/ip/diffim/modelPsfMatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,8 +360,9 @@ def run(self, exposure, referencePsfModel, kernelSum=1.0):

# Normalize the psf-matching kernel while convolving since its magnitude is meaningless
# when PSF-matching one model to another.
doNormalize = True
afwMath.convolve(psfMatchedMaskedImage, maskedImage, psfMatchingKernel, doNormalize)
convolutionControl = afwMath.ConvolutionControl()
convolutionControl.setDoNormalize(True)
afwMath.convolve(psfMatchedMaskedImage, maskedImage, psfMatchingKernel, convolutionControl)

self.log.info("done")
return pipeBase.Struct(psfMatchedExposure=psfMatchedExposure,
Expand Down
2 changes: 1 addition & 1 deletion python/lsst/ip/diffim/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -890,7 +890,7 @@ def plotWhisker(results, newWcs):
"""Plot whisker diagram of astromeric offsets between results.matches.
"""
refCoordKey = results.matches[0].first.getTable().getCoordKey()
inCentroidKey = results.matches[0].second.getTable().getCentroidKey()
inCentroidKey = results.matches[0].second.getTable().getCentroidSlot().getMeasKey()
positions = [m.first.get(refCoordKey) for m in results.matches]
residuals = [m.first.get(refCoordKey).getOffsetFrom(
newWcs.pixelToSky(m.second.get(inCentroidKey))) for
Expand Down
18 changes: 13 additions & 5 deletions src/KernelSolution.cc
Original file line number Diff line number Diff line change
Expand Up @@ -352,8 +352,10 @@ namespace diffim {
/* Iterators over convolved image list and basis list */
typename std::vector<Eigen::MatrixXd>::iterator eiter = convolvedEigenList.begin();
/* Create C_i in the formalism of Alard & Lupton */
afwMath::ConvolutionControl convolutionControl;
convolutionControl.setDoNormalize(false);
for (kiter = basisList.begin(); kiter != basisList.end(); ++kiter, ++eiter) {
afwMath::convolve(cimage, templateImage, **kiter, false); /* cimage stores convolved image */
afwMath::convolve(cimage, templateImage, **kiter, convolutionControl); /* cimage stores convolved image */

Eigen::MatrixXd cMat = imageToEigenMatrix(cimage).block(startRow,
startCol,
Expand Down Expand Up @@ -615,8 +617,10 @@ namespace diffim {
typename std::vector<Eigen::VectorXd>::iterator eiter = convolvedEigenList.begin();

/* Create C_i in the formalism of Alard & Lupton */
afwMath::ConvolutionControl convolutionControl;
convolutionControl.setDoNormalize(false);
for (kiter = basisList.begin(); kiter != basisList.end(); ++kiter, ++eiter) {
afwMath::convolve(cimage, templateImage, **kiter, false); /* cimage stores convolved image */
afwMath::convolve(cimage, templateImage, **kiter, convolutionControl); /* cimage stores convolved image */

ndarray::Array<InputT, 1, 1> arrayC =
ndarray::allocate(ndarray::makeVector(fullFp->getArea()));
Expand Down Expand Up @@ -771,8 +775,10 @@ namespace diffim {
/* Iterators over convolved image list and basis list */
typename std::vector<Eigen::MatrixXd>::iterator eiter = convolvedEigenList.begin();
/* Create C_i in the formalism of Alard & Lupton */
for (kiter = basisList.begin(); kiter != basisList.end(); ++kiter, ++eiter) {
afwMath::convolve(cimage, templateImage, **kiter, false); /* cimage stores convolved image */
afwMath::ConvolutionControl convolutionControl;
convolutionControl.setDoNormalize(false);
for (kiter = basisList.begin(); kiter != basisList.end(); ++kiter, ++eiter) {
afwMath::convolve(cimage, templateImage, **kiter, convolutionControl); /* cimage stores convolved image */

Eigen::MatrixXd cMat = imageToEigenMatrix(cimage).block(startRow,
startCol,
Expand Down Expand Up @@ -1003,8 +1009,10 @@ namespace diffim {
std::vector<Eigen::MatrixXd> convolvedEigenList(nKernelParameters);
typename std::vector<Eigen::MatrixXd>::iterator eiter = convolvedEigenList.begin();
/* Create C_i in the formalism of Alard & Lupton */
afwMath::ConvolutionControl convolutionControl;
convolutionControl.setDoNormalize(false);
for (kiter = basisList.begin(); kiter != basisList.end(); ++kiter, ++eiter) {
afwMath::convolve(cimage, templateImage, **kiter, false); /* cimage stores convolved image */
afwMath::convolve(cimage, templateImage, **kiter, convolutionControl); /* cimage stores convolved image */
Eigen::MatrixXd cMat(totalSize, 1);
cMat.setZero();

Expand Down
8 changes: 6 additions & 2 deletions tests/test_assessSpatialKernelVisitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ def testGood(self):
ti[50, 50, afwImage.LOCAL] = (1., 0x0, 1.)
sKernel = self.makeSpatialKernel(2)
si = afwImage.MaskedImageF(ti.getDimensions())
afwMath.convolve(si, ti, sKernel, True)
convolutionControl = afwMath.ConvolutionControl()
convolutionControl.setDoNormalize(True)
afwMath.convolve(si, ti, sKernel, convolutionControl)

bbox = geom.Box2I(geom.Point2I(25, 25),
geom.Point2I(75, 75))
Expand Down Expand Up @@ -86,7 +88,9 @@ def testBad(self):
ti[50, 50, afwImage.LOCAL] = (1., 0x0, 1.)
sKernel = self.makeSpatialKernel(2)
si = afwImage.MaskedImageF(ti.getDimensions())
afwMath.convolve(si, ti, sKernel, True)
convolutionControl = afwMath.ConvolutionControl()
convolutionControl.setDoNormalize(True)
afwMath.convolve(si, ti, sKernel, convolutionControl)

bbox = geom.Box2I(geom.Point2I(25, 25),
geom.Point2I(75, 75))
Expand Down
4 changes: 3 additions & 1 deletion tests/test_imageSubtract.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ def setUp(self):
self.templateImage = afwImage.MaskedImageF(defImagePath)
self.scienceImage = self.templateImage.Factory(self.templateImage.getDimensions())

afwMath.convolve(self.scienceImage, self.templateImage, self.gaussKernel, False)
convolutionControl = afwMath.ConvolutionControl()
convolutionControl.setDoNormalize(False)
afwMath.convolve(self.scienceImage, self.templateImage, self.gaussKernel, convolutionControl)

def tearDown(self):
del self.subconfig
Expand Down
17 changes: 11 additions & 6 deletions tests/test_kernelCandidateAndSolution.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,8 @@ def testConstructor(self):
def testSourceStats(self):
source = self.ss.addNew()
source.setId(1)
source.set(self.table.getCentroidKey().getX(), 276)
source.set(self.table.getCentroidKey().getY(), 717)
source.set(self.table.getCentroidSlot().getMeasKey().getX(), 276)
source.set(self.table.getCentroidSlot().getMeasKey().getY(), 717)
source.set("slot_PsfFlux_instFlux", 1.)

kc = ipDiffim.KernelCandidateF(source,
Expand All @@ -208,8 +208,8 @@ def testSourceStats(self):
def testSourceConstructor(self):
source = self.ss.addNew()
source.setId(1)
source.set(self.table.getCentroidKey().getX(), 276)
source.set(self.table.getCentroidKey().getY(), 717)
source.set(self.table.getCentroidSlot().getMeasKey().getX(), 276)
source.set(self.table.getCentroidSlot().getMeasKey().getY(), 717)
source.set("slot_PsfFlux_instFlux", 1.)

kc = ipDiffim.KernelCandidateF(source,
Expand Down Expand Up @@ -367,7 +367,10 @@ def testGaussianWithNoise(self):

imX, imY = self.templateExposure2.getMaskedImage().getDimensions()
smi = afwImage.MaskedImageF(geom.Extent2I(imX, imY))
afwMath.convolve(smi, self.templateExposure2.getMaskedImage(), gaussKernel, False)

convolutionControl = afwMath.ConvolutionControl()
convolutionControl.setDoNormalize(False)
afwMath.convolve(smi, self.templateExposure2.getMaskedImage(), gaussKernel, convolutionControl)

bbox = gaussKernel.shrinkBBox(smi.getBBox(afwImage.LOCAL))

Expand Down Expand Up @@ -436,7 +439,9 @@ def testGaussian(self, imsize=50):

# science image
smi = afwImage.MaskedImageF(tmi.getDimensions())
afwMath.convolve(smi, tmi, gaussKernel, False)
convolutionControl = afwMath.ConvolutionControl()
convolutionControl.setDoNormalize(False)
afwMath.convolve(smi, tmi, gaussKernel, convolutionControl)

# get the actual kernel sum (since the image is not infinite)
gscaling = afwMath.makeStatistics(smi, afwMath.SUM).getValue(afwMath.SUM)
Expand Down
4 changes: 3 additions & 1 deletion tests/test_kernelCandidateDetection.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ def setUp(self):
self.templateImage = afwImage.MaskedImageF(defImagePath)
self.scienceImage = self.templateImage.Factory(self.templateImage.getDimensions())

afwMath.convolve(self.scienceImage, self.templateImage, self.gaussKernel, False)
convolutionControl = afwMath.ConvolutionControl()
convolutionControl.setDoNormalize(False)
afwMath.convolve(self.scienceImage, self.templateImage, self.gaussKernel, convolutionControl)

def tearDown(self):
del self.config
Expand Down