LSSTApplications  10.0+286,10.0+36,10.0+46,10.0-2-g4f67435,10.1+152,10.1+37,11.0,11.0+1,11.0-1-g47edd16,11.0-1-g60db491,11.0-1-g7418c06,11.0-2-g04d2804,11.0-2-g68503cd,11.0-2-g818369d,11.0-2-gb8b8ce7
LSSTDataManagementBasePackage
Functions
lsst.ip.diffim.makeRatingVector Namespace Reference

Functions

def makeRatingVector
 

Function Documentation

def lsst.ip.diffim.makeRatingVector.makeRatingVector (   kernelCellSet,
  spatialKernel,
  spatialBg 
)

Definition at line 10 of file makeRatingVector.py.

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.cast_KernelCandidateF(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:551