Skip to content

Commit

Permalink
ForcedPhot tasks are now responsible for attaching Footrints to sources
Browse files Browse the repository at this point in the history
Forced photometry previously relied on the MeasureSources class to
transform reference Footprints and attach them to sources, but we've
moved that responsibility here so we can override it at the Python
level in the future.
  • Loading branch information
TallJimbo committed Dec 16, 2014
1 parent 2186e13 commit 0f29c18
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions python/lsst/pipe/tasks/forcedPhotImage.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ class ForcedPhotImageTask(CmdLineTask):
- Set the _DefaultName class attribute
- Implement makeIdFactory
- Implement fetchReferences
- (optional) Implement attachFootprints
"""

RunnerClass = ButlerInitializedTaskRunner
Expand Down Expand Up @@ -130,6 +131,24 @@ def fetchReferences(self, dataRef, exposure):
"""
raise NotImplementedError()

def attachFootprints(self, dataRef, sources, references, exposure, refWcs):
"""Hook for derived classes to define how to attach Footprints to blank sources prior to measurement
Footprints for forced photometry must be in the pixel coordinate system of the image being
measured, while the actual detections may start out in a different coordinate system.
Subclasses for ForcedPhotImageTask must implement this method to define how those Footprints
should be generated.
The default implementation transforms the Footprints from the reference catalog from the refWcs
to the exposure's Wcs, which downgrades HeavyFootprints into regular Footprints, destroying
deblend information.
"""
exposureWcs = exposure.getWcs()
region = exposure.getBBox(lsst.afw.image.PARENT)
for refRecord, srcRecord in zip(sources, references):
srcRecord.setFootprint(refRecord.getFootprint().transform(refWcs, exposureWcs, region))

def getExposure(self, dataRef):
"""Read input exposure on which to perform the measurements
Expand Down Expand Up @@ -181,6 +200,7 @@ def run(self, dataRef):
references = list(self.fetchReferences(dataRef, exposure))
self.log.info("Performing forced measurement on %d sources" % len(references))
sources = self.generateSources(dataRef, references)
self.attachFootprints(dataRef, sources, references=references, exposure=exposure, refWcs=refWcs)
self.measurement.run(exposure, sources, references=references, refWcs=refWcs)
self.writeOutput(dataRef, sources)
return Struct(sources=sources)
Expand Down

0 comments on commit 0f29c18

Please sign in to comment.