LSST Applications  21.0.0-172-gfb10e10a+18fedfabac,22.0.0+297cba6710,22.0.0+80564b0ff1,22.0.0+8d77f4f51a,22.0.0+a28f4c53b1,22.0.0+dcf3732eb2,22.0.1-1-g7d6de66+2a20fdde0d,22.0.1-1-g8e32f31+297cba6710,22.0.1-1-geca5380+7fa3b7d9b6,22.0.1-12-g44dc1dc+2a20fdde0d,22.0.1-15-g6a90155+515f58c32b,22.0.1-16-g9282f48+790f5f2caa,22.0.1-2-g92698f7+dcf3732eb2,22.0.1-2-ga9b0f51+7fa3b7d9b6,22.0.1-2-gd1925c9+bf4f0e694f,22.0.1-24-g1ad7a390+a9625a72a8,22.0.1-25-g5bf6245+3ad8ecd50b,22.0.1-25-gb120d7b+8b5510f75f,22.0.1-27-g97737f7+2a20fdde0d,22.0.1-32-gf62ce7b1+aa4237961e,22.0.1-4-g0b3f228+2a20fdde0d,22.0.1-4-g243d05b+871c1b8305,22.0.1-4-g3a563be+32dcf1063f,22.0.1-4-g44f2e3d+9e4ab0f4fa,22.0.1-42-gca6935d93+ba5e5ca3eb,22.0.1-5-g15c806e+85460ae5f3,22.0.1-5-g58711c4+611d128589,22.0.1-5-g75bb458+99c117b92f,22.0.1-6-g1c63a23+7fa3b7d9b6,22.0.1-6-g50866e6+84ff5a128b,22.0.1-6-g8d3140d+720564cf76,22.0.1-6-gd805d02+cc5644f571,22.0.1-8-ge5750ce+85460ae5f3,master-g6e05de7fdc+babf819c66,master-g99da0e417a+8d77f4f51a,w.2021.48
LSST Data Management Base Package
Public Member Functions | Public Attributes | Static Public Attributes | List of all members
lsst.meas.base.references.MultiBandReferencesTask Class Reference
Inheritance diagram for lsst.meas.base.references.MultiBandReferencesTask:
lsst.meas.base.references.CoaddSrcReferencesTask lsst.meas.base.references.BaseReferencesTask

Public Member Functions

def getWcs (self, dataRef)
 
def fetchInPatches (self, dataRef, patchList)
 
def fetchInBox (self, dataRef, bbox, wcs, pad=0)
 
def fetchInBox (self, dataRef, bbox, wcs)
 
def getSchema (self, butler)
 
def subset (self, sources, bbox, wcs)
 

Public Attributes

 schema
 

Static Public Attributes

 ConfigClass = MultiBandReferencesConfig
 
string datasetSuffix = "ref"
 

Detailed Description

Loads references from the multi-band processing scheme.

Definition at line 381 of file references.py.

Member Function Documentation

◆ fetchInBox() [1/2]

def lsst.meas.base.references.BaseReferencesTask.fetchInBox (   self,
  dataRef,
  bbox,
  wcs 
)
inherited
Return reference sources within a given bounding box.

Reference sources are selected if they overlap a region defined by a
pixel-coordinate bounding box and corresponding WCS.

Parameters
----------
dataRef : `lsst.daf.persistence.ButlerDataRef`
    Butler data reference. The implied data ID must contain the
    ``tract`` key.
bbox : `lsst.afw.geom.Box2I` or `lsst.afw.geom.Box2D`
    Defines the selection region in pixel coordinates.
wcs : `lsst.afw.image.SkyWcs`
    Maps ``bbox`` to sky coordinates.

Returns
-------
sources : iterable of `~lsst.afw.table.SourceRecord`
    Reference sources. May be any Python iterable, including a lazy
    iterator.

Notes
-----
The returned set of sources should be complete and close to minimal.

Definition at line 108 of file references.py.

