LSST Applications 24.1.5,g02d81e74bb+fa3a7a026e,g180d380827+a53a32eff8,g2079a07aa2+86d27d4dc4,g2305ad1205+c0501b3732,g295015adf3+7d3e92f0ec,g2bbee38e9b+0e5473021a,g337abbeb29+0e5473021a,g33d1c0ed96+0e5473021a,g3a166c0a6a+0e5473021a,g3ddfee87b4+5dd1654d75,g48712c4677+3bf1020dcb,g487adcacf7+065c13d9cf,g50ff169b8f+96c6868917,g52b1c1532d+585e252eca,g591dd9f2cf+d7ac436cfb,g5a732f18d5+53520f316c,g64a986408d+fa3a7a026e,g858d7b2824+fa3a7a026e,g8a8a8dda67+585e252eca,g99cad8db69+a5a909b84f,g9ddcbc5298+9a081db1e4,ga1e77700b3+15fc3df1f7,ga8c6da7877+4cf350ccb2,gb0e22166c9+60f28cb32d,gba4ed39666+c2a2e4ac27,gbb8dafda3b+f991a0b59f,gc120e1dc64+9ccbfdb8be,gc28159a63d+0e5473021a,gcf0d15dbbd+5dd1654d75,gd96a1ce819+42fd0ee607,gdaeeff99f8+f9a426f77a,ge6526c86ff+0d71447b4b,ge79ae78c31+0e5473021a,gee10cc3b42+585e252eca,gff1a9f87cc+fa3a7a026e
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 61 of file measurePsf.py.

Constructor & Destructor Documentation

◆ __init__()

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

Definition at line 111 of file measurePsf.py.

111 def __init__(self, schema=None, **kwargs):
112 pipeBase.Task.__init__(self, **kwargs)
113 if schema is not None:
114 self.candidateKey = schema.addField(
115 "calib_psf_candidate", type="Flag",
116 doc=("Flag set if the source was a candidate for PSF determination, "
117 "as determined by the star selector.")
118 )
119 self.usedKey = schema.addField(
120 "calib_psf_used", type="Flag",
121 doc=("Flag set if the source was actually used for PSF determination, "
122 "as determined by the '%s' PSF determiner.") % self.config.psfDeterminer.name
123 )
124 else:
125 self.candidateKey = None
126 self.usedKey = None
127 self.makeSubtask("starSelector")
128 self.makeSubtask("makePsfCandidates")
129 self.makeSubtask("psfDeterminer", schema=schema)
130 self.makeSubtask("reserve", columnName="calib_psf", schema=schema,
131 doc="set if source was reserved from PSF determination")
132

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 134 of file measurePsf.py.

