LSSTApplications  11.0-13-gbb96280,12.1+18,12.1+7,12.1-1-g14f38d3+72,12.1-1-g16c0db7+5,12.1-1-g5961e7a+84,12.1-1-ge22e12b+23,12.1-11-g06625e2+4,12.1-11-g0d7f63b+4,12.1-19-gd507bfc,12.1-2-g7dda0ab+38,12.1-2-gc0bc6ab+81,12.1-21-g6ffe579+2,12.1-21-gbdb6c2a+4,12.1-24-g941c398+5,12.1-3-g57f6835+7,12.1-3-gf0736f3,12.1-37-g3ddd237,12.1-4-gf46015e+5,12.1-5-g06c326c+20,12.1-5-g648ee80+3,12.1-5-gc2189d7+4,12.1-6-ga608fc0+1,12.1-7-g3349e2a+5,12.1-7-gfd75620+9,12.1-9-g577b946+5,12.1-9-gc4df26a+10
LSSTDataManagementBasePackage
makeRatingVector.py
Go to the documentation of this file.
1 # all the c++ level classes and routines
2 from . import diffimLib
3 
4 # all the other LSST packages
5 import lsst.afw.image as afwImage
6 import lsst.afw.math as afwMath
7 
8 # Basically deprecated until SDQA is replaced
9 
10 
11 def makeRatingVector(kernelCellSet, spatialKernel, spatialBg):
12  imstats = diffimLib.ImageStatisticsF()
13  #sdqaVector = sdqa.SdqaRatingSet()
14 
15  width, height = spatialKernel.getDimensions()
16  kImage = afwImage.ImageD(width, height)
17  # find the kernel sum and its Rms by looking at the 4 corners of the image
18  kSums = afwMath.vectorD()
19  for x in (0, width):
20  for y in (0, height):
21  kSum = spatialKernel.computeImage(kImage, False, x, y)
22  kSums.push_back(kSum)
23 
24  #afwStat = afwMath.makeStatistics(kSums, afwMath.MEAN | afwMath.STDEV)
25  #kSumRating = sdqa.SdqaRating("lsst.ip.diffim.kernel_sum",
26  # afwStat.getValue(afwMath.MEAN),
27  # afwStat.getValue(afwMath.STDEV),
28  # scope)
29  #sdqaVector.append(kSumRating)
30 
31  nGood = 0
32  nBad = 0
33  for cell in kernelCellSet.getCellList():
34  for cand in cell.begin(False): # False = include bad candidates
35  cand = diffimLib.KernelCandidateF.cast(cand)
36  if cand.getStatus() == afwMath.SpatialCellCandidate.GOOD:
37  # this has been used for processing
38  nGood += 1
39 
40  xCand = int(cand.getXCenter())
41  yCand = int(cand.getYCenter())
42 
43  # evaluate kernel and background at position of candidate
44  kSum = spatialKernel.computeImage(kImage, False, xCand, yCand)
45  kernel = afwMath.FixedKernel(kImage)
46  background = spatialBg(xCand, yCand)
47 
48  diffIm = cand.getDifferenceImage(kernel, background)
49  imstats.apply(diffIm)
50 
51  #candMean = imstats.getMean()
52  #candRms = imstats.getRms()
53  #candRating = sdqa.SdqaRating("lsst.ip.diffim.residuals_%d_%d" % (xCand, yCand),
54  # candMean, candRms, scope)
55  #sdqaVector.append(candRating)
56  elif cand.getStatus() == afwMath.SpatialCellCandidate.BAD:
57  nBad += 1
58 
59  #nGoodRating = sdqa.SdqaRating("lsst.ip.diffim.nCandGood", nGood, 0, scope)
60  #sdqaVector.append(nGoodRating)
61  #nBadRating = sdqa.SdqaRating("lsst.ip.diffim.nCandBad", nBad, 0, scope)
62  #sdqaVector.append(nBadRating)
63 
64  nKernelTerms = spatialKernel.getNSpatialParameters()
65  if nKernelTerms == 0: # order 0
66  nKernelTerms = 1
67  #nBgTerms = len(spatialBg.getParameters())
68  #nKernRating = sdqa.SdqaRating("lsst.ip.diffim.nTermsSpatialKernel", nKernelTerms, 0, scope)
69  #nBgRating = sdqa.SdqaRating("lsst.ip.diffim.nTermsSpatialBg", nBgTerms, 0, scope)
70  #sdqaVector.append(nKernRating)
71  #sdqaVector.append(nBgRating)
72 
73  #for i in range(sdqaVector.size()):
74  # pexLog.Trace("lsst.ip.diffim.makeSdqaRatingVector", 5,
75  # "Sdqa Rating %s : %.2f %.2f" % (sdqaVector[i].getName(),
76  # sdqaVector[i].getValue(),
77  # sdqaVector[i].getErr()))
78  #
79  #return sdqaVector
A kernel created from an Image.
Definition: Kernel.h:548