108  def fetchInBox(self, dataRef, bbox, wcs):
109  """Return reference sources within a given bounding box.
110 
111  Reference sources are selected if they overlap a region defined by a
112  pixel-coordinate bounding box and corresponding WCS.
113 
114  Parameters
115  ----------
116  dataRef : `lsst.daf.persistence.ButlerDataRef`
117  Butler data reference. The implied data ID must contain the
118  ``tract`` key.
119  bbox : `lsst.afw.geom.Box2I` or `lsst.afw.geom.Box2D`
120  Defines the selection region in pixel coordinates.
121  wcs : `lsst.afw.image.SkyWcs`
122  Maps ``bbox`` to sky coordinates.
123 
124  Returns
125  -------
126  sources : iterable of `~lsst.afw.table.SourceRecord`
127  Reference sources. May be any Python iterable, including a lazy
128  iterator.
129 
130  Notes
131  -----
132  The returned set of sources should be complete and close to minimal.
133  """
134  raise NotImplementedError("BaseReferencesTask is pure abstract, and cannot be used directly.")
135 

◆ fetchInBox() [2/2]

def lsst.meas.base.references.CoaddSrcReferencesTask.fetchInBox (   self,
  dataRef,
  bbox,
  wcs,
  pad = 0 
)
inherited
Return reference sources within a given bounding box.

Reference sources are selected if they overlap a region defined by a
pixel-coordinate bounding box and corresponding WCS.

Parameters
----------
dataRef : `lsst.daf.persistence.ButlerDataRef`
    Butler data reference. The implied data ID must contain the
    ``tract`` key.
bbox : `lsst.afw.geom.Box2I` or `lsst.afw.geom.Box2D`
    Defines the selection region in pixel coordinates.
wcs : `lsst.afw.image.SkyWcs`
    Maps ``bbox`` to sky coordinates.
pad : `int`
    a buffer to grow the bounding box by after catalogs have been loaded, but
    before filtering them to include just the given bounding box.

Returns
-------
sources : iterable of `~lsst.afw.table.SourceRecord`
    Reference sources. May be any Python iterable, including a lazy
    iterator.

Definition at line 329 of file references.py.

329  def fetchInBox(self, dataRef, bbox, wcs, pad=0):
330  """Return reference sources within a given bounding box.
331 
332  Reference sources are selected if they overlap a region defined by a
333  pixel-coordinate bounding box and corresponding WCS.
334 
335  Parameters
336  ----------
337  dataRef : `lsst.daf.persistence.ButlerDataRef`
338  Butler data reference. The implied data ID must contain the
339  ``tract`` key.
340  bbox : `lsst.afw.geom.Box2I` or `lsst.afw.geom.Box2D`
341  Defines the selection region in pixel coordinates.
342  wcs : `lsst.afw.image.SkyWcs`
343  Maps ``bbox`` to sky coordinates.
344  pad : `int`
345  a buffer to grow the bounding box by after catalogs have been loaded, but
346  before filtering them to include just the given bounding box.
347 
348  Returns
349  -------
350  sources : iterable of `~lsst.afw.table.SourceRecord`
351  Reference sources. May be any Python iterable, including a lazy
352  iterator.
353  """
354  skyMap = dataRef.get(self.config.coaddName + "Coadd_skyMap", immediate=True)
355  tract = skyMap[dataRef.dataId["tract"]]
356  coordList = [wcs.pixelToSky(corner) for corner in lsst.geom.Box2D(bbox).getCorners()]
357  self.log.info("Getting references in region with corners %s [degrees]",
358  ", ".join("(%s)" % (coord.getPosition(lsst.geom.degrees),) for coord in coordList))
359  patchList = tract.findPatchList(coordList)
360  # After figuring out which patch catalogs to read from the bbox, pad out the bbox if desired
361  # But don't add any new patches while padding
362  if pad:
363  bbox.grow(pad)
364  return self.subset(self.fetchInPatches(dataRef, patchList), bbox, wcs)
365 
366 
A floating-point coordinate rectangle geometry.
Definition: Box.h:413

◆ fetchInPatches()

