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 Attributes | List of all members
lsst.meas.astrom.catalogStarSelector.CatalogStarSelector Class Reference
Inheritance diagram for lsst.meas.astrom.catalogStarSelector.CatalogStarSelector:

Public Member Functions

def __init__
 
def selectStars
 

Static Public Attributes

 ConfigClass = CatalogStarSelectorConfig
 

Private Attributes

 _kernelSize
 
 _borderWidth
 
 _fluxLim
 
 _fluxMax
 
 _badStarPixelFlags
 

Detailed Description

Definition at line 78 of file catalogStarSelector.py.

Constructor & Destructor Documentation

def lsst.meas.astrom.catalogStarSelector.CatalogStarSelector.__init__ (   self,
  config = None 
)
Construct a star selector that uses second moments

This is a naive algorithm and should be used with caution.

@param[in] config: An instance of CatalogStarSelectorConfig

Definition at line 81 of file catalogStarSelector.py.

81 
82  def __init__(self, config=None):
83  """Construct a star selector that uses second moments
84 
85  This is a naive algorithm and should be used with caution.
86 
87  @param[in] config: An instance of CatalogStarSelectorConfig
88  """
89  if not config:
90  config = CatalogStarSelector.ConfigClass()
91 
92  self._kernelSize = config.kernelSize
93  self._borderWidth = config.borderWidth
94  self._fluxLim = config.fluxLim
95  self._fluxMax = config.fluxMax
96  self._badStarPixelFlags = config.badStarPixelFlags

Member Function Documentation

def lsst.meas.astrom.catalogStarSelector.CatalogStarSelector.selectStars (   self,
  exposure,
  sources,
  matches = None 
)
Return a list of PSF candidates that represent likely stars

A list of PSF candidates may be used by a PSF fitter to construct a PSF.

@param[in] exposure: the exposure containing the sources
@param[in] sources: a source list containing sources that may be stars
@param[in] matches: a match vector as produced by meas_astrom; not actually optional
            (passing None just allows us to handle the exception better here
            than in calling code)

@return psfCandidateList: a list of PSF candidates.

Definition at line 97 of file catalogStarSelector.py.

97 
98  def selectStars(self, exposure, sources, matches=None):
99  """Return a list of PSF candidates that represent likely stars
100 
101  A list of PSF candidates may be used by a PSF fitter to construct a PSF.
102 
103  @param[in] exposure: the exposure containing the sources
104  @param[in] sources: a source list containing sources that may be stars
105  @param[in] matches: a match vector as produced by meas_astrom; not actually optional
106  (passing None just allows us to handle the exception better here
107  than in calling code)
108 
109  @return psfCandidateList: a list of PSF candidates.
110  """
111  import lsstDebug
112  display = lsstDebug.Info(__name__).display
113  displayExposure = lsstDebug.Info(__name__).displayExposure # display the Exposure + spatialCells
114  pauseAtEnd = lsstDebug.Info(__name__).pauseAtEnd # pause when done
115 
116  if matches is None:
117  raise RuntimeError(
118  "Cannot use catalog star selector without running astrometry."
119  )
120 
121  mi = exposure.getMaskedImage()
122 
123  if display:
124  frames = {}
125  if displayExposure:
126  frames["displayExposure"] = 1
127  ds9.mtv(mi, frame=frames["displayExposure"], title="PSF candidates")
128  #
129  # Read the reference catalogue
130  #
131  isGoodSource = CheckSource(sources, self._fluxLim, self._fluxMax, self._badStarPixelFlags)
132 
133  #
134  # Go through and find all the PSFs in the catalogue
135  #
136  # We'll split the image into a number of cells, each of which contributes only
137  # one PSF candidate star
138  #
139  psfCandidateList = []
140 
141  with ds9.Buffering():
142  for ref, source, d in matches:
143  if not ref.get("resolved"):
144  if not isGoodSource(source):
145  symb, ctype = "+", ds9.RED
146  else:
147  try:
148  psfCandidate = measAlg.makePsfCandidate(source, exposure)
149 
150  # The setXXX methods are class static, but it's convenient to call them on
151  # an instance as we don't know Exposure's pixel type
152  # (and hence psfCandidate's exact type)
153  if psfCandidate.getWidth() == 0:
154  psfCandidate.setBorderWidth(self._borderWidth)
155  psfCandidate.setWidth(self._kernelSize + 2*self._borderWidth)
156  psfCandidate.setHeight(self._kernelSize + 2*self._borderWidth)
157 
158  im = psfCandidate.getMaskedImage().getImage()
159  max = afwMath.makeStatistics(im, afwMath.MAX).getValue()
160  if not numpy.isfinite(max):
161  continue
162  psfCandidateList.append(psfCandidate)
163 
164  symb, ctype = "+", ds9.GREEN
165  except Exception as err:
166  symb, ctype = "o", ds9.RED
167  print "RHL", err
168  pass # FIXME: should log this!
169  else:
170  symb, ctype = "o", ds9.BLUE
171 
172  if display and displayExposure:
173  ds9.dot(symb, source.getX() - mi.getX0(), source.getY() - mi.getY0(),
174  size=4, frame=frames["displayExposure"], ctype=ctype)
175 
176  if display and pauseAtEnd:
177  raw_input("Continue? y[es] p[db] ")
178 
179  return psfCandidateList
180 
181 measAlg.starSelectorRegistry.register("catalog", CatalogStarSelector)
182 
boost::shared_ptr< PsfCandidate< PixelT > > makePsfCandidate(boost::shared_ptr< afw::table::SourceRecord > const &source, boost::shared_ptr< afw::image::Exposure< PixelT > > image)
Definition: PsfCandidate.h:188
Statistics makeStatistics(afwImage::Mask< afwImage::MaskPixel > const &msk, int const flags, StatisticsControl const &sctrl)
Specialization to handle Masks.
Definition: Statistics.cc:1082

Member Data Documentation

lsst.meas.astrom.catalogStarSelector.CatalogStarSelector._badStarPixelFlags
private

Definition at line 95 of file catalogStarSelector.py.

lsst.meas.astrom.catalogStarSelector.CatalogStarSelector._borderWidth
private

Definition at line 92 of file catalogStarSelector.py.

lsst.meas.astrom.catalogStarSelector.CatalogStarSelector._fluxLim
private

Definition at line 93 of file catalogStarSelector.py.

lsst.meas.astrom.catalogStarSelector.CatalogStarSelector._fluxMax
private

Definition at line 94 of file catalogStarSelector.py.

lsst.meas.astrom.catalogStarSelector.CatalogStarSelector._kernelSize
private

Definition at line 91 of file catalogStarSelector.py.

lsst.meas.astrom.catalogStarSelector.CatalogStarSelector.ConfigClass = CatalogStarSelectorConfig
static

Definition at line 79 of file catalogStarSelector.py.


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