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 | Static Public Attributes | Static Private Attributes | List of all members
lsst.pipe.tasks.mocks.mockCoadd.MockCoaddTask Class Reference
Inheritance diagram for lsst.pipe.tasks.mocks.mockCoadd.MockCoaddTask:

Public Member Functions

def __init__
 
def buildSkyMap
 
def buildTruthCatalog
 
def buildObservationCatalog
 
def buildInputImages
 
def buildAllInputs
 
def makeCoaddTask
 
def iterPatchRefs
 
def buildCoadd
 
def buildMockCoadd
 

Public Attributes

 schema
 
 objectIdKey
 
 exposureIdKey
 
 centroidInBBoxKey
 
 partialOverlapKey
 

Static Public Attributes

 ConfigClass = MockCoaddConfig
 

Static Private Attributes

string _DefaultName = "MockCoadd"
 

Detailed Description

MockCoaddTask is a driver task for creating mock coadds.  As opposed to more realistic
simulations, MockCoadd generates and uses extremely simple "toy" data that can be used to more
rigorously test the behavior of high-level task code because the expected results are
more easily predicted.  In particular, calexps are generated directly from the truth catalog,
and contain only zero-noise stars that are created using the same Psf, Calib, and Wcs that will
be attached to the mock calexp.

In addition to creating the mock calexps and truth catalogs, MockCoadd also contains driver
code to run the MakeSkyMap, MakeCoaddTempExp, and AssembleCoadd tasks on the mock calexps,
and code to directly create a mock coadd image using CoaddPsf, which can be compared to the
output of the regular coadd tasks to check that the coadd code and CoaddPsf are consistent.

Note that aside from MakeSkyMapTask, the coadd tasks are *not* subtasks of MockCoaddTasks,
and their configs are not part of MockCoaddConfig; these are created locally within
MockCoaddTask methods when needed, as not all coadd task config options are appropriate
for the mock data generated by MockCoadd.

Definition at line 89 of file mockCoadd.py.

Constructor & Destructor Documentation

def lsst.pipe.tasks.mocks.mockCoadd.MockCoaddTask.__init__ (   self,
  kwds 
)
Construct a MockCoaddTask and the subtasks used for generating skymaps, objects,
and observations (i.e. calexp parameters).

Definition at line 112 of file mockCoadd.py.

113  def __init__(self, **kwds):
114  """Construct a MockCoaddTask and the subtasks used for generating skymaps, objects,
115  and observations (i.e. calexp parameters).
116  """
117  lsst.pipe.base.CmdLineTask.__init__(self, **kwds)
118  self.makeSubtask("makeSkyMap")
119  self.makeSubtask("mockObject")
120  self.makeSubtask("mockObservation")
122  self.objectIdKey = self.schema.addField("objectId", type=long, doc="foreign key to truth catalog")
123  self.exposureIdKey = self.schema.addField("exposureId", type=long,
124  doc="foreign key to observation catalog")
125  self.centroidInBBoxKey = self.schema.addField(
126  "centroidInBBox", type="Flag",
127  doc="set if this source's center position is inside the generated image's bbox"
128  )
129  self.partialOverlapKey = self.schema.addField(
130  "partialOverlap", type="Flag",
131  doc="set if this source was not completely inside the generated image"
132  )
static Schema makeMinimalSchema()
Return a minimal schema for Simple tables and records.
Definition: Simple.h:121

Member Function Documentation

def lsst.pipe.tasks.mocks.mockCoadd.MockCoaddTask.buildAllInputs (   self,
  butler 
)
Convenience function that calls buildSkyMap, buildObservationCatalog, buildTruthCatalog,
and buildInputImages.

Definition at line 209 of file mockCoadd.py.

210  def buildAllInputs(self, butler):
211  """Convenience function that calls buildSkyMap, buildObservationCatalog, buildTruthCatalog,
212  and buildInputImages.
213  """
214  skyMap = self.buildSkyMap(butler)
215  observations = self.buildObservationCatalog(butler, skyMap=skyMap)
216  truth = self.buildTruthCatalog(butler, skyMap=skyMap)
217  simSrcCatalog = self.buildInputImages(butler, obsCatalog=observations, truthCatalog=truth)
def lsst.pipe.tasks.mocks.mockCoadd.MockCoaddTask.buildCoadd (   self,
  butler,
  skyMap = None,
  tract = 0 
)
Run the coadd tasks (MakeCoaddTempExp and AssembleCoadd) on the mock data.

Must be run after buildInputImages.

Definition at line 248 of file mockCoadd.py.

249  def buildCoadd(self, butler, skyMap=None, tract=0):
250  """Run the coadd tasks (MakeCoaddTempExp and AssembleCoadd) on the mock data.
251 
252  Must be run after buildInputImages.
253  """
254  if skyMap is None:
255  skyMap = butler.get(self.config.coaddName + "Coadd_skyMap")
256  tractInfo = skyMap[tract]
257  makeCoaddTempExpTask = self.makeCoaddTask(MakeCoaddTempExpTask)
258  assembleCoaddTask = self.makeCoaddTask(AssembleCoaddTask)
259  for patchRef in self.iterPatchRefs(butler, tractInfo):
260  makeCoaddTempExpTask.run(patchRef)
261  for patchRef in self.iterPatchRefs(butler, tractInfo):
262  assembleCoaddTask.run(patchRef)
def lsst.pipe.tasks.mocks.mockCoadd.MockCoaddTask.buildInputImages (   self,
  butler,
  obsCatalog = None,
  truthCatalog = None,
  tract = 0 
)
Use the truth catalog and observation catalog to create and save (if butler is not None)
mock calexps and an ExposureCatalog ('simsrc') that contains information about which objects
appear partially or fully in each exposure.

Must be run after buildTruthCatalog and buildObservationCatalog.

Definition at line 170 of file mockCoadd.py.

171  def buildInputImages(self, butler, obsCatalog=None, truthCatalog=None, tract=0):
172  """Use the truth catalog and observation catalog to create and save (if butler is not None)
173  mock calexps and an ExposureCatalog ('simsrc') that contains information about which objects
174  appear partially or fully in each exposure.
175 
176  Must be run after buildTruthCatalog and buildObservationCatalog.
177  """
178  if obsCatalog is None:
179  obsCatalog = butler.get("observations", tract=tract)
180  if truthCatalog is None:
181  truthCatalog = butler.get("truth", tract=tract)
182  ccdKey = obsCatalog.getSchema().find("ccd").key
183  visitKey = obsCatalog.getSchema().find("visit").key
184  simSrcCatalog = lsst.afw.table.SimpleCatalog(self.schema)
185  for obsRecord in obsCatalog:
186  ccd = obsRecord.getI(ccdKey)
187  visit = obsRecord.getI(visitKey)
188  self.log.info("Generating image for visit={visit}, ccd={ccd}".format(ccd=ccd, visit=visit))
189  exposure = lsst.afw.image.ExposureF(obsRecord.getBBox())
190  exposure.setCalib(obsRecord.getCalib())
191  exposure.setWcs(obsRecord.getWcs())
192  exposure.setPsf(obsRecord.getPsf())
193  for truthRecord in truthCatalog:
194  status = self.mockObject.drawSource(truthRecord, exposure, buffer=self.config.edgeBuffer)
195  if status:
196  simSrcRecord = simSrcCatalog.addNew()
197  simSrcRecord.setCoord(truthRecord.getCoord())
198  simSrcRecord.setL(self.objectIdKey, truthRecord.getId())
199  simSrcRecord.setL(self.exposureIdKey, obsRecord.getId())
200  simSrcRecord.setFlag(self.centroidInBBoxKey, obsRecord.contains(truthRecord.getCoord()))
201  simSrcRecord.setFlag(self.partialOverlapKey, status == 1)
202  self.log.info(" added object {id}".format(id=truthRecord.getId()))
203  exposure.getMaskedImage().getVariance().set(1.0)
204  if butler is not None:
205  butler.put(exposure, "calexp", ccd=ccd, visit=visit)
206  if butler is not None:
207  butler.put(simSrcCatalog, "simsrc", tract=tract)
208  return simSrcCatalog
Custom catalog class for record/table subclasses that are guaranteed to have an ID, and should generally be sorted by that ID.
Definition: fwd.h:55
def lsst.pipe.tasks.mocks.mockCoadd.MockCoaddTask.buildMockCoadd (   self,
  butler,
  truthCatalog = None,
  skyMap = None,
  tract = 0 
)
Directly create a simulation of the coadd, using the CoaddPsf of the coadd exposure
and the truth catalog.

Must be run after buildCoadd.

Definition at line 263 of file mockCoadd.py.

264  def buildMockCoadd(self, butler, truthCatalog=None, skyMap=None, tract=0):
265  """Directly create a simulation of the coadd, using the CoaddPsf of the coadd exposure
266  and the truth catalog.
267 
268  Must be run after buildCoadd.
269  """
270  if truthCatalog is None:
271  truthCatalog = butler.get("truth", tract=tract)
272  if skyMap is None:
273  skyMap = butler.get(self.config.coaddName + "Coadd_skyMap")
274  tractInfo = skyMap[tract]
275  tractWcs = tractInfo.getWcs()
276  for patchRef in self.iterPatchRefs(butler, tractInfo):
277  exposure = patchRef.get(self.config.coaddName + "Coadd")
278  exposure.getMaskedImage().getImage().set(0.0)
280  exposure.getInfo().getCoaddInputs().ccds, exposure.getWcs()
281  )
282  exposure.setPsf(coaddPsf)
283  for truthRecord in truthCatalog:
284  self.mockObject.drawSource(truthRecord, exposure, buffer=0)
285  patchRef.put(exposure, self.config.coaddName + "Coadd_mock")
CoaddPsf is the Psf derived to be used for non-PSF-matched Coadd images.
Definition: CoaddPsf.h:45
def lsst.pipe.tasks.mocks.mockCoadd.MockCoaddTask.buildObservationCatalog (   self,
  butler = None,
  skyMap = None,
  tract = 0,
  camera = None 
)
Create and save (if butler is not None) an ExposureCatalog of simulated observations,
containing the Psfs, Wcss, Calibs, etc. of the calexps to be simulated.

Must be run after buildSkyMap.

Most of the work is delegated to the mockObservation subtask.

Definition at line 151 of file mockCoadd.py.

152  def buildObservationCatalog(self, butler=None, skyMap=None, tract=0, camera=None):
153  """Create and save (if butler is not None) an ExposureCatalog of simulated observations,
154  containing the Psfs, Wcss, Calibs, etc. of the calexps to be simulated.
155 
156  Must be run after buildSkyMap.
157 
158  Most of the work is delegated to the mockObservation subtask.
159  """
160  if skyMap is None:
161  skyMap = butler.get(self.config.coaddName + "Coadd_skyMap")
162  if camera is None:
163  camera = butler.get("camera")
164  catalog = self.mockObservation.run(butler=butler,
165  n=self.config.nObservations, camera=camera,
166  tractInfo=skyMap[tract])
167  if butler is not None:
168  butler.put(catalog, "observations", tract=tract)
169  return catalog
def lsst.pipe.tasks.mocks.mockCoadd.MockCoaddTask.buildSkyMap (   self,
  butler 
)
Build the skymap for the mock dataset.

Definition at line 133 of file mockCoadd.py.

134  def buildSkyMap(self, butler):
135  """Build the skymap for the mock dataset."""
136  return self.makeSkyMap.run(butler.dataRef(self.config.coaddName + "Coadd_skyMap")).skyMap
def lsst.pipe.tasks.mocks.mockCoadd.MockCoaddTask.buildTruthCatalog (   self,
  butler = None,
  skyMap = None,
  tract = 0 
)
Create and save (if butler is not None) a truth catalog containing all the mock objects.

Must be run after buildSkyMap.

Most of the work is delegated to the mockObject subtask.

Definition at line 137 of file mockCoadd.py.

138  def buildTruthCatalog(self, butler=None, skyMap=None, tract=0):
139  """Create and save (if butler is not None) a truth catalog containing all the mock objects.
140 
141  Must be run after buildSkyMap.
142 
143  Most of the work is delegated to the mockObject subtask.
144  """
145  if skyMap is None:
146  skyMap = butler.get(self.config.coaddName + "Coadd_skyMap")
147  catalog = self.mockObject.run(tractInfo=skyMap[tract])
148  if butler is not None:
149  butler.put(catalog, "truth", tract=tract)
150  return catalog
def lsst.pipe.tasks.mocks.mockCoadd.MockCoaddTask.iterPatchRefs (   self,
  butler,
  tractInfo 
)
Generator that iterates over the patches in a tract, yielding dataRefs.

Definition at line 237 of file mockCoadd.py.

238  def iterPatchRefs(self, butler, tractInfo):
239  """Generator that iterates over the patches in a tract, yielding dataRefs.
240  """
241  nPatchX, nPatchY = tractInfo.getNumPatches()
242  for iPatchX in range(nPatchX):
243  for iPatchY in range(nPatchY):
244  patchRef = butler.dataRef(self.config.coaddName + "Coadd",
245  tract=tractInfo.getId(), patch="%d,%d" % (iPatchX,iPatchY),
246  filter='r')
247  yield patchRef
def lsst.pipe.tasks.mocks.mockCoadd.MockCoaddTask.makeCoaddTask (   self,
  cls 
)
Helper function to create a Coadd task with configuration appropriate for the simulations.

MockCoaddTask does not include MakeCoaddTempExpTask or AssembleCoaddTask as subtasks, because
we want explicit control over their configs, rather than leaving this up to the user.
However, we have to install our own SelectImages task for both of these, so it made sense
to have a single method that would create one of these two tasks, set the config values we
want, and install the custom SelectImagesTask.

Definition at line 218 of file mockCoadd.py.

219  def makeCoaddTask(self, cls):
220  """Helper function to create a Coadd task with configuration appropriate for the simulations.
221 
222  MockCoaddTask does not include MakeCoaddTempExpTask or AssembleCoaddTask as subtasks, because
223  we want explicit control over their configs, rather than leaving this up to the user.
224  However, we have to install our own SelectImages task for both of these, so it made sense
225  to have a single method that would create one of these two tasks, set the config values we
226  want, and install the custom SelectImagesTask.
227  """
228  config = cls.ConfigClass()
229  config.coaddName = self.config.coaddName
230  config.select.retarget(MockSelectImagesTask)
231  if cls == MakeCoaddTempExpTask:
232  config.bgSubtracted = True
233  config.doPsfMatch = False
234  elif cls == AssembleCoaddTask:
235  config.doMatchBackgrounds = False
236  return cls(config)

Member Data Documentation

string lsst.pipe.tasks.mocks.mockCoadd.MockCoaddTask._DefaultName = "MockCoadd"
staticprivate

Definition at line 110 of file mockCoadd.py.

lsst.pipe.tasks.mocks.mockCoadd.MockCoaddTask.centroidInBBoxKey

Definition at line 124 of file mockCoadd.py.

lsst.pipe.tasks.mocks.mockCoadd.MockCoaddTask.ConfigClass = MockCoaddConfig
static

Definition at line 108 of file mockCoadd.py.

lsst.pipe.tasks.mocks.mockCoadd.MockCoaddTask.exposureIdKey

Definition at line 122 of file mockCoadd.py.

lsst.pipe.tasks.mocks.mockCoadd.MockCoaddTask.objectIdKey

Definition at line 121 of file mockCoadd.py.

lsst.pipe.tasks.mocks.mockCoadd.MockCoaddTask.partialOverlapKey

Definition at line 128 of file mockCoadd.py.

lsst.pipe.tasks.mocks.mockCoadd.MockCoaddTask.schema

Definition at line 120 of file mockCoadd.py.


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