LSSTApplications  11.0-13-gbb96280,12.1.rc1,12.1.rc1+1,12.1.rc1+2,12.1.rc1+5,12.1.rc1+8,12.1.rc1-1-g06d7636+1,12.1.rc1-1-g253890b+5,12.1.rc1-1-g3d31b68+7,12.1.rc1-1-g3db6b75+1,12.1.rc1-1-g5c1385a+3,12.1.rc1-1-g83b2247,12.1.rc1-1-g90cb4cf+6,12.1.rc1-1-g91da24b+3,12.1.rc1-2-g3521f8a,12.1.rc1-2-g39433dd+4,12.1.rc1-2-g486411b+2,12.1.rc1-2-g4c2be76,12.1.rc1-2-gc9c0491,12.1.rc1-2-gda2cd4f+6,12.1.rc1-3-g3391c73+2,12.1.rc1-3-g8c1bd6c+1,12.1.rc1-3-gcf4b6cb+2,12.1.rc1-4-g057223e+1,12.1.rc1-4-g19ed13b+2,12.1.rc1-4-g30492a7
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:548