LSSTApplications  17.0+11,17.0+34,17.0+56,17.0+57,17.0+59,17.0+7,17.0-1-g377950a+33,17.0.1-1-g114240f+2,17.0.1-1-g4d4fbc4+28,17.0.1-1-g55520dc+49,17.0.1-1-g5f4ed7e+52,17.0.1-1-g6dd7d69+17,17.0.1-1-g8de6c91+11,17.0.1-1-gb9095d2+7,17.0.1-1-ge9fec5e+5,17.0.1-1-gf4e0155+55,17.0.1-1-gfc65f5f+50,17.0.1-1-gfc6fb1f+20,17.0.1-10-g87f9f3f+1,17.0.1-11-ge9de802+16,17.0.1-16-ga14f7d5c+4,17.0.1-17-gc79d625+1,17.0.1-17-gdae4c4a+8,17.0.1-2-g26618f5+29,17.0.1-2-g54f2ebc+9,17.0.1-2-gf403422+1,17.0.1-20-g2ca2f74+6,17.0.1-23-gf3eadeb7+1,17.0.1-3-g7e86b59+39,17.0.1-3-gb5ca14a,17.0.1-3-gd08d533+40,17.0.1-30-g596af8797,17.0.1-4-g59d126d+4,17.0.1-4-gc69c472+5,17.0.1-6-g5afd9b9+4,17.0.1-7-g35889ee+1,17.0.1-7-gc7c8782+18,17.0.1-9-gc4bbfb2+3,w.2019.22
LSSTDataManagementBasePackage
detectOnlyFakes.py
Go to the documentation of this file.
1 import lsst.pex.config as pexConfig
2 import lsst.pipe.base as pipeBase
3 import lsst.afw.table as afwTable
4 import lsst.meas.algorithms as measAlg
5 import lsst.afw.detection as afwDetect
6 
7 # WARNING: if you want to add configuration variables (maybe how close you are
8 # to a fake object), you will need to deal with the fact that the configuration
9 # for a retargeted subtask (like this one) blows away any overrides in setDefault of
10 # the parent task (processCoadd in this case) and, it seems any camera specific
11 # overrides in $OBS_SUBARU/config/hsc/processCcd.py.
12 # See https://dev.lsstcorp.org/trac/ticket/2282 for more details
13 # I think you need something like cmdLineTask.applyOverrides to deal with this
14 
15 
16 class OnlyFakesDetectionConfig(measAlg.SourceDetectionTask.ConfigClass):
17  dummyVar = pexConfig.Field(doc='Dummy config variable, does nothing',
18  dtype=bool, default=True)
19 
20 
21 class OnlyFakesDetectionTask(measAlg.SourceDetectionTask):
22  """This task serves culls the source list to sources which overlap with fakes"""
23 
24  # WARNING: we are using the parent configuration class instead of the
25  # OnlyFakesDetectionConfig to avoid having to fix overridden config parameters
26  # from processCoaddConfig.setDefaults and from the camera-specific $OBS_SUBARU/config
27  ConfigClass = measAlg.SourceDetectionConfig
28 
29  def makeSourceCatalog(self, table, exposure, doSmooth=True, sigma=None, clearMask=True):
30  if self.negativeFlagKey is not None and self.negativeFlagKey not in table.getSchema():
31  raise ValueError("Table has incorrect Schema")
32 
33  # detect the footprints as usual
34  fpSets = self.detectFootprints(exposure=exposure, doSmooth=doSmooth, sigma=sigma,
35  clearMask=clearMask)
36 
37  # ignore objects whose footprints do NOT overlap with the 'FAKE' mask
38  mask = exposure.getMaskedImage().getMask()
39  fakebit = mask.getPlaneBitMask('FAKE')
40  fpPos = fpSets.positive.getFootprints()
41  removes = []
42  for i_foot, foot in enumerate(fpPos):
43  footTmp = afwDetect.Footprint(foot)
44  footTmp.intersectMask(mask, fakebit)
45  if footTmp.getArea() == foot.getArea():
46  removes.append(i_foot)
47  removes = sorted(removes, reverse=True)
48  for r in removes:
49  del fpPos[r]
50 
51  self.log.info("Found %d sources near fake footprints" % len(fpPos))
52 
53  fpSets.numPos = len(fpPos)
54  if fpSets.negative:
55  del fpSets.negative.getFootprints()[0:]
56  fpSets.negative = None
57 
58  # make sources
59  sources = afwTable.SourceCatalog(table)
60  table.preallocate(fpSets.numPos)
61  if fpSets.positive:
62  fpSets.positive.makeSources(sources)
63 
64  return pipeBase.Struct(sources=sources, fpSets=fpSets)
def makeSourceCatalog(self, table, exposure, doSmooth=True, sigma=None, clearMask=True)
Fit spatial kernel using approximate fluxes for candidates, and solving a linear system of equations...
Class to describe the properties of a detected object from an image.
Definition: Footprint.h:62