def lsst.meas.base.references.CoaddSrcReferencesTask.fetchInPatches (   self,
  dataRef,
  patchList 
)
inherited
Fetch the source catalog using the Butler.

Parameters
----------
dataRef : `lsst.daf.persistence.ButlerDataRef`
    Butler data reference. The implied data ID must contain the
    ``tract`` key.
patchList : `list` of `lsst.skymap.PatchInfo`
    Patches for which to fetch reference sources.

Returns
-------
sources : iterable of `~lsst.afw.table.SourceRecord`
    Reference sources. May be any Python iterable, including a lazy
    iterator.

Notes
-----
An implementation of `BaseReferencesTask.fetchInPatches` that loads
``Coadd_`` + `datasetSuffix` catalogs using the butler.

Reimplemented from lsst.meas.base.references.BaseReferencesTask.

Definition at line 284 of file references.py.

284  def fetchInPatches(self, dataRef, patchList):
285  """Fetch the source catalog using the Butler.
286 
287  Parameters
288  ----------
289  dataRef : `lsst.daf.persistence.ButlerDataRef`
290  Butler data reference. The implied data ID must contain the
291  ``tract`` key.
292  patchList : `list` of `lsst.skymap.PatchInfo`
293  Patches for which to fetch reference sources.
294 
295  Returns
296  -------
297  sources : iterable of `~lsst.afw.table.SourceRecord`
298  Reference sources. May be any Python iterable, including a lazy
299  iterator.
300 
301  Notes
302  -----
303  An implementation of `BaseReferencesTask.fetchInPatches` that loads
304  ``Coadd_`` + `datasetSuffix` catalogs using the butler.
305  """
306  dataset = "{}Coadd_{}".format(self.config.coaddName, self.datasetSuffix)
307  tract = dataRef.dataId["tract"]
308  butler = dataRef.butlerSubset.butler
309  for patch in patchList:
310  dataId = {'tract': tract, 'patch': "%d,%d" % patch.getIndex()}
311  if self.config.filter is not None:
312  dataId['filter'] = self.config.filter
313 
314  if not butler.datasetExists(dataset, dataId):
315  if self.config.skipMissing:
316  continue
317  raise lsst.pipe.base.TaskError("Reference %s doesn't exist" % (dataId,))
318  self.log.info("Getting references in %s", dataId)
319  catalog = butler.get(dataset, dataId, immediate=True)
320  if self.config.removePatchOverlaps:
321  bbox = lsst.geom.Box2D(patch.getInnerBBox())
322  for source in catalog:
323  if bbox.contains(source.getCentroid()):
324  yield source
325  else:
326  for source in catalog:
327  yield source
328 
def format(config, name=None, writeSourceLine=True, prefix="", verbose=False)
Definition: history.py:174

◆ getSchema()

def lsst.meas.base.references.BaseReferencesTask.getSchema (   self,
  butler 
)
inherited
Return the schema for the reference sources.

Parameters
----------
butler : `lsst.daf.persistence.butler.Butler`
    Data butler from which the schema will be fetched.

Notes
-----
Must be available even before any data has been processed.

Definition at line 83 of file references.py.

83  def getSchema(self, butler):
84  """Return the schema for the reference sources.
85 
86  Parameters
87  ----------
88  butler : `lsst.daf.persistence.butler.Butler`
89  Data butler from which the schema will be fetched.
90 
91  Notes
92  -----
93  Must be available even before any data has been processed.
94  """
95  raise NotImplementedError("BaseReferencesTask is pure abstract, and cannot be used directly.")
96 

◆ getWcs()

def lsst.meas.base.references.CoaddSrcReferencesTask.getWcs (   self,
  dataRef 
)
inherited
Return the WCS for reference sources.

Parameters
----------
dataRef : `lsst.daf.persistence.ButlerDataRef`
    Butler data reference. Must includ the trac in its dataId.

Reimplemented from lsst.meas.base.references.BaseReferencesTask.

Definition at line 273 of file references.py.

273  def getWcs(self, dataRef):
274  """Return the WCS for reference sources.
275 
276  Parameters
277  ----------
278  dataRef : `lsst.daf.persistence.ButlerDataRef`
279  Butler data reference. Must includ the trac in its dataId.
280  """
281  skyMap = dataRef.get(self.config.coaddName + "Coadd_skyMap", immediate=True)
282  return skyMap[dataRef.dataId["tract"]].getWcs()
283 

◆ subset()

def lsst.meas.base.references.BaseReferencesTask.subset (   self,
  sources,
  bbox,
  wcs 
)
inherited
Filter a list of sources to only those within the bounding box.

Parameters
----------
sources : iterable of `~lsst.afw.table.SourceRecord`
    Reference sources. May be any Python iterable, including a lazy
    iterator.
bbox : `lsst.afw.geom.Box2I` or `lsst.afw.geom.Box2D`
    Defines the selection region.
wcs : `lsst.afw.image.SkyWcs`
    Maps ``bbox`` to sky coordinates.

Returns
-------
sources : iterable of `~lsst.afw.table.SourceRecord`
    Filtered sources. May be any Python iterable, including a lazy
    iterator.

Notes
-----
Instead of filtering sources directly via their positions, we filter
based on the positions of parent objects, then include or discard all
children based on their parent's status. This is necessary to support
replacement with noise in measurement, which requires all child
sources have their parent present.

This is not a part of the required `BaseReferencesTask` interface;
it's a convenience function used in implementing `fetchInBox` that may
be of use to subclasses.

Definition at line 162 of file references.py.

162  def subset(self, sources, bbox, wcs):
163  """Filter a list of sources to only those within the bounding box.
164 
165  Parameters
166  ----------
167  sources : iterable of `~lsst.afw.table.SourceRecord`
168  Reference sources. May be any Python iterable, including a lazy
169  iterator.
170  bbox : `lsst.afw.geom.Box2I` or `lsst.afw.geom.Box2D`
171  Defines the selection region.
172  wcs : `lsst.afw.image.SkyWcs`
173  Maps ``bbox`` to sky coordinates.
174 
175  Returns
176  -------
177  sources : iterable of `~lsst.afw.table.SourceRecord`
178  Filtered sources. May be any Python iterable, including a lazy
179  iterator.
180 
181  Notes
182  -----
183  Instead of filtering sources directly via their positions, we filter
184  based on the positions of parent objects, then include or discard all
185  children based on their parent's status. This is necessary to support
186  replacement with noise in measurement, which requires all child
187  sources have their parent present.
188 
189  This is not a part of the required `BaseReferencesTask` interface;
190  it's a convenience function used in implementing `fetchInBox` that may
191  be of use to subclasses.
192  """
193  boxD = lsst.geom.Box2D(bbox)
194  # We're passed an arbitrary iterable, but we need a catalog so we can
195  # iterate over parents and then children.
196  catalog = lsst.afw.table.SourceCatalog(self.schema)
197  catalog.extend(sources)
198  # catalog must be sorted by parent ID for lsst.afw.table.getChildren
199  # to work
201  # Iterate over objects that have no parent.
202  parentSources = catalog.getChildren(0)
203  skyCoordList = [source.getCoord() for source in parentSources]
204  pixelPosList = wcs.skyToPixel(skyCoordList)
205  parentList = [parent for parent, pixel in zip(parentSources, pixelPosList) if boxD.contains(pixel)]
206  childrenIter = catalog.getChildren((parent.getId() for parent in parentList))
207  for parent, children in zip(parentList, childrenIter):
208  yield parent
209  yield from children
210 
211 
static Key< RecordId > getParentKey()
Key for the parent ID.
Definition: Source.h:273

Member Data Documentation

◆ ConfigClass

lsst.meas.base.references.MultiBandReferencesTask.ConfigClass = MultiBandReferencesConfig
static

Definition at line 385 of file references.py.

◆ datasetSuffix

string lsst.meas.base.references.MultiBandReferencesTask.datasetSuffix = "ref"
static

Definition at line 386 of file references.py.

◆ schema

lsst.meas.base.references.CoaddSrcReferencesTask.schema
inherited

Definition at line 271 of file references.py.


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