Skip to content

Commit

Permalink
Move reference filtering from forcedPhotImage to forcedPhotCcd.
Browse files Browse the repository at this point in the history
  • Loading branch information
TallJimbo committed May 15, 2015
1 parent 6f5ee25 commit d369520
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
16 changes: 15 additions & 1 deletion python/lsst/pipe/tasks/forcedPhotCcd.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,21 @@ def makeIdFactory(self, dataRef):
return lsst.afw.table.IdFactory.makeSource(expId, 64 - expBits)

def fetchReferences(self, dataRef, exposure):
return self.references.fetchInBox(dataRef, exposure.getBBox(lsst.afw.image.PARENT), exposure.getWcs())
references = lsst.afw.table.SourceCatalog(self.references.schema)
badParents = set()
unfiltered = self.references.fetchInBox(dataRef, exposure.getBBox(lsst.afw.image.PARENT), exposure.getWcs())
for record in unfiltered:
if record.getFootprint() is None or record.getFootprint().getArea() == 0:
if record.getParent() != 0:
self.log.warn("Skipping reference %s (child of %s) with bad Footprint" %
(record.getId(), record.getParent()))
else:
self.log.warn("Skipping reference parent %s with bad Footprint" % (record.getId(),))
badParents.add(record.getId())
elif record.getParent() not in badParents:
references.append(record)
references.sort() # need to ensure catalog is in ID order so find methods work
return references

def getExposure(self, dataRef):
"""Read input exposure to measure
Expand Down
14 changes: 1 addition & 13 deletions python/lsst/pipe/tasks/forcedPhotImage.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,20 +197,8 @@ def run(self, dataRef):
refWcs = self.references.getWcs(dataRef)
exposure = self.getExposure(dataRef)
if exposure:
references = lsst.afw.table.SourceCatalog(self.references.schema)
self.log.info("Performing forced measurement on %s" % dataRef.dataId)
badParents = set()
for record in self.fetchReferences(dataRef, exposure):
if record.getFootprint() is None or record.getFootprint().getArea() == 0:
if record.getParent() != 0:
self.log.warn("Skipping reference %s (child of %s) with bad Footprint" %
(record.getId(), record.getParent()))
else:
self.log.warn("Skipping reference parent %s with bad Footprint" % (record.getId(),))
badParents.add(record.getId())
elif record.getParent() not in badParents:
references.append(record)
references.sort() # need to ensure catalog is in ID order so find methods work
references = self.fetchReferences(dataRef, exposure))
sources = self.generateSources(dataRef, references)
self.attachFootprints(dataRef, sources, references=references, exposure=exposure, refWcs=refWcs)
self.measurement.run(exposure, sources, references=references, refWcs=refWcs)
Expand Down

0 comments on commit d369520

Please sign in to comment.