Skip to content

Commit

Permalink
Refactor ForcedPhotImageTask.runDataRef to new run.
Browse files Browse the repository at this point in the history
  • Loading branch information
czwa committed Aug 27, 2018
1 parent f9130ea commit 19cffbb
Showing 1 changed file with 23 additions and 7 deletions.
30 changes: 23 additions & 7 deletions python/lsst/meas/base/forcedPhotImage.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,17 +121,14 @@ def __init__(self, butler=None, refSchema=None, **kwds):
self.makeSubtask('catalogCalculation', schema=self.measurement.schema)

def runDataRef(self, dataRef, psfCache=None):
"""!Measure a single exposure using forced detection for a reference catalog.
"""!Measure a single exposure for forced detection for a reference catalog using a dataRef.
@param[in] dataRef An lsst.daf.persistence.ButlerDataRef. It is passed to the
references subtask to obtain the reference WCS, the getExposure()
method (implemented by derived classes) to read the measurement
image, and the fetchReferences() method (implemented by derived
classes) to get the exposure and load the reference catalog (see
the CoaddSrcReferencesTask for more information). Sources are
generated with generateMeasCat() in the measurement subtask. These
are passed to measurement's run method which fills the source
catalog with the forced measurement results. The sources are then
the CoaddSrcReferencesTask for more information). The sources are then
passed to the writeOutputs() method (implemented by derived classes)
which writes the outputs. See derived class documentation for which
datasets and data ID keys are used.
Expand All @@ -143,21 +140,40 @@ def runDataRef(self, dataRef, psfCache=None):
if psfCache is not None:
exposure.getPsf().setCacheSize(psfCache)
refCat = self.fetchReferences(dataRef, exposure)

measCat = self.measurement.generateMeasCat(exposure, refCat, refWcs,
idFactory=self.makeIdFactory(dataRef))
self.log.info("Performing forced measurement on %s" % (dataRef.dataId,))
self.attachFootprints(measCat, refCat, exposure, refWcs, dataRef)

self.measurement.run(measCat, exposure, refCat, refWcs, exposureId=self.getExposureId(dataRef))
exposureId = self.getExposureId(dataRef)

forcedPhotResult = self.run(measCat, exposure, refCat, refWcs, exposureId=exposureId)

self.writeOutput(dataRef, forcedPhotResult.measCat)

def run(self, measCat, exposure, refCat, refWcs, exposureId=None):
"""!Measure a single exposure with forced detection for a reference catalog.
@param[in] measCat The measurement catalog generated by measurement.generateMeasCat(),
based on the sources listed in the reference catalog.
@param[in] exposure The measurement image upon which to perform forced detection.
@param[in] refCat The reference catalog of sources to measure.
@param[in] refWcs The WCS for the references.
@param[in] exposureId Optional unique exposureId used for random seed in measurement task.
@return result An lsst.pipe.base.Struct containing the catalog of forced measurement results
from measurement.run().
"""
self.measurement.run(measCat, exposure, refCat, refWcs, exposureId=exposureId)
if self.config.doApCorr:
self.applyApCorr.run(
catalog=measCat,
apCorrMap=exposure.getInfo().getApCorrMap()
)
self.catalogCalculation.run(measCat)

self.writeOutput(dataRef, measCat)
return lsst.pipe.base.Struct(measCat=measCat)

def makeIdFactory(self, dataRef):
"""!Hook for derived classes to define how to make an IdFactory for forced sources.
Expand Down

0 comments on commit 19cffbb

Please sign in to comment.