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 Attributes | Private Member Functions | Static Private Attributes | List of all members
lsst.meas.astrom.matchOptimisticB.MatchOptimisticBTask Class Reference

Match sources to reference objects. More...

Inheritance diagram for lsst.meas.astrom.matchOptimisticB.MatchOptimisticBTask:

Public Member Functions

def filterStars
 
def matchObjectsToSources
 Match sources to position reference stars. More...
 

Static Public Attributes

 ConfigClass = MatchOptimisticBConfig
 
 SourceInfoClass = SourceInfo
 

Private Member Functions

def _doMatch
 Implementation of matching sources to position reference stars. More...
 

Static Private Attributes

string _DefaultName = "matchObjectsToSources"
 

Detailed Description

Match sources to reference objects.

Contents

Description

Match sources to reference objects. This is often done as a preliminary step to fitting an astrometric or photometric solution. For details about the matching algorithm see matchOptimisticB.h

Task initialisation

Invoking the Task

Match sources to position reference stars.

Parameters
[in]refCatcatalog of reference objects that overlap the exposure; reads fields for:
  • coord
  • the specified flux field
[in]sourceCatcatalog of sources found on an exposure; reads fields for:
  • centroid
  • centroid flag
  • edge flag
  • saturated flag
  • aperture flux, if found, else PSF flux
[in]wcsestimated WCS
[in]refFluxFieldfield of refCat to use for flux
[in]maxMatchDistmaximum on-sky distance between reference objects and sources (an lsst.afw.geom.Angle); if specified then the smaller of config.maxMatchDistArcSec or maxMatchDist is used; if None then config.maxMatchDistArcSec is used
Returns
an lsst.pipe.base.Struct with fields:
  • matches a list of matches, each instance of lsst.afw.table.ReferenceMatch
  • usableSourcCat a catalog of sources potentially usable for matching. For this fitter usable sources include unresolved sources not too near the edge. It includes saturated sources, even those these are removed from the final match list, because saturated sources may be used to determine the match list.

Configuration parameters

See MatchOptimisticBConfig

To modify the tests for usable sources and good sources, subclass SourceInfo and set MatchOptimisticBTask.SourceInfoClass to your subclass.

A complete example of using MatchOptimisticBTask

MatchOptimisticBTask is a subtask of AstrometryTask, which is called by PhotoCalTask. See meas_photocal_photocal_Example.

Debug variables

The command line task interface supports a flag -d to import debug.py from your PYTHONPATH; see Using lsstDebug to control debugging output for more about debug.py files.

The available variables in MatchOptimisticBTask are:

verbose (bool)
If True then the matcher prints debug messages to stdout

To investigate the Debug variables, put something like

1 import lsstDebug
2 def DebugInfo(name):
3  debug = lsstDebug.getInfo(name) # N.b. lsstDebug.Info(name) would call us recursively
4  if name == "lsst.pipe.tasks.astrometry":
5  debug.verbose = True
6 
7  return debug
8 
9 lsstDebug.Info = DebugInfo

into your debug.py file and run this task with the –debug flag.

Definition at line 153 of file matchOptimisticB.py.

Member Function Documentation

def lsst.meas.astrom.matchOptimisticB.MatchOptimisticBTask._doMatch (   self,
  refCat,
  sourceCat,
  wcs,
  refFluxField,
  numUsableSources,
  minMatchedPairs,
  maxMatchDist,
  sourceInfo,
  verbose 
)
private

Implementation of matching sources to position reference stars.

Unlike matchObjectsToSources, this method does not check if the sources are suitable.

Parameters
[in]refCatcatalog of position reference stars that overlap an exposure
[in]sourceCatcatalog of sources found on the exposure
[in]wcsestimated WCS of exposure
[in]refFluxFieldfield of refCat to use for flux
[in]numUsableSourcesnumber of usable sources (sources with known centroid that are not near the edge, but may be saturated)
[in]minMatchedPairsminimum number of matches
[in]maxMatchDistmaximum on-sky distance between reference objects and sources (an lsst.afw.geom.Angle); if specified then the smaller of config.maxMatchDistArcSec or maxMatchDist is used; if None then config.maxMatchDistArcSec is used
[in]sourceInfoSourceInfo for the sourceCat
[in]verbosetrue to print diagnostic information to std::cout
Returns
a list of matches, an instance of lsst.afw.table.ReferenceMatch

Definition at line 319 of file matchOptimisticB.py.

320  maxMatchDist, sourceInfo, verbose):
321  """!Implementation of matching sources to position reference stars
322 
323  Unlike matchObjectsToSources, this method does not check if the sources are suitable.
324 
325  @param[in] refCat catalog of position reference stars that overlap an exposure
326  @param[in] sourceCat catalog of sources found on the exposure
327  @param[in] wcs estimated WCS of exposure
328  @param[in] refFluxField field of refCat to use for flux
329  @param[in] numUsableSources number of usable sources (sources with known centroid
330  that are not near the edge, but may be saturated)
331  @param[in] minMatchedPairs minimum number of matches
332  @param[in] maxMatchDist maximum on-sky distance between reference objects and sources
333  (an lsst.afw.geom.Angle); if specified then the smaller of config.maxMatchDistArcSec or
334  maxMatchDist is used; if None then config.maxMatchDistArcSec is used
335  @param[in] sourceInfo SourceInfo for the sourceCat
336  @param[in] verbose true to print diagnostic information to std::cout
337 
338  @return a list of matches, an instance of lsst.afw.table.ReferenceMatch
339  """
340  numSources = len(sourceCat)
341  posRefBegInd = numUsableSources - numSources
342  if maxMatchDist is None:
343  maxMatchDistArcSec = self.config.maxMatchDistArcSec
344  else:
345  maxMatchDistArcSec = min(maxMatchDist.asArcseconds(), self.config.maxMatchDistArcSec)
346  configMatchDistPix = maxMatchDistArcSec/wcs.pixelScale().asArcseconds()
347 
348  matchControl = MatchOptimisticBControl()
349  matchControl.refFluxField = refFluxField
350  matchControl.sourceFluxField = sourceInfo.fluxField
351  matchControl.numBrightStars = self.config.numBrightStars
352  matchControl.minMatchedPairs = self.config.minMatchedPairs
353  matchControl.maxOffsetPix = self.config.maxOffsetPix
354  matchControl.numPointsForShape = self.config.numPointsForShape
355  matchControl.maxDeterminant = self.config.maxDeterminant
356 
357  for maxRotInd in range(4):
358  matchControl.maxRotationDeg = self.config.maxRotationDeg * math.pow(2.0, 0.5*maxRotInd)
359  for matchRadInd in range(3):
360  matchControl.matchingAllowancePix = configMatchDistPix * math.pow(1.25, matchRadInd)
361 
362  for angleDiffInd in range(3):
363  matchControl.allowedNonperpDeg = self.config.allowedNonperpDeg*(angleDiffInd+1)
364  matches = matchOptimisticB(
365  refCat,
366  sourceCat,
367  matchControl,
368  wcs,
369  posRefBegInd,
370  verbose,
371  )
372  if matches is not None and len(matches) > 0:
373  setMatchDistance(matches)
374  return matches
375  return matches
lsst::afw::table::ReferenceMatchVector matchOptimisticB(lsst::afw::table::SimpleCatalog const &posRefCat, lsst::afw::table::SourceCatalog const &sourceCat, MatchOptimisticBControl const &control, afw::image::Wcs const &wcs, int posRefBegInd=0, bool verbose=false)
def lsst.meas.astrom.matchOptimisticB.MatchOptimisticBTask.filterStars (   self,
  refCat 
)
Extra filtering pass; subclass if desired

Definition at line 222 of file matchOptimisticB.py.

223  def filterStars(self, refCat):
224  """Extra filtering pass; subclass if desired
225  """
226  return refCat
def lsst.meas.astrom.matchOptimisticB.MatchOptimisticBTask.matchObjectsToSources (   self,
  refCat,
  sourceCat,
  wcs,
  refFluxField,
  maxMatchDist = None 
)

Match sources to position reference stars.

Parameters
[in]refCatcatalog of reference objects that overlap the exposure; reads fields for:
  • coord
  • the specified flux field
[in]sourceCatcatalog of sources found on an exposure; reads fields for:
  • centroid
  • centroid flag
  • edge flag
  • saturated flag
  • aperture flux, if found, else PSF flux
[in]wcsestimated WCS
[in]refFluxFieldfield of refCat to use for flux
[in]maxMatchDistmaximum on-sky distance between reference objects and sources (an lsst.afw.geom.Angle); if specified then the smaller of config.maxMatchDistArcSec or maxMatchDist is used; if None then config.maxMatchDistArcSec is used
Returns
an lsst.pipe.base.Struct with fields:
  • matches a list of matches, each instance of lsst.afw.table.ReferenceMatch
  • usableSourcCat a catalog of sources potentially usable for matching. For this fitter usable sources include unresolved sources not too near the edge. It includes saturated sources, even those these are removed from the final match list, because saturated sources may be used to determine the match list.

Definition at line 228 of file matchOptimisticB.py.

229  def matchObjectsToSources(self, refCat, sourceCat, wcs, refFluxField, maxMatchDist=None):
230  """!Match sources to position reference stars
231 
232  @param[in] refCat catalog of reference objects that overlap the exposure; reads fields for:
233  - coord
234  - the specified flux field
235  @param[in] sourceCat catalog of sources found on an exposure; reads fields for:
236  - centroid
237  - centroid flag
238  - edge flag
239  - saturated flag
240  - aperture flux, if found, else PSF flux
241  @param[in] wcs estimated WCS
242  @param[in] refFluxField field of refCat to use for flux
243  @param[in] maxMatchDist maximum on-sky distance between reference objects and sources
244  (an lsst.afw.geom.Angle); if specified then the smaller of config.maxMatchDistArcSec or
245  maxMatchDist is used; if None then config.maxMatchDistArcSec is used
246  @return an lsst.pipe.base.Struct with fields:
247  - matches a list of matches, each instance of lsst.afw.table.ReferenceMatch
248  - usableSourcCat a catalog of sources potentially usable for matching.
249  For this fitter usable sources include unresolved sources not too near the edge.
250  It includes saturated sources, even those these are removed from the final match list,
251  because saturated sources may be used to determine the match list.
252  """
253  import lsstDebug
254  debug = lsstDebug.Info(__name__)
255 
256  preNumObj = len(refCat)
257  refCat = self.filterStars(refCat)
258  numRefObj = len(refCat)
259 
260  if self.log: self.log.info("filterStars purged %d reference stars, leaving %d stars" % \
261  (preNumObj - numRefObj, numRefObj))
262 
263  sourceInfo = self.SourceInfoClass(
264  schema = sourceCat.schema,
265  fluxType = self.config.sourceFluxType,
266  )
267 
268  # usableSourceCat: sources that are good but may be saturated
269  numSources = len(sourceCat)
270  usableSourceCat = afwTable.SourceCatalog(sourceCat.table)
271  usableSourceCat.extend(s for s in sourceCat if sourceInfo.isUsable(s))
272  numUsableSources = len(usableSourceCat)
273  self.log.info("Purged %d unusable sources, leaving %d usable sources" % \
274  (numSources - numUsableSources, numUsableSources))
275 
276  if len(usableSourceCat) == 0:
277  raise pipeBase.TaskError("No sources are usable")
278 
279  del sourceCat # avoid accidentally using sourceCat; use usableSourceCat or goodSourceCat from now on
280 
281  minMatchedPairs = min(self.config.minMatchedPairs,
282  int(self.config.minFracMatchedPairs * min([len(refCat), len(usableSourceCat)])))
283 
284  # match usable (possibly saturated) sources and then purge saturated sources from the match list
285  usableMatches = self._doMatch(
286  refCat = refCat,
287  sourceCat = usableSourceCat,
288  wcs = wcs,
289  refFluxField = refFluxField,
290  numUsableSources = numUsableSources,
291  minMatchedPairs = minMatchedPairs,
292  maxMatchDist = maxMatchDist,
293  sourceInfo = sourceInfo,
294  verbose = debug.verbose,
295  )
296 
297  # cull non-good sources
298  matches = []
299  for match in usableMatches:
300  if sourceInfo.isGood(match.second):
301  matches.append(match)
302 
303  self.log.logdebug("Found %d usable matches, of which %d had good sources" %
304  (len(usableMatches), len(matches)))
305 
306  if len(matches) == 0:
307  raise RuntimeError("Unable to match sources")
308 
309  self.log.info("Matched %d sources" % len(matches))
310  if len(matches) < minMatchedPairs:
311  self.log.warn("Number of matches is smaller than request")
312 
313  return pipeBase.Struct(
314  matches = matches,
315  usableSourceCat = usableSourceCat,
316  )
def matchObjectsToSources
Match sources to position reference stars.
def _doMatch
Implementation of matching sources to position reference stars.
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

Member Data Documentation

string lsst.meas.astrom.matchOptimisticB.MatchOptimisticBTask._DefaultName = "matchObjectsToSources"
staticprivate

Definition at line 219 of file matchOptimisticB.py.

lsst.meas.astrom.matchOptimisticB.MatchOptimisticBTask.ConfigClass = MatchOptimisticBConfig
static

Definition at line 218 of file matchOptimisticB.py.

lsst.meas.astrom.matchOptimisticB.MatchOptimisticBTask.SourceInfoClass = SourceInfo
static

Definition at line 220 of file matchOptimisticB.py.


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