LSSTApplications  8.0.0.0+107,8.0.0.1+13,9.1+18,9.2,master-g084aeec0a4,master-g0aced2eed8+6,master-g15627eb03c,master-g28afc54ef9,master-g3391ba5ea0,master-g3d0fb8ae5f,master-g4432ae2e89+36,master-g5c3c32f3ec+17,master-g60f1e072bb+1,master-g6a3ac32d1b,master-g76a88a4307+1,master-g7bce1f4e06+57,master-g8ff4092549+31,master-g98e65bf68e,master-ga6b77976b1+53,master-gae20e2b580+3,master-gb584cd3397+53,master-gc5448b162b+1,master-gc54cf9771d,master-gc69578ece6+1,master-gcbf758c456+22,master-gcec1da163f+63,master-gcf15f11bcc,master-gd167108223,master-gf44c96c709
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 11 of file makeRatingVector.py.

11 
12 def makeRatingVector(kernelCellSet, spatialKernel, spatialBg):
13  imstats = diffimLib.ImageStatisticsF()
14  #sdqaVector = sdqa.SdqaRatingSet()
15 
16  width, height = spatialKernel.getDimensions()
17  kImage = afwImage.ImageD(width, height)
18  # find the kernel sum and its Rms by looking at the 4 corners of the image
19  kSums = afwMath.vectorD()
20  for x in (0, width):
21  for y in (0, height):
22  kSum = spatialKernel.computeImage(kImage, False, x, y)
23  kSums.push_back(kSum)
24 
25  afwStat = afwMath.makeStatistics(kSums, afwMath.MEAN | afwMath.STDEV)
26  #kSumRating = sdqa.SdqaRating("lsst.ip.diffim.kernel_sum",
27  # afwStat.getValue(afwMath.MEAN),
28  # afwStat.getValue(afwMath.STDEV),
29  # scope)
30  #sdqaVector.append(kSumRating)
31 
32  nGood = 0
33  nBad = 0
34  for cell in kernelCellSet.getCellList():
35  for cand in cell.begin(False): # False = include bad candidates
36  cand = diffimLib.cast_KernelCandidateF(cand)
37  if cand.getStatus() == afwMath.SpatialCellCandidate.GOOD:
38  # this has been used for processing
39  nGood += 1
40 
41  xCand = int(cand.getXCenter())
42  yCand = int(cand.getYCenter())
43 
44  # evaluate kernel and background at position of candidate
45  kSum = spatialKernel.computeImage(kImage, False, xCand, yCand)
46  kernel = afwMath.FixedKernel(kImage)
47  background = spatialBg(xCand, yCand)
48 
49  diffIm = cand.getDifferenceImage(kernel, background)
50  imstats.apply(diffIm)
51 
52  candMean = imstats.getMean()
53  candRms = imstats.getRms()
54  #candRating = sdqa.SdqaRating("lsst.ip.diffim.residuals_%d_%d" % (xCand, yCand),
55  # candMean, candRms, scope)
56  #sdqaVector.append(candRating)
57  elif cand.getStatus() == afwMath.SpatialCellCandidate.BAD:
58  nBad += 1
59 
60  #nGoodRating = sdqa.SdqaRating("lsst.ip.diffim.nCandGood", nGood, 0, scope)
61  #sdqaVector.append(nGoodRating)
62  #nBadRating = sdqa.SdqaRating("lsst.ip.diffim.nCandBad", nBad, 0, scope)
63  #sdqaVector.append(nBadRating)
64 
65  nKernelTerms = spatialKernel.getNSpatialParameters()
66  if nKernelTerms == 0: # order 0
67  nKernelTerms = 1
68  nBgTerms = len(spatialBg.getParameters())
69  #nKernRating = sdqa.SdqaRating("lsst.ip.diffim.nTermsSpatialKernel", nKernelTerms, 0, scope)
70  #nBgRating = sdqa.SdqaRating("lsst.ip.diffim.nTermsSpatialBg", nBgTerms, 0, scope)
71  #sdqaVector.append(nKernRating)
72  #sdqaVector.append(nBgRating)
73 
74  #for i in range(sdqaVector.size()):
75  # pexLog.Trace("lsst.ip.diffim.makeSdqaRatingVector", 5,
76  # "Sdqa Rating %s : %.2f %.2f" % (sdqaVector[i].getName(),
77  # sdqaVector[i].getValue(),
78  # sdqaVector[i].getErr()))
79  #
80  #return sdqaVector
Statistics makeStatistics(afwImage::Mask< afwImage::MaskPixel > const &msk, int const flags, StatisticsControl const &sctrl)
Specialization to handle Masks.
Definition: Statistics.cc:1023
A kernel created from an Image.
Definition: Kernel.h:551