134 def run(self, exposure, sources, expId=0, matches=None):
135 """Measure the PSF.
136
137 Parameters
138 ----------
139 exposure : `lsst.afw.image.Exposure`
140 Exposure to process; measured PSF will be added.
141 sources : `Unknown`
142 Measured sources on exposure; flag fields will be set marking
143 stars chosen by the star selector and the PSF determiner if a schema
144 was passed to the task constructor.
145 expId : `int`, optional
146 Exposure id used for generating random seed.
147 matches : `list`, optional
148 A list of ``lsst.afw.table.ReferenceMatch`` objects
149 (i.e. of ``lsst.afw.table.Match`` with @c first being
150 of type ``lsst.afw.table.SimpleRecord`` and @c second
151 type lsst.afw.table.SourceRecord --- the reference object and detected
152 object respectively) as returned by @em e.g. the AstrometryTask.
153 Used by star selectors that choose to refer to an external catalog.
154
155 Returns
156 -------
157 measurement : `lsst.pipe.base.Struct`
158 PSF measurement as a struct with attributes:
159
160 ``psf``
161 The measured PSF (also set in the input exposure).
162 ``cellSet``
163 An `lsst.afw.math.SpatialCellSet` containing the PSF candidates
164 as returned by the psf determiner.
165 """
166 self.log.info("Measuring PSF")
167
168 import lsstDebug
169 display = lsstDebug.Info(__name__).display
170 displayExposure = lsstDebug.Info(__name__).displayExposure # display the Exposure + spatialCells
171 displayPsfMosaic = lsstDebug.Info(__name__).displayPsfMosaic # show mosaic of reconstructed PSF(x,y)
172 displayPsfCandidates = lsstDebug.Info(__name__).displayPsfCandidates # show mosaic of candidates
173 displayResiduals = lsstDebug.Info(__name__).displayResiduals # show residuals
174 showBadCandidates = lsstDebug.Info(__name__).showBadCandidates # include bad candidates
175 normalizeResiduals = lsstDebug.Info(__name__).normalizeResiduals # normalise residuals by object peak
176
177 #
178 # Run star selector
179 #
180 stars = self.starSelector.run(sourceCat=sources, matches=matches, exposure=exposure)
181 selectionResult = self.makePsfCandidates.run(stars.sourceCat, exposure=exposure)
182 self.log.info("PSF star selector found %d candidates", len(selectionResult.psfCandidates))
183 reserveResult = self.reserve.run(selectionResult.goodStarCat, expId=expId)
184 # Make list of psf candidates to send to the determiner (omitting those marked as reserved)
185 psfDeterminerList = [cand for cand, use
186 in zip(selectionResult.psfCandidates, reserveResult.use) if use]
187
188 if selectionResult.psfCandidates and self.candidateKey is not None:
189 for cand in selectionResult.psfCandidates:
190 source = cand.getSource()
191 source.set(self.candidateKey, True)
192
193 self.log.info("Sending %d candidates to PSF determiner", len(psfDeterminerList))
194
195 if display:
196 frame = 1
197 if displayExposure:
198 disp = afwDisplay.Display(frame=frame)
199 disp.mtv(exposure, title="psf determination")
200 frame += 1
201 #
202 # Determine PSF
203 #
204 psf, cellSet = self.psfDeterminer.determinePsf(exposure, psfDeterminerList, self.metadata,
205 flagKey=self.usedKey)
206 self.log.info("PSF determination using %d/%d stars.",
207 self.metadata.getScalar("numGoodStars"), self.metadata.getScalar("numAvailStars"))
208
209 exposure.setPsf(psf)
210
211 if display:
212 frame = display
213 if displayExposure:
214 disp = afwDisplay.Display(frame=frame)
215 showPsfSpatialCells(exposure, cellSet, showBadCandidates, frame=frame)
216 frame += 1
217
218 if displayPsfCandidates: # Show a mosaic of PSF candidates
219 plotPsfCandidates(cellSet, showBadCandidates=showBadCandidates, frame=frame)
220 frame += 1
221
222 if displayResiduals:
223 frame = plotResiduals(exposure, cellSet,
224 showBadCandidates=showBadCandidates,
225 normalizeResiduals=normalizeResiduals,
226 frame=frame)
227 if displayPsfMosaic:
228 disp = afwDisplay.Display(frame=frame)
229 maUtils.showPsfMosaic(exposure, psf, display=disp, showFwhm=True)
230 disp.scale("linear", 0, 1)
231 frame += 1
232
233 return pipeBase.Struct(
234 psf=psf,
235 cellSet=cellSet,
236 )
237

◆ 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 239 of file measurePsf.py.

239 def usesMatches(self):
240 """Return True if this task makes use of the "matches" argument to the run method"""
241 return self.starSelector.usesMatches
242
243#
244# Debug code
245#
246
247

Member Data Documentation

◆ _DefaultName

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

Definition at line 109 of file measurePsf.py.

◆ candidateKey

lsst.pipe.tasks.measurePsf.MeasurePsfTask.candidateKey

Definition at line 114 of file measurePsf.py.

◆ ConfigClass

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

Definition at line 108 of file measurePsf.py.

◆ usedKey

lsst.pipe.tasks.measurePsf.MeasurePsfTask.usedKey

Definition at line 119 of file measurePsf.py.


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