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 | Static Public Member Functions | Static Public Attributes | Private Member Functions | Static Private Member Functions | Static Private Attributes | List of all members
lsst.meas.algorithms.loadReferenceObjects.LoadReferenceObjectsTask Class Reference

Abstract base class to load objects from reference catalogs. More...

Inheritance diagram for lsst.meas.algorithms.loadReferenceObjects.LoadReferenceObjectsTask:

Public Member Functions

def loadPixelBox
 Load reference objects that overlap a pixel-based rectangular region. More...
 
def loadSkyCircle
 Load reference objects that overlap a circular sky region. More...
 

Static Public Member Functions

def makeMinimalSchema
 Make the standard schema for reference object catalogs. More...
 

Static Public Attributes

 ConfigClass = LoadReferenceObjectsConfig
 

Private Member Functions

def _addFluxAliases
 

Static Private Member Functions

def _trimToBBox
 Remove objects outside a given pixel-based bbox and set centroid and hasCentroid fields. More...
 

Static Private Attributes

 __metaclass__ = abc.ABCMeta
 
string _DefaultName = "LoadReferenceObjects"
 

Detailed Description

Abstract base class to load objects from reference catalogs.

Contents

Description

Abstract base class for tasks that load objects from a reference catalog in a particular region of the sky.

Implementations must subclass this class, override the loadSkyCircle method, and will typically override the value of ConfigClass with a task-specific config class.

Task initialisation

Invoking the Task

Schema of the reference object catalog

Reference object catalogs are instances of lsst.afw.table.SimpleCatalog with the following schema (other fields may also be present):

Configuration parameters

See LoadReferenceObjectsConfig for a base set of configuration parameters. Most subclasses will add configuration variables.

Definition at line 82 of file loadReferenceObjects.py.

Member Function Documentation

def lsst.meas.algorithms.loadReferenceObjects.LoadReferenceObjectsTask._addFluxAliases (   self,
  schema 
)
private
Add aliases for camera filter fluxes to the schema

If self.config.defaultFilter then adds these aliases:
    camFlux:      <defaultFilter>_flux
    camFluxSigma: <defaultFilter>_fluxSigma, if the latter exists

For each camFilter: refFilter in self.config.filterMap adds these aliases:
    <camFilter>_camFlux:      <refFilter>_flux
    <camFilter>_camFluxSigma: <refFilter>_fluxSigma, if the latter exists

@throw RuntimeError if any reference flux field is missing from the schema

Definition at line 226 of file loadReferenceObjects.py.

227  def _addFluxAliases(self, schema):
228  """Add aliases for camera filter fluxes to the schema
229 
230  If self.config.defaultFilter then adds these aliases:
231  camFlux: <defaultFilter>_flux
232  camFluxSigma: <defaultFilter>_fluxSigma, if the latter exists
233 
234  For each camFilter: refFilter in self.config.filterMap adds these aliases:
235  <camFilter>_camFlux: <refFilter>_flux
236  <camFilter>_camFluxSigma: <refFilter>_fluxSigma, if the latter exists
237 
238  @throw RuntimeError if any reference flux field is missing from the schema
239  """
240  aliasMap = schema.getAliasMap()
241 
242  def addAliasesForOneFilter(filterName, refFilterName):
243  """Add aliases for a single filter
244 
245  @param[in] filterName camera filter name, or ""
246  the name is <filterName>_camFlux or camFlux if filterName is None
247  @param[in] refFilterName reference filter name; <refFilterName>_flux must exist
248  """
249  camFluxName = filterName + "_camFlux" if filterName is not None else "camFlux"
250  refFluxName = refFilterName + "_flux"
251  if refFluxName not in schema:
252  raise RuntimeError("Unknown reference filter %s" % (refFluxName,))
253  aliasMap.set(camFluxName, refFluxName)
254  refFluxErrName = refFluxName + "Sigma"
255  if refFluxErrName in schema:
256  camFluxErrName = camFluxName + "Sigma"
257  aliasMap.set(camFluxErrName, refFluxErrName)
258 
259  if self.config.defaultFilter:
260  addAliasesForOneFilter(None, self.config.defaultFilter)
261 
262  for filterName, refFilterName in self.config.filterMap.iteritems():
263  addAliasesForOneFilter(filterName, refFilterName)
def lsst.meas.algorithms.loadReferenceObjects.LoadReferenceObjectsTask._trimToBBox (   refCat,
  bbox,
  wcs 
)
staticprivate

Remove objects outside a given pixel-based bbox and set centroid and hasCentroid fields.

Parameters
[in]refCata catalog of objects (an lsst.afw.table.SimpleCatalog, or other table type that supports getCoord() on records)
[in]bboxpixel region (an afwImage.Box2D)
[in]wcsWCS used to convert sky position to pixel position (an lsst.afw.math.WCS)
Returns
a catalog of reference objects in bbox, with centroid and hasCentroid fields set

Definition at line 205 of file loadReferenceObjects.py.

206  def _trimToBBox(refCat, bbox, wcs):
207  """!Remove objects outside a given pixel-based bbox and set centroid and hasCentroid fields
208 
209  @param[in] refCat a catalog of objects (an lsst.afw.table.SimpleCatalog,
210  or other table type that supports getCoord() on records)
211  @param[in] bbox pixel region (an afwImage.Box2D)
212  @param[in] wcs WCS used to convert sky position to pixel position (an lsst.afw.math.WCS)
213 
214  @return a catalog of reference objects in bbox, with centroid and hasCentroid fields set
215  """
216  centroidKey = afwTable.Point2DKey(refCat.schema["centroid"])
217  hasCentroidKey = refCat.schema["hasCentroid"].asKey()
218  retStarCat = type(refCat)(refCat.table)
219  for star in refCat:
220  point = wcs.skyToPixel(star.getCoord())
221  if bbox.contains(point):
222  star.set(centroidKey, point)
223  star.set(hasCentroidKey, True)
224  retStarCat.append(star)
225  return retStarCat
def _trimToBBox
Remove objects outside a given pixel-based bbox and set centroid and hasCentroid fields.
def lsst.meas.algorithms.loadReferenceObjects.LoadReferenceObjectsTask.loadPixelBox (   self,
  bbox,
  wcs,
  filterName = None,
  calib = None 
)

Load reference objects that overlap a pixel-based rectangular region.

The search algorith works by searching in a region in sky coordinates whose center is the center of the bbox and radius is large enough to just include all 4 corners of the bbox. Stars that lie outside the bbox are then trimmed from the list.

Parameters
[in]bboxbounding box for pixels (an lsst.afw.geom.Box2I or Box2D)
[in]wcsWCS (an lsst.afw.image.Wcs)
[in]filterNamename of camera filter, or None or blank for the default filter
[in]calibcalibration, or None if unknown
Returns
a catalog of reference objects using the standard schema (see the class doc string)

Definition at line 145 of file loadReferenceObjects.py.

146  def loadPixelBox(self, bbox, wcs, filterName=None, calib=None):
147  """!Load reference objects that overlap a pixel-based rectangular region
148 
149  The search algorith works by searching in a region in sky coordinates whose center is the center
150  of the bbox and radius is large enough to just include all 4 corners of the bbox.
151  Stars that lie outside the bbox are then trimmed from the list.
152 
153  @param[in] bbox bounding box for pixels (an lsst.afw.geom.Box2I or Box2D)
154  @param[in] wcs WCS (an lsst.afw.image.Wcs)
155  @param[in] filterName name of camera filter, or None or blank for the default filter
156  @param[in] calib calibration, or None if unknown
157 
158  @return a catalog of reference objects using the standard schema (see the class doc string)
159  """
160  # compute on-sky center and radius of search region, for loadSkyCircle
161  bbox = afwGeom.Box2D(bbox) # make sure bbox is double and that we have a copy
162  bbox.grow(self.config.pixelMargin)
163  ctrCoord = wcs.pixelToSky(bbox.getCenter())
164  maxRadius = afwGeom.Angle(0)
165  for pixPt in bbox.getCorners():
166  coord = wcs.pixelToSky(pixPt)
167  rad = ctrCoord.angularSeparation(coord)
168  maxRadius = max(rad, maxRadius)
169  del rad
170 
171  # find objects in circle
172  self.log.info("Loading reference objects using center %s pix = %s sky and radius %s deg" %
173  (bbox.getCenter(), ctrCoord, maxRadius.asDegrees()))
174  loadRes = self.loadSkyCircle(ctrCoord, maxRadius, filterName)
175  refCat = loadRes.refCat
176  numFound = len(refCat)
177 
178  # trim objects outside bbox
179  refCat = self._trimToBBox(refCat=refCat, bbox=bbox, wcs=wcs)
180  numTrimmed = numFound - len(refCat)
181  self.log.logdebug("trimmed %d out-of-bbox objects, leaving %d" % (numTrimmed, len(refCat)))
182  self.log.info("Loaded %d reference objects" % (len(refCat),))
183 
184  loadRes.refCat = refCat # should be a no-op, but just in case
185  return loadRes
def _trimToBBox
Remove objects outside a given pixel-based bbox and set centroid and hasCentroid fields.
def loadPixelBox
Load reference objects that overlap a pixel-based rectangular region.
def loadSkyCircle
Load reference objects that overlap a circular sky region.
A floating-point coordinate rectangle geometry.
Definition: Box.h:271
def lsst.meas.algorithms.loadReferenceObjects.LoadReferenceObjectsTask.loadSkyCircle (   self,
  ctrCoord,
  radius,
  filterName = None 
)

Load reference objects that overlap a circular sky region.

Parameters
[in]ctrCoordcenter of search region (an lsst.afw.geom.Coord)
[in]radiusradius of search region (an lsst.afw.geom.Angle)
[in]filterNamename of filter, or None for the default filter; used for flux values in case we have flux limits (which are not yet implemented)
Returns
an lsst.pipe.base.Struct containing:
  • refCat a catalog of reference objects with the standard schema as documented in LoadReferenceObjects, including photometric, resolved and variable; hasCentroid is False for all objects.
  • fluxField = name of flux field for specified filterName

Definition at line 187 of file loadReferenceObjects.py.

188  def loadSkyCircle(self, ctrCoord, radius, filterName=None):
189  """!Load reference objects that overlap a circular sky region
190 
191  @param[in] ctrCoord center of search region (an lsst.afw.geom.Coord)
192  @param[in] radius radius of search region (an lsst.afw.geom.Angle)
193  @param[in] filterName name of filter, or None for the default filter;
194  used for flux values in case we have flux limits (which are not yet implemented)
195 
196  @return an lsst.pipe.base.Struct containing:
197  - refCat a catalog of reference objects with the
198  \link meas_algorithms_loadReferenceObjects_Schema standard schema \endlink
199  as documented in LoadReferenceObjects, including photometric, resolved and variable;
200  hasCentroid is False for all objects.
201  - fluxField = name of flux field for specified filterName
202  """
203  return
def loadSkyCircle
Load reference objects that overlap a circular sky region.
def lsst.meas.algorithms.loadReferenceObjects.LoadReferenceObjectsTask.makeMinimalSchema (   filterNameList,
  addFluxSigma = False,
  addIsPhotometric = False,
  addIsResolved = False,
  addIsVariable = False 
)
static

Make the standard schema for reference object catalogs.

Parameters
[in]filterNameListlist of filter names; used to create filterName_flux fields
[in]addFluxSigmaif True then include flux sigma fields
[in]addIsPhotometricif True add field "photometric"
[in]addIsResolvedif True add field "resolved"
[in]addIsVariableif True add field "variable"

Definition at line 266 of file loadReferenceObjects.py.

267  addIsPhotometric=False, addIsResolved=False, addIsVariable=False):
268  """!Make the standard schema for reference object catalogs
269 
270  @param[in] filterNameList list of filter names; used to create *filterName*_flux fields
271  @param[in] addFluxSigma if True then include flux sigma fields
272  @param[in] addIsPhotometric if True add field "photometric"
273  @param[in] addIsResolved if True add field "resolved"
274  @param[in] addIsVariable if True add field "variable"
275  """
276  schema = afwTable.SimpleTable.makeMinimalSchema()
277  afwTable.Point2DKey.addFields(
278  schema,
279  "centroid",
280  "centroid on an exposure, if relevant",
281  "pixels",
282  )
283  schema.addField(
284  field = "hasCentroid",
285  type = "Flag",
286  doc = "is position known?",
287  )
288  for filterName in filterNameList:
289  schema.addField(
290  field = "%s_flux" % (filterName,),
291  type = numpy.float64,
292  doc = "flux in filter %s" % (filterName,),
293  units = "?",
294  )
295  if addFluxSigma:
296  for filterName in filterNameList:
297  schema.addField(
298  field = "%s_fluxSigma" % (filterName,),
299  type = numpy.float64,
300  doc = "flux uncertainty in filter %s" % (filterName,),
301  units = "?",
302  )
303  if addIsPhotometric:
304  schema.addField(
305  field = "photometric",
306  type = "Flag",
307  doc = "set if the object can be used for photometric calibration",
308  )
309  if addIsResolved:
310  schema.addField(
311  field = "resolved",
312  type = "Flag",
313  doc = "set if the object is spatially resolved",
314  )
315  if addIsVariable:
316  schema.addField(
317  field = "variable",
318  type = "Flag",
319  doc = "set if the object has variable brightness",
320  )
321  return schema

Member Data Documentation

lsst.meas.algorithms.loadReferenceObjects.LoadReferenceObjectsTask.__metaclass__ = abc.ABCMeta
staticprivate

Definition at line 140 of file loadReferenceObjects.py.

string lsst.meas.algorithms.loadReferenceObjects.LoadReferenceObjectsTask._DefaultName = "LoadReferenceObjects"
staticprivate

Definition at line 142 of file loadReferenceObjects.py.

lsst.meas.algorithms.loadReferenceObjects.LoadReferenceObjectsTask.ConfigClass = LoadReferenceObjectsConfig
static

Definition at line 141 of file loadReferenceObjects.py.


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