23 from psfMatch
import PsfMatchConfigDF, PsfMatchConfigAL
24 from imagePsfMatch
import ImagePsfMatchTask, ImagePsfMatchConfig
27 """Delta-function Psf-matching config optimized for snap subtraction"""
29 PsfMatchConfigDF.setDefaults(self)
40 """Sum-of-Gaussian (Alard-Lupton) Psf-matching config optimized for snap subtraction"""
42 PsfMatchConfigAL.setDefaults(self)
50 kernel = pexConfig.ConfigChoiceField(
53 AL = SnapPsfMatchConfigAL,
54 DF = SnapPsfMatchConfigDF
59 doWarping = pexConfig.Field(
61 doc =
"Warp the snaps?",
66 ImagePsfMatchConfig.setDefaults(self)
69 self.kernel.active.spatialKernelOrder = 0
72 self.kernel.active.fitForBackground =
False
75 self.kernel.active.kernelSize = 7
78 self.kernel.active.spatialKernelClipping =
False
89 \anchor SnapPsfMatchTask_
91 \brief Image-based Psf-matching of two subsequent snaps from the same visit
93 \section ip_diffim_snappsfmatch_Contents Contents
95 - \ref ip_diffim_snappsfmatch_Purpose
96 - \ref ip_diffim_snappsfmatch_Initialize
97 - \ref ip_diffim_snappsfmatch_IO
98 - \ref ip_diffim_snappsfmatch_Config
99 - \ref ip_diffim_snappsfmatch_Metadata
100 - \ref ip_diffim_snappsfmatch_Debug
101 - \ref ip_diffim_snappsfmatch_Example
103 #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
105 \section ip_diffim_snappsfmatch_Purpose Description
107 \copybrief SnapPsfMatchTask
109 This Task differs from ImagePsfMatchTask in that it matches two Exposures assuming that the images have
110 been acquired very closely in time. Under this assumption, the astrometric misalignments and/or
111 relative distortions should be within a pixel, and the Psf-shapes should be very similar. As a
112 consequence, the default configurations for this class assume a very simple solution.
114 . The spatial variation in the kernel (SnapPsfMatchConfig.spatialKernelOrder) is assumed to be zero
116 . With no spatial variation, we turn of the spatial clipping loops (SnapPsfMatchConfig.spatialKernelClipping)
118 . The differential background is _not_ fit for (SnapPsfMatchConfig.fitForBackground)
120 . The kernel is expected to be appx. a delta function, and has a small size (SnapPsfMatchConfig.kernelSize)
122 The sub-configurations for the Alard-Lupton (SnapPsfMatchConfigAL) and delta-function (SnapPsfMatchConfigDF)
123 bases also are designed to generate a small, simple kernel.
125 #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
127 \section ip_diffim_snappsfmatch_Initialize Task initialization
129 Initialization is the same as base class ImagePsfMatch.__init__, with the difference being that the Task's
130 ConfigClass is SnapPsfMatchConfig.
132 #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
134 \section ip_diffim_snappsfmatch_IO Invoking the Task
136 The Task is only configured to have a subtractExposures method, which in turn calls
137 ImagePsfMatchTask.subtractExposures.
139 #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
141 \section ip_diffim_snappsfmatch_Config Configuration parameters
143 See \ref SnapPsfMatchConfig, which uses either \ref SnapPsfMatchConfigDF and \ref SnapPsfMatchConfigAL
144 as its active configuration.
146 #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
148 \section ip_diffim_snappsfmatch_Metadata Quantities set in Metadata
150 See \ref ip_diffim_psfmatch_Metadata "PsfMatchTask"
152 #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
154 \section ip_diffim_snappsfmatch_Debug Debug variables
156 The \link lsst.pipe.base.cmdLineTask.CmdLineTask command line task\endlink interface supports a
157 flag \c -d/--debug to import \b debug.py from your \c PYTHONPATH. The relevant contents of debug.py
158 for this Task include:
164 di = lsstDebug.getInfo(name)
165 if name == "lsst.ip.diffim.psfMatch":
166 di.display = True # enable debug output
167 di.maskTransparency = 80 # ds9 mask transparency
168 di.displayCandidates = True # show all the candidates and residuals
169 di.displayKernelBasis = False # show kernel basis functions
170 di.displayKernelMosaic = True # show kernel realized across the image
171 di.plotKernelSpatialModel = False # show coefficients of spatial model
172 di.showBadCandidates = True # show the bad candidates (red) along with good (green)
173 elif name == "lsst.ip.diffim.imagePsfMatch":
174 di.display = True # enable debug output
175 di.maskTransparency = 30 # ds9 mask transparency
176 di.displayTemplate = True # show full (remapped) template
177 di.displaySciIm = True # show science image to match to
178 di.displaySpatialCells = True # show spatial cells
179 di.displayDiffIm = True # show difference image
180 di.showBadCandidates = True # show the bad candidates (red) along with good (green)
181 elif name == "lsst.ip.diffim.diaCatalogSourceSelector":
182 di.display = False # enable debug output
183 di.maskTransparency = 30 # ds9 mask transparency
184 di.displayExposure = True # show exposure with candidates indicated
185 di.pauseAtEnd = False # pause when done
187 lsstDebug.Info = DebugInfo
191 Note that if you want addional logging info, you may add to your scripts:
193 import lsst.pex.logging as pexLog
194 pexLog.Trace_setVerbosity('lsst.ip.diffim', 5)
197 #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
199 \section ip_diffim_snappsfmatch_Example A complete example of using SnapPsfMatchTask
201 This code is snapPsfMatchTask.py in the examples directory, and can be run as \em e.g.
203 examples/snapPsfMatchTask.py
204 examples/snapPsfMatchTask.py --debug
205 examples/snapPsfMatchTask.py --debug --template /path/to/templateExp.fits --science /path/to/scienceExp.fits
208 \dontinclude snapPsfMatchTask.py
209 First, create a subclass of SnapPsfMatchTask that accepts two exposures. Ideally these exposures would have
210 been taken back-to-back, such that the pointing/background/Psf does not vary substantially between the two:
211 \skip MySnapPsfMatchTask
214 And allow the user the freedom to either run the script in default mode, or point to their own images on disk.
215 Note that these images must be readable as an lsst.afw.image.Exposure:
219 We have enabled some minor display debugging in this script via the --debug option. However, if you
220 have an lsstDebug debug.py in your PYTHONPATH you will get additional debugging displays. The following
221 block checks for this script:
226 \dontinclude snapPsfMatchTask.py
227 Finally, we call a run method that we define below. First set up a Config and choose the basis set to use:
231 Make sure the images (if any) that were sent to the script exist on disk and are readable. If no images
232 are sent, make some fake data up for the sake of this example script (have a look at the code if you want
233 more details on generateFakeImages; as a detail of how the fake images were made, you do have to fit for a
234 differential background):
238 Display the two images if --debug:
242 Create and run the Task:
246 And finally provide optional debugging display of the Psf-matched (via the Psf models) science image:
248 \until result.subtractedExposure
250 #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
252 ConfigClass = SnapPsfMatchConfig
256 templateFwhmPix =
None, scienceFwhmPix =
None,
257 candidateList =
None):
258 return ImagePsfMatchTask.subtractExposures(self,
259 templateExposure = templateExposure,
260 scienceExposure = scienceExposure,
261 templateFwhmPix = templateFwhmPix,
262 scienceFwhmPix = scienceFwhmPix,
263 candidateList = candidateList,
264 doWarping = self.config.doWarping,
Image-based Psf-matching of two subsequent snaps from the same visit.