LSST Applications g0d97872fb5+4fd969bb9d,g1653933729+34a971ddd9,g28da252d5a+072f89fe25,g2bbee38e9b+a99b0ab4cd,g2bc492864f+a99b0ab4cd,g2ca4be77d2+c0e3b27cd8,g2cdde0e794+704103fe75,g3156d2b45e+6e87dc994a,g347aa1857d+a99b0ab4cd,g35bb328faa+34a971ddd9,g3a166c0a6a+a99b0ab4cd,g3e281a1b8c+8ec26ec694,g4005a62e65+ba0306790b,g414038480c+9ed5ed841a,g569e0e2b34+cb4faa46ad,g5a97de2502+520531a62c,g717e5f8c0f+29153700a5,g7ede599f99+367733290c,g80478fca09+17051a22cc,g82479be7b0+f2f1ea0a87,g858d7b2824+29153700a5,g8b782ad322+29153700a5,g8cd86fa7b1+05420e7f7d,g9125e01d80+34a971ddd9,ga5288a1d22+e7f674aaf3,gae0086650b+34a971ddd9,gae74b0b5c6+45ef5cdc51,gb58c049af0+ace264a4f2,gc28159a63d+a99b0ab4cd,gcf0d15dbbd+8051a81198,gda6a2b7d83+8051a81198,gdaeeff99f8+7774323b41,gdf4d240d4a+34a971ddd9,ge2409df99d+cb167bac99,ge33fd446bb+29153700a5,ge79ae78c31+a99b0ab4cd,gf0baf85859+890af219f9,gf5289d68f6+9faa5c5784,w.2024.36
LSST Data Management Base Package
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Static Public Attributes | Static Protected Attributes | List of all members
lsst.pipe.tasks.measurePsf.MeasurePsfTask Class Reference
Inheritance diagram for lsst.pipe.tasks.measurePsf.MeasurePsfTask:

Public Member Functions

 __init__ (self, schema=None, **kwargs)
 
 run (self, exposure, sources, expId=0, matches=None)
 
 usesMatches (self)
 

Public Attributes

 candidateKey
 
 usedKey
 

Static Public Attributes

 ConfigClass = MeasurePsfConfig
 

Static Protected Attributes

str _DefaultName = "measurePsf"
 

Detailed Description

A task that selects stars from a catalog of sources and uses those to measure the PSF.

Parameters
----------
schema : `lsst.sfw.table.Schema`
    An `lsst.afw.table.Schema` used to create the output `lsst.afw.table.SourceCatalog`.
**kwargs :
    Keyword arguments passed to lsst.pipe.base.task.Task.__init__.

Notes
-----
If schema is not None, 'calib_psf_candidate' and 'calib_psf_used' fields will be added to
identify which stars were employed in the PSF estimation.

This task can add fields to the schema, so any code calling this task must ensure that
these fields are indeed present in the input table.

The star selector is a subclass of
``lsst.meas.algorithms.starSelector.BaseStarSelectorTask`` "lsst.meas.algorithms.BaseStarSelectorTask"
and the PSF determiner is a sublcass of
``lsst.meas.algorithms.psfDeterminer.BasePsfDeterminerTask`` "lsst.meas.algorithms.BasePsfDeterminerTask"

There is no establised set of configuration parameters for these algorithms, so once you start modifying
parameters (as we do in @ref pipe_tasks_measurePsf_Example) your code is no longer portable.

Debugging:

.. code-block:: none

display
    If True, display debugging plots
displayExposure
    display the Exposure + spatialCells
displayPsfCandidates
    show mosaic of candidates
showBadCandidates
    Include bad candidates
displayPsfMosaic
    show mosaic of reconstructed PSF(xy)
displayResiduals
    show residuals
normalizeResiduals
    Normalise residuals by object amplitude

Additionally you can enable any debug outputs that your chosen star selector and psf determiner support.

Definition at line 98 of file measurePsf.py.

Constructor & Destructor Documentation

◆ __init__()

lsst.pipe.tasks.measurePsf.MeasurePsfTask.__init__ ( self,
schema = None,
** kwargs )

Definition at line 148 of file measurePsf.py.

148 def __init__(self, schema=None, **kwargs):
149 pipeBase.Task.__init__(self, **kwargs)
150 if schema is not None:
151 self.candidateKey = schema.addField(
152 "calib_psf_candidate", type="Flag",
153 doc=("Flag set if the source was a candidate for PSF determination, "
154 "as determined by the star selector.")
155 )
156 self.usedKey = schema.addField(
157 "calib_psf_used", type="Flag",
158 doc=("Flag set if the source was actually used for PSF determination, "
159 "as determined by the '%s' PSF determiner.") % self.config.psfDeterminer.name
160 )
161 else:
162 self.candidateKey = None
163 self.usedKey = None
164 self.makeSubtask("starSelector")
165 self.makeSubtask("makePsfCandidates")
166 self.makeSubtask("psfDeterminer", schema=schema)
167 self.makeSubtask("reserve", columnName="calib_psf", schema=schema,
168 doc="set if source was reserved from PSF determination")
169

Member Function Documentation

◆ run()

lsst.pipe.tasks.measurePsf.MeasurePsfTask.run ( self,
exposure,
sources,
expId = 0,
matches = None )
Measure the PSF.

Parameters
----------
exposure : `lsst.afw.image.Exposure`
    Exposure to process; measured PSF will be added.
sources : `Unknown`
    Measured sources on exposure; flag fields will be set marking
    stars chosen by the star selector and the PSF determiner if a schema
    was passed to the task constructor.
expId : `int`, optional
    Exposure id used for generating random seed.
matches : `list`, optional
    A list of ``lsst.afw.table.ReferenceMatch`` objects
    (i.e. of ``lsst.afw.table.Match`` with @c first being
    of type ``lsst.afw.table.SimpleRecord`` and @c second
    type lsst.afw.table.SourceRecord --- the reference object and detected
    object respectively) as returned by @em e.g. the AstrometryTask.
    Used by star selectors that choose to refer to an external catalog.

Returns
-------
measurement : `lsst.pipe.base.Struct`
     PSF measurement as a struct with attributes:

    ``psf``
        The measured PSF (also set in the input exposure).
    ``cellSet``
        An `lsst.afw.math.SpatialCellSet` containing the PSF candidates
        as returned by the psf determiner.

Definition at line 171 of file measurePsf.py.

171 def run(self, exposure, sources, expId=0, matches=None):
172 """Measure the PSF.
173
174 Parameters
175 ----------
176 exposure : `lsst.afw.image.Exposure`
177 Exposure to process; measured PSF will be added.
178 sources : `Unknown`
179 Measured sources on exposure; flag fields will be set marking
180 stars chosen by the star selector and the PSF determiner if a schema
181 was passed to the task constructor.
182 expId : `int`, optional
183 Exposure id used for generating random seed.
184 matches : `list`, optional
185 A list of ``lsst.afw.table.ReferenceMatch`` objects
186 (i.e. of ``lsst.afw.table.Match`` with @c first being
187 of type ``lsst.afw.table.SimpleRecord`` and @c second
188 type lsst.afw.table.SourceRecord --- the reference object and detected
189 object respectively) as returned by @em e.g. the AstrometryTask.
190 Used by star selectors that choose to refer to an external catalog.
191
192 Returns
193 -------
194 measurement : `lsst.pipe.base.Struct`
195 PSF measurement as a struct with attributes:
196
197 ``psf``
198 The measured PSF (also set in the input exposure).
199 ``cellSet``
200 An `lsst.afw.math.SpatialCellSet` containing the PSF candidates
201 as returned by the psf determiner.
202 """
203 self.log.info("Measuring PSF")
204
205 import lsstDebug
206 display = lsstDebug.Info(__name__).display
207 displayExposure = lsstDebug.Info(__name__).displayExposure # display the Exposure + spatialCells
208 displayPsfMosaic = lsstDebug.Info(__name__).displayPsfMosaic # show mosaic of reconstructed PSF(x,y)
209 displayPsfCandidates = lsstDebug.Info(__name__).displayPsfCandidates # show mosaic of candidates
210 displayResiduals = lsstDebug.Info(__name__).displayResiduals # show residuals
211 showBadCandidates = lsstDebug.Info(__name__).showBadCandidates # include bad candidates
212 normalizeResiduals = lsstDebug.Info(__name__).normalizeResiduals # normalise residuals by object peak
213
214 #
215 # Run star selector
216 #
217 stars = self.starSelector.run(sourceCat=sources, matches=matches, exposure=exposure)
218 selectionResult = self.makePsfCandidates.run(stars.sourceCat, exposure=exposure)
219 self.log.info("PSF star selector found %d candidates", len(selectionResult.psfCandidates))
220 reserveResult = self.reserve.run(selectionResult.goodStarCat, expId=expId)
221 # Make list of psf candidates to send to the determiner (omitting those marked as reserved)
222 psfDeterminerList = [cand for cand, use
223 in zip(selectionResult.psfCandidates, reserveResult.use) if use]
224
225 if selectionResult.psfCandidates and self.candidateKey is not None:
226 for cand in selectionResult.psfCandidates:
227 source = cand.getSource()
228 source.set(self.candidateKey, True)
229
230 self.log.info("Sending %d candidates to PSF determiner", len(psfDeterminerList))
231
232 if display:
233 frame = 1
234 if displayExposure:
235 disp = afwDisplay.Display(frame=frame)
236 disp.mtv(exposure, title="psf determination")
237 frame += 1
238 #
239 # Determine PSF
240 #
241 psf, cellSet = self.psfDeterminer.determinePsf(exposure, psfDeterminerList, self.metadata,
242 flagKey=self.usedKey)
243 self.log.info("PSF determination using %d/%d stars.",
244 self.metadata.getScalar("numGoodStars"), self.metadata.getScalar("numAvailStars"))
245
246 exposure.setPsf(psf)
247
248 if display:
249 frame = display
250 if displayExposure:
251 disp = afwDisplay.Display(frame=frame)
252 showPsfSpatialCells(exposure, cellSet, showBadCandidates, frame=frame)
253 frame += 1
254
255 if displayPsfCandidates: # Show a mosaic of PSF candidates
256 plotPsfCandidates(cellSet, showBadCandidates=showBadCandidates, frame=frame)
257 frame += 1
258
259 if displayResiduals:
260 frame = plotResiduals(exposure, cellSet,
261 showBadCandidates=showBadCandidates,
262 normalizeResiduals=normalizeResiduals,
263 frame=frame)
264 if displayPsfMosaic:
265 disp = afwDisplay.Display(frame=frame)
266 maUtils.showPsfMosaic(exposure, psf, display=disp, showFwhm=True)
267 disp.scale("linear", 0, 1)
268 frame += 1
269
270 return pipeBase.Struct(
271 psf=psf,
272 cellSet=cellSet,
273 )
274

◆ usesMatches()

lsst.pipe.tasks.measurePsf.MeasurePsfTask.usesMatches ( self)
Return True if this task makes use of the "matches" argument to the run method

Definition at line 276 of file measurePsf.py.

276 def usesMatches(self):
277 """Return True if this task makes use of the "matches" argument to the run method"""
278 return self.starSelector.usesMatches
279
280#
281# Debug code
282#
283
284

Member Data Documentation

◆ _DefaultName

str lsst.pipe.tasks.measurePsf.MeasurePsfTask._DefaultName = "measurePsf"
staticprotected

Definition at line 146 of file measurePsf.py.

◆ candidateKey

lsst.pipe.tasks.measurePsf.MeasurePsfTask.candidateKey

Definition at line 151 of file measurePsf.py.

◆ ConfigClass

lsst.pipe.tasks.measurePsf.MeasurePsfTask.ConfigClass = MeasurePsfConfig
static

Definition at line 145 of file measurePsf.py.

◆ usedKey

lsst.pipe.tasks.measurePsf.MeasurePsfTask.usedKey

Definition at line 156 of file measurePsf.py.


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