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
Public Member Functions | Public Attributes | List of all members
lsst.ip.diffim.diaSourceAnalysis.DiaSourceAnalyst Class Reference
Inheritance diagram for lsst.ip.diffim.diaSourceAnalysis.DiaSourceAnalyst:

Public Member Functions

def __init__
 
def countDetected
 
def countMasked
 
def countPolarity
 
def testSource
 

Public Attributes

 config
 
 bitMask
 

Detailed Description

Definition at line 96 of file diaSourceAnalysis.py.

Constructor & Destructor Documentation

def lsst.ip.diffim.diaSourceAnalysis.DiaSourceAnalyst.__init__ (   self,
  config 
)

Definition at line 97 of file diaSourceAnalysis.py.

97 
98  def __init__(self, config):
99  self.config = config
100 
101  self.bitMask = 0
102  srcBadMaskPlanes = self.config.srcBadMaskPlanes
103  for maskPlane in srcBadMaskPlanes:
104  self.bitMask |= afwImage.MaskU_getPlaneBitMask(maskPlane)

Member Function Documentation

def lsst.ip.diffim.diaSourceAnalysis.DiaSourceAnalyst.countDetected (   self,
  mask 
)

Definition at line 105 of file diaSourceAnalysis.py.

106  def countDetected(self, mask):
107  idxP = num.where(mask & afwImage.MaskU_getPlaneBitMask("DETECTED"))
108  idxN = num.where(mask & afwImage.MaskU_getPlaneBitMask("DETECTED_NEGATIVE"))
109  return len(idxP[0]), len(idxN[0])
def lsst.ip.diffim.diaSourceAnalysis.DiaSourceAnalyst.countMasked (   self,
  mask 
)

Definition at line 110 of file diaSourceAnalysis.py.

111  def countMasked(self, mask):
112  idxM = num.where(mask & self.bitMask)
113  return len(idxM[0])
def lsst.ip.diffim.diaSourceAnalysis.DiaSourceAnalyst.countPolarity (   self,
  mask,
  pixels 
)

Definition at line 114 of file diaSourceAnalysis.py.

115  def countPolarity(self, mask, pixels):
116  unmasked = ((mask & self.bitMask) == 0)
117  idxP = num.where( (pixels >= 0) & unmasked)
118  idxN = num.where( (pixels < 0) & unmasked)
119  fluxP = num.sum(pixels[idxP])
120  fluxN = num.sum(pixels[idxN])
121  #import pdb; pdb.set_trace()
122  return len(idxP[0]), len(idxN[0]), fluxP, fluxN
def lsst.ip.diffim.diaSourceAnalysis.DiaSourceAnalyst.testSource (   self,
  source,
  subMi 
)

Definition at line 123 of file diaSourceAnalysis.py.

124  def testSource(self, source, subMi):
125  imArr, maArr, varArr = subMi.getArrays()
126  flux = source.getApFlux()
127 
128  nPixels = subMi.getWidth() * subMi.getHeight()
129  nPos, nNeg, fPos, fNeg = self.countPolarity(maArr, imArr)
130  nDetPos, nDetNeg = self.countDetected(maArr)
131  nMasked = self.countMasked(maArr)
132  assert (nPixels == (nMasked + nPos + nNeg))
133 
134  # 1) Too many pixels in the detection are masked
135  fMasked = (nMasked / nPixels)
136  fMaskedTol = self.config.fBadPixels
137  if fMasked > fMaskedTol:
138  pexLog.Trace("lsst.ip.diffim.DiaSourceAnalysis", 1,
139  "Candidate %d : BAD fBadPixels %.2f > %.2f" % (source.getId(), fMasked, fMaskedTol))
140  return False
141 
142  if flux > 0:
143  # positive-going source
144  fluxRatio = fPos / (fPos + abs(fNeg))
145  ngoodRatio = nPos / nPixels
146  maskRatio = nPos / (nPos + nMasked)
147  npolRatio = nPos / (nPos + nNeg)
148  else:
149  # negative-going source
150  fluxRatio = abs(fNeg)/ (fPos + abs(fNeg))
151  ngoodRatio = nNeg / nPixels
152  maskRatio = nNeg / (nNeg + nMasked)
153  npolRatio = nNeg / (nNeg + nPos)
154 
155  # 2) Not enough flux in unmasked correct-polarity pixels
156  fluxRatioTolerance = self.config.fluxPolarityRatio
157  if fluxRatio < fluxRatioTolerance:
158  pexLog.Trace("lsst.ip.diffim.DiaSourceAnalysis", 1,
159  "Candidate %d : BAD flux polarity %.2f < %.2f (pos=%.2f neg=%.2f)" % (source.getId(),
160  fluxRatio, fluxRatioTolerance, fPos, fNeg))
161  return False
162 
163  # 3) Not enough unmasked pixels of correct polarity
164  polarityTolerance = self.config.nPolarityRatio
165  if npolRatio < polarityTolerance:
166  pexLog.Trace("lsst.ip.diffim.DiaSourceAnalysis", 1,
167  "Candidate %d : BAD polarity count %.2f < %.2f (pos=%d neg=%d)" % (source.getId(),
168  npolRatio, polarityTolerance, nPos, nNeg))
169  return False
170 
171  # 4) Too many masked vs. correct polarity pixels
172  maskedTolerance = self.config.nMaskedRatio
173  if maskRatio < maskedTolerance:
174  pexLog.Trace("lsst.ip.diffim.DiaSourceAnalysis", 1,
175  "Candidate %d : BAD unmasked count %.2f < %.2f (pos=%d neg=%d mask=%d)" % (source.getId(),
176  maskRatio, maskedTolerance, nPos, nNeg, nMasked))
177  return False
178 
179  # 5) Too few unmasked, correct polarity pixels
180  ngoodTolerance = self.config.nGoodRatio
181  if ngoodRatio < ngoodTolerance:
182  pexLog.Trace("lsst.ip.diffim.DiaSourceAnalysis", 1,
183  "Candidate %d : BAD good pixel count %.2f < %.2f (pos=%d neg=%d tot=%d)" % (source.getId(),
184  ngoodRatio, ngoodTolerance, nPos, nNeg, nPixels))
185  return False
186 
187  pexLog.Trace("lsst.ip.diffim.DiaSourceAnalysis", 1,
188  "Candidate %d : OK flux=%.2f nPos=%d nNeg=%d nTot=%d nDetPos=%d nDetNeg=%d fPos=%.2f fNeg=%2f" % (source.getId(),
189  flux, nPos, nNeg, nPixels, nDetPos, nDetNeg, fPos, fNeg))
190  return True
191 
limited backward compatibility to the DC2 run-time trace facilities
Definition: Trace.h:93

Member Data Documentation

lsst.ip.diffim.diaSourceAnalysis.DiaSourceAnalyst.bitMask

Definition at line 100 of file diaSourceAnalysis.py.

lsst.ip.diffim.diaSourceAnalysis.DiaSourceAnalyst.config

Definition at line 98 of file diaSourceAnalysis.py.


The documentation for this class was generated from the following file: