LSST Applications g0265f82a02+0e5473021a,g02d81e74bb+f5613e8b4f,g1470d8bcf6+190ad2ba91,g14a832a312+311607e4ab,g2079a07aa2+86d27d4dc4,g2305ad1205+a8e3196225,g295015adf3+b67ee847e5,g2bbee38e9b+0e5473021a,g337abbeb29+0e5473021a,g3ddfee87b4+a761f810f3,g487adcacf7+17c8fdbcbd,g50ff169b8f+96c6868917,g52b1c1532d+585e252eca,g591dd9f2cf+65b5bd823e,g5a732f18d5+53520f316c,g64a986408d+f5613e8b4f,g6c1bc301e9+51106c2951,g858d7b2824+f5613e8b4f,g8a8a8dda67+585e252eca,g99cad8db69+6729933424,g9ddcbc5298+9a081db1e4,ga1e77700b3+15fc3df1f7,ga8c6da7877+ef4e3a5875,gb0e22166c9+60f28cb32d,gb6a65358fc+0e5473021a,gba4ed39666+c2a2e4ac27,gbb8dafda3b+e9bba80f27,gc120e1dc64+eee469a5e5,gc28159a63d+0e5473021a,gcf0d15dbbd+a761f810f3,gdaeeff99f8+f9a426f77a,ge6526c86ff+d4c1d4bfef,ge79ae78c31+0e5473021a,gee10cc3b42+585e252eca,gf1cff7945b+f5613e8b4f,w.2024.16
LSST Data Management Base Package
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | Static Protected Attributes | List of all members
lsst.meas.astrom.matchOptimisticBTask.MatchOptimisticBTask Class Reference
Inheritance diagram for lsst.meas.astrom.matchOptimisticBTask.MatchOptimisticBTask:

Public Member Functions

 __init__ (self, **kwargs)
 
 filterStars (self, refCat)
 
 matchObjectsToSources (self, refCat, sourceCat, wcs, sourceFluxField, refFluxField, match_tolerance=None)
 

Public Attributes

 edgeKey
 
 interpolatedCenterKey
 
 saturatedKey
 

Static Public Attributes

 ConfigClass = MatchOptimisticBConfig
 

Protected Member Functions

 _getIsGoodKeys (self, schema)
 
 _isGoodTest (self, source)
 
 _doMatch (self, refCat, sourceCat, wcs, refFluxField, numUsableSources, minMatchedPairs, maxMatchDist, sourceFluxField, verbose)
 

Static Protected Attributes

str _DefaultName = "matchObjectsToSources"
 

Detailed Description

Match sources to reference objects using the Optimistic Pattern Matcher
B algorithm of Tabur 2007.

Definition at line 124 of file matchOptimisticBTask.py.

Constructor & Destructor Documentation

◆ __init__()

lsst.meas.astrom.matchOptimisticBTask.MatchOptimisticBTask.__init__ ( self,
** kwargs )

Definition at line 131 of file matchOptimisticBTask.py.

131 def __init__(self, **kwargs):
132 pipeBase.Task.__init__(self, **kwargs)
133

Member Function Documentation

◆ _doMatch()

lsst.meas.astrom.matchOptimisticBTask.MatchOptimisticBTask._doMatch ( self,
refCat,
sourceCat,
wcs,
refFluxField,
numUsableSources,
minMatchedPairs,
maxMatchDist,
sourceFluxField,
verbose )
protected
Implementation of matching sources to position reference stars.

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

Parameters
----------
refCat : `lsst.afw.table.SimpleCatalog`
    Catalog of reference objects.
sourceCat : `lsst.afw.table.SourceCatalog`
    Catalog of detected sources.
wcs : `lsst.afw.geom.SkyWcs`
    Current best WCS of the image.
refFluxFioeld : `str`
    Name of flux field in refCat to use.
numUsableSources : `int`
    Total number of source usable for matching.
mintMatchPairs : `int`
    Minimum number of objects to match between the refCat and sourceCat
    to consider a valid match.
maxMatchDist : `lsst.geom.Angle`
    Maximum separation to considering a reference and a source a match.
sourceFluxField : `str`
    Name of source catalog flux field.
verbose : `bool`
    Print diagnostic information std::cout

Returns
-------
matches : `list` of `lsst.afw.table.ReferenceMatch`

Definition at line 282 of file matchOptimisticBTask.py.

283 maxMatchDist, sourceFluxField, verbose):
284 """Implementation of matching sources to position reference stars.
285
286 Unlike matchObjectsToSources, this method does not check if the sources
287 are suitable.
288
289 Parameters
290 ----------
291 refCat : `lsst.afw.table.SimpleCatalog`
292 Catalog of reference objects.
293 sourceCat : `lsst.afw.table.SourceCatalog`
294 Catalog of detected sources.
295 wcs : `lsst.afw.geom.SkyWcs`
296 Current best WCS of the image.
297 refFluxFioeld : `str`
298 Name of flux field in refCat to use.
299 numUsableSources : `int`
300 Total number of source usable for matching.
301 mintMatchPairs : `int`
302 Minimum number of objects to match between the refCat and sourceCat
303 to consider a valid match.
304 maxMatchDist : `lsst.geom.Angle`
305 Maximum separation to considering a reference and a source a match.
306 sourceFluxField : `str`
307 Name of source catalog flux field.
308 verbose : `bool`
309 Print diagnostic information std::cout
310
311 Returns
312 -------
313 matches : `list` of `lsst.afw.table.ReferenceMatch`
314 """
315 numSources = len(sourceCat)
316 posRefBegInd = numUsableSources - numSources
317 if maxMatchDist is None:
318 maxMatchDistArcSec = self.config.maxMatchDistArcSec
319 else:
320 maxMatchDistArcSec = min(maxMatchDist.asArcseconds(), self.config.maxMatchDistArcSec)
321 configMatchDistPix = maxMatchDistArcSec/wcs.getPixelScale().asArcseconds()
322
323 matchControl = MatchOptimisticBControl()
324 matchControl.refFluxField = refFluxField
325 matchControl.sourceFluxField = sourceFluxField
326 matchControl.numBrightStars = self.config.numBrightStars
327 matchControl.minMatchedPairs = self.config.minMatchedPairs
328 matchControl.maxOffsetPix = self.config.maxOffsetPix
329 matchControl.numPointsForShape = self.config.numPointsForShape
330 matchControl.maxDeterminant = self.config.maxDeterminant
331
332 for maxRotInd in range(4):
333 matchControl.maxRotationDeg = self.config.maxRotationDeg * math.pow(2.0, 0.5*maxRotInd)
334 for matchRadInd in range(3):
335 matchControl.matchingAllowancePix = configMatchDistPix * math.pow(1.25, matchRadInd)
336
337 for angleDiffInd in range(3):
338 matchControl.allowedNonperpDeg = self.config.allowedNonperpDeg*(angleDiffInd+1)
339 matches = matchOptimisticB(
340 refCat,
341 sourceCat,
342 matchControl,
343 wcs,
344 posRefBegInd,
345 verbose,
346 )
347 if matches is not None and len(matches) > 0:
348 setMatchDistance(matches)
349 return matches
350 return matches
int min

◆ _getIsGoodKeys()

lsst.meas.astrom.matchOptimisticBTask.MatchOptimisticBTask._getIsGoodKeys ( self,
schema )
protected
Retrieve the keys needed for the isGoodTest from the source catalog
schema.

Parameters
----------
schema : `lsst.afw.table.Schema`
    Source schema to retrieve `lsst.afw.table.Key` s from.

Definition at line 248 of file matchOptimisticBTask.py.

248 def _getIsGoodKeys(self, schema):
249 """Retrieve the keys needed for the isGoodTest from the source catalog
250 schema.
251
252 Parameters
253 ----------
254 schema : `lsst.afw.table.Schema`
255 Source schema to retrieve `lsst.afw.table.Key` s from.
256 """
257 self.edgeKey = schema["base_PixelFlags_flag_edge"].asKey()
258 self.interpolatedCenterKey = schema["base_PixelFlags_flag_interpolatedCenter"].asKey()
259 self.saturatedKey = schema["base_PixelFlags_flag_saturated"].asKey()
260

◆ _isGoodTest()

lsst.meas.astrom.matchOptimisticBTask.MatchOptimisticBTask._isGoodTest ( self,
source )
protected
Test that an object is good for use in the WCS fitter.

This is a hard coded version of the isGood flag from the old SourceInfo
class that used to be part of this class.

Parameters
----------
source : `lsst.afw.table.SourceRecord`
    Source to test.

Returns
-------
isGood : `bool`
    Source passes CCD edge and saturated tests.

Definition at line 261 of file matchOptimisticBTask.py.

261 def _isGoodTest(self, source):
262 """Test that an object is good for use in the WCS fitter.
263
264 This is a hard coded version of the isGood flag from the old SourceInfo
265 class that used to be part of this class.
266
267 Parameters
268 ----------
269 source : `lsst.afw.table.SourceRecord`
270 Source to test.
271
272 Returns
273 -------
274 isGood : `bool`
275 Source passes CCD edge and saturated tests.
276 """
277 return (not source.get(self.edgeKey)
278 and not source.get(self.interpolatedCenterKey)
279 and not source.get(self.saturatedKey))
280

◆ filterStars()

lsst.meas.astrom.matchOptimisticBTask.MatchOptimisticBTask.filterStars ( self,
refCat )
Extra filtering pass; subclass if desired.

Parameters
----------
refCat : `lsst.afw.table.SimpleCatalog`
    Catalog of reference objects.

Returns
-------
trimmedRefCat : `lsst.afw.table.SimpleCatalog`
    Reference catalog with some filtering applied. Currently no
    filtering is applied.

Definition at line 134 of file matchOptimisticBTask.py.

134 def filterStars(self, refCat):
135 """Extra filtering pass; subclass if desired.
136
137 Parameters
138 ----------
139 refCat : `lsst.afw.table.SimpleCatalog`
140 Catalog of reference objects.
141
142 Returns
143 -------
144 trimmedRefCat : `lsst.afw.table.SimpleCatalog`
145 Reference catalog with some filtering applied. Currently no
146 filtering is applied.
147 """
148 return refCat
149

◆ matchObjectsToSources()

lsst.meas.astrom.matchOptimisticBTask.MatchOptimisticBTask.matchObjectsToSources ( self,
refCat,
sourceCat,
wcs,
sourceFluxField,
refFluxField,
match_tolerance = None )
Match sources to position reference stars.

Parameters
----------
refCat : `lsst.afw.table.SimpleCatalog`
    Reference catalog to match.
sourceCat : `lsst.afw.table.SourceCatalog`
    Catalog of sources found on an exposure.  This should already be
    down-selected to "good"/"usable" sources in the calling Task.
wcs : `lsst.afw.geom.SkyWcs`
    Current WCS of the  exposure containing the sources.
sourceFluxField : `str`
    Field of the sourceCat to use for flux
refFluxField : `str`
    Field of the refCat to use for flux
match_tolerance : `lsst.meas.astrom.MatchTolerance`
    Object containing information from previous
    `lsst.meas.astrom.AstrometryTask` match/fit cycles for use in
    matching. If `None` is config defaults.

Returns
-------
matchResult : `lsst.pipe.base.Struct`
    Result struct with components

    - ``matches`` : List of matches with distance below the maximum match
      distance (`list` of `lsst.afw.table.ReferenceMatch`).
    - ``useableSourceCat`` : Catalog of sources matched and suited for
      WCS fitting (`lsst.afw.table.SourceCatalog`).
    - ``match_tolerance`` : MatchTolerance object updated from this
      match iteration (`lsst.meas.astrom.MatchTolerance`).

Definition at line 151 of file matchOptimisticBTask.py.

152 match_tolerance=None):
153 """Match sources to position reference stars.
154
155 Parameters
156 ----------
157 refCat : `lsst.afw.table.SimpleCatalog`
158 Reference catalog to match.
159 sourceCat : `lsst.afw.table.SourceCatalog`
160 Catalog of sources found on an exposure. This should already be
161 down-selected to "good"/"usable" sources in the calling Task.
162 wcs : `lsst.afw.geom.SkyWcs`
163 Current WCS of the exposure containing the sources.
164 sourceFluxField : `str`
165 Field of the sourceCat to use for flux
166 refFluxField : `str`
167 Field of the refCat to use for flux
168 match_tolerance : `lsst.meas.astrom.MatchTolerance`
169 Object containing information from previous
170 `lsst.meas.astrom.AstrometryTask` match/fit cycles for use in
171 matching. If `None` is config defaults.
172
173 Returns
174 -------
175 matchResult : `lsst.pipe.base.Struct`
176 Result struct with components
177
178 - ``matches`` : List of matches with distance below the maximum match
179 distance (`list` of `lsst.afw.table.ReferenceMatch`).
180 - ``useableSourceCat`` : Catalog of sources matched and suited for
181 WCS fitting (`lsst.afw.table.SourceCatalog`).
182 - ``match_tolerance`` : MatchTolerance object updated from this
183 match iteration (`lsst.meas.astrom.MatchTolerance`).
184 """
185 import lsstDebug
186 debug = lsstDebug.Info(__name__)
187
188 preNumObj = len(refCat)
189 refCat = self.filterStars(refCat)
190 numRefObj = len(refCat)
191
192 if self.log:
193 self.log.info("filterStars purged %d reference stars, leaving %d stars",
194 preNumObj - numRefObj, numRefObj)
195
196 if match_tolerance is None:
197 match_tolerance = MatchTolerance()
198
199 # Make a name alias here for consistency with older code, and to make
200 # it clear that this is a good/usable (cleaned) source catalog.
201 usableSourceCat = sourceCat
202
203 numUsableSources = len(usableSourceCat)
204
205 if len(usableSourceCat) == 0:
206 raise pipeBase.TaskError("No sources are usable")
207
208 minMatchedPairs = min(self.config.minMatchedPairs,
209 int(self.config.minFracMatchedPairs * min([len(refCat), len(usableSourceCat)])))
210
211 # match usable (possibly saturated) sources and then purge saturated sources from the match list
212 usableMatches = self._doMatch(
213 refCat=refCat,
214 sourceCat=usableSourceCat,
215 wcs=wcs,
216 refFluxField=refFluxField,
217 numUsableSources=numUsableSources,
218 minMatchedPairs=minMatchedPairs,
219 maxMatchDist=match_tolerance.maxMatchDist,
220 sourceFluxField=sourceFluxField,
221 verbose=debug.verbose,
222 )
223
224 # cull non-good sources
225 matches = []
226 self._getIsGoodKeys(usableSourceCat.schema)
227 for match in usableMatches:
228 if self._isGoodTest(match.second):
229 # Append the isGood match.
230 matches.append(match)
231
232 self.log.debug("Found %d usable matches, of which %d had good sources",
233 len(usableMatches), len(matches))
234
235 if len(matches) == 0:
236 raise RuntimeError("Unable to match sources")
237
238 self.log.info("Matched %d sources", len(matches))
239 if len(matches) < minMatchedPairs:
240 self.log.warning("Number of matches is smaller than request")
241
242 return pipeBase.Struct(
243 matches=matches,
244 usableSourceCat=usableSourceCat,
245 match_tolerance=match_tolerance,
246 )
247

Member Data Documentation

◆ _DefaultName

str lsst.meas.astrom.matchOptimisticBTask.MatchOptimisticBTask._DefaultName = "matchObjectsToSources"
staticprotected

Definition at line 129 of file matchOptimisticBTask.py.

◆ ConfigClass

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

Definition at line 128 of file matchOptimisticBTask.py.

◆ edgeKey

lsst.meas.astrom.matchOptimisticBTask.MatchOptimisticBTask.edgeKey

Definition at line 257 of file matchOptimisticBTask.py.

◆ interpolatedCenterKey

lsst.meas.astrom.matchOptimisticBTask.MatchOptimisticBTask.interpolatedCenterKey

Definition at line 258 of file matchOptimisticBTask.py.

◆ saturatedKey

lsst.meas.astrom.matchOptimisticBTask.MatchOptimisticBTask.saturatedKey

Definition at line 259 of file matchOptimisticBTask.py.


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