LSSTApplications  1.1.2+25,10.0+13,10.0+132,10.0+133,10.0+224,10.0+41,10.0+8,10.0-1-g0f53050+14,10.0-1-g4b7b172+19,10.0-1-g61a5bae+98,10.0-1-g7408a83+3,10.0-1-gc1e0f5a+19,10.0-1-gdb4482e+14,10.0-11-g3947115+2,10.0-12-g8719d8b+2,10.0-15-ga3f480f+1,10.0-2-g4f67435,10.0-2-gcb4bc6c+26,10.0-28-gf7f57a9+1,10.0-3-g1bbe32c+14,10.0-3-g5b46d21,10.0-4-g027f45f+5,10.0-4-g86f66b5+2,10.0-4-gc4fccf3+24,10.0-40-g4349866+2,10.0-5-g766159b,10.0-5-gca2295e+25,10.0-6-g462a451+1
LSSTDataManagementBasePackage
makeRatingVector.py
Go to the documentation of this file.
1 # all the c++ level classes and routines
2 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 def makeRatingVector(kernelCellSet, spatialKernel, spatialBg):
11  imstats = diffimLib.ImageStatisticsF()
12  #sdqaVector = sdqa.SdqaRatingSet()
13 
14  width, height = spatialKernel.getDimensions()
15  kImage = afwImage.ImageD(width, height)
16  # find the kernel sum and its Rms by looking at the 4 corners of the image
17  kSums = afwMath.vectorD()
18  for x in (0, width):
19  for y in (0, height):
20  kSum = spatialKernel.computeImage(kImage, False, x, y)
21  kSums.push_back(kSum)
22 
23  #afwStat = afwMath.makeStatistics(kSums, afwMath.MEAN | afwMath.STDEV)
24  #kSumRating = sdqa.SdqaRating("lsst.ip.diffim.kernel_sum",
25  # afwStat.getValue(afwMath.MEAN),
26  # afwStat.getValue(afwMath.STDEV),
27  # scope)
28  #sdqaVector.append(kSumRating)
29 
30  nGood = 0
31  nBad = 0
32  for cell in kernelCellSet.getCellList():
33  for cand in cell.begin(False): # False = include bad candidates
34  cand = diffimLib.cast_KernelCandidateF(cand)
35  if cand.getStatus() == afwMath.SpatialCellCandidate.GOOD:
36  # this has been used for processing
37  nGood += 1
38 
39  xCand = int(cand.getXCenter())
40  yCand = int(cand.getYCenter())
41 
42  # evaluate kernel and background at position of candidate
43  kSum = spatialKernel.computeImage(kImage, False, xCand, yCand)
44  kernel = afwMath.FixedKernel(kImage)
45  background = spatialBg(xCand, yCand)
46 
47  diffIm = cand.getDifferenceImage(kernel, background)
48  imstats.apply(diffIm)
49 
50  #candMean = imstats.getMean()
51  #candRms = imstats.getRms()
52  #candRating = sdqa.SdqaRating("lsst.ip.diffim.residuals_%d_%d" % (xCand, yCand),
53  # candMean, candRms, scope)
54  #sdqaVector.append(candRating)
55  elif cand.getStatus() == afwMath.SpatialCellCandidate.BAD:
56  nBad += 1
57 
58  #nGoodRating = sdqa.SdqaRating("lsst.ip.diffim.nCandGood", nGood, 0, scope)
59  #sdqaVector.append(nGoodRating)
60  #nBadRating = sdqa.SdqaRating("lsst.ip.diffim.nCandBad", nBad, 0, scope)
61  #sdqaVector.append(nBadRating)
62 
63  nKernelTerms = spatialKernel.getNSpatialParameters()
64  if nKernelTerms == 0: # order 0
65  nKernelTerms = 1
66  #nBgTerms = len(spatialBg.getParameters())
67  #nKernRating = sdqa.SdqaRating("lsst.ip.diffim.nTermsSpatialKernel", nKernelTerms, 0, scope)
68  #nBgRating = sdqa.SdqaRating("lsst.ip.diffim.nTermsSpatialBg", nBgTerms, 0, scope)
69  #sdqaVector.append(nKernRating)
70  #sdqaVector.append(nBgRating)
71 
72  #for i in range(sdqaVector.size()):
73  # pexLog.Trace("lsst.ip.diffim.makeSdqaRatingVector", 5,
74  # "Sdqa Rating %s : %.2f %.2f" % (sdqaVector[i].getName(),
75  # sdqaVector[i].getValue(),
76  # sdqaVector[i].getErr()))
77  #
78  #return sdqaVector
A kernel created from an Image.
Definition: Kernel.h:551