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
|
Psf-match two MaskedImages or Exposures using the sources in the images. More...
Public Member Functions | |
def | __init__ |
Create the ImagePsfMatchTask. More... | |
def | getFwhmPix |
Return the FWHM in pixels of a Psf. More... | |
def | matchExposures |
Warp and PSF-match an exposure to the reference. More... | |
def | matchMaskedImages |
PSF-match a MaskedImage (templateMaskedImage) to a reference MaskedImage (scienceMaskedImage) More... | |
def | subtractExposures |
Register, Psf-match and subtract two Exposures. More... | |
def | subtractMaskedImages |
Psf-match and subtract two MaskedImages. More... | |
def | getSelectSources |
Get sources to use for Psf-matching. More... | |
def | makeCandidateList |
Make a list of acceptable KernelCandidates. More... | |
Public Attributes | |
kConfig | |
selectSchema | |
selectAlgMetadata | |
Static Public Attributes | |
ConfigClass = ImagePsfMatchConfig | |
Private Member Functions | |
def | _adaptCellSize |
NOT IMPLEMENTED YET. More... | |
def | _buildCellSet |
Build a SpatialCellSet for use with the solve method. More... | |
def | _validateSize |
Return True if two image-like objects are the same size. More... | |
def | _validateWcs |
Return True if the WCS of the two Exposures have the same origin and extent. More... | |
Private Attributes | |
_warper | |
Psf-match two MaskedImages or Exposures using the sources in the images.
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Build a Psf-matching kernel using two input images, either as MaskedImages (in which case they need to be astrometrically aligned) or Exposures (in which case astrometric alignment will happen by default but may be turned off). This requires a list of input Sources which may be provided by the calling Task; if not, the Task will perform a coarse source detection and selection for this purpose. Sources are vetted for signal-to-noise and masked pixels (in both the template and science image), and substamps around each acceptable source are extracted and used to create an instance of KernelCandidate. Each KernelCandidate is then placed within a lsst.afw.math.SpatialCellSet, which is used by an ensemble of lsst.afw.math.CandidateVisitor instances to build the Psf-matching kernel. These visitors include, in the order that they are called: BuildSingleKernelVisitor, KernelSumVisitor, BuildSpatialKernelVisitor, and AssessSpatialKernelVisitor.
Sigma clipping of KernelCandidates is performed as follows:
The actual solving for the kernel (and differential background model) happens in lsst.ip.diffim.PsfMatchTask._solve. This involves a loop over the SpatialCellSet that first builds the per-candidate matching kernel for the requested number of KernelCandidates per cell (PsfMatchConfig.nStarPerCell). The quality of this initial per-candidate difference image is examined, using moments of the pixel residuals in the difference image normalized by the square root of the variance (i.e. sigma); ideally this should follow a normal (0, 1) distribution, but the rejection thresholds are set by the config (PsfMatchConfig.candidateResidualMeanMax and PsfMatchConfig.candidateResidualStdMax). All candidates that pass this initial build are then examined en masse to find the mean/stdev of the kernel sums across all candidates. Objects that are significantly above or below the mean, typically due to variability or sources that are saturated in one image but not the other, are also rejected. This threshold is defined by PsfMatchConfig.maxKsumSigma. Finally, a spatial model is built using all currently-acceptable candidates, and the spatial model used to derive a second set of (spatial) residuals which are again used to reject bad candidates, using the same thresholds as above.
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Create the ImagePsfMatchTask.
*args | arguments to be passed to lsst.ip.diffim.PsfMatchTask.__init__ |
**kwargs | keyword arguments to be passed to lsst.ip.diffim.PsfMatchTask.__init__ |
Upon initialization, the kernel configuration is defined by self.config.kernel.active. The task creates an lsst.afw.math.Warper from the subConfig self.config.kernel.active.warpingConfig. A schema for the selection and measurement of candidate lsst.ip.diffim.KernelCandidates is defined, and used to initize subTasks selectDetection (for candidate detection) and selectMeasurement (for candidate measurement).
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
There is no run() method for this Task. Instead there are 4 methods that may be used to invoke the Psf-matching. These are matchMaskedImages, subtractMaskedImages, matchExposures, and subtractExposures.
The methods that operate on lsst.afw.image.MaskedImage require that the images already be astrometrically aligned, and are the same shape. The methods that operate on lsst.afw.image.Exposure allow for the input images to be misregistered and potentially be different sizes; by default a lsst.afw.math.LanczosWarpingKernel is used to perform the astrometric alignment. The methods that "match" images return a Psf-matched image, while the methods that "subtract" images return a Psf-matched and template subtracted image.
See each method's returned lsst.pipe.base.Struct for more details.
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
See PsfMatchTask
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
The command line task interface supports a flag -d/–debug
to import debug.py from your PYTHONPATH
. The relevant contents of debug.py for this Task include:
Note that if you want addional logging info, you may add to your scripts:
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
This code is imagePsfMatchTask.py in the examples directory, and can be run as e.g.
And allow the user the freedom to either run the script in default mode, or point to their own images on disk. Note that these images must be readable as an lsst.afw.image.Exposure:
We have enabled some minor display debugging in this script via the –debug option. However, if you have an lsstDebug debug.py in your PYTHONPATH you will get additional debugging displays. The following block checks for this script:
Make sure the images (if any) that were sent to the script exist on disk and are readable. If no images are sent, make some fake data up for the sake of this example script (have a look at the code if you want more details on generateFakeImages):
Create and run the Task:
And finally provide some optional debugging displays:
Definition at line 81 of file imagePsfMatch.py.
def lsst.ip.diffim.imagePsfMatch.ImagePsfMatchTask.__init__ | ( | self, | |
args, | |||
kwargs | |||
) |
Create the ImagePsfMatchTask.
*args | arguments to be passed to lsst.ip.diffim.PsfMatchTask.__init__ |
**kwargs | keyword arguments to be passed to lsst.ip.diffim.PsfMatchTask.__init__ |
Upon initialization, the kernel configuration is defined by self.config.kernel.active. The task creates an lsst.afw.math.Warper from the subConfig self.config.kernel.active.warpingConfig. A schema for the selection and measurement of candidate lsst.ip.diffim.KernelCandidates is defined, and used to initize subTasks selectDetection (for candidate detection) and selectMeasurement (for candidate measurement).
Definition at line 269 of file imagePsfMatch.py.
|
private |
NOT IMPLEMENTED YET.
Definition at line 698 of file imagePsfMatch.py.
|
private |
Build a SpatialCellSet for use with the solve method.
templateMaskedImage: | MaskedImage to PSF-matched to scienceMaskedImage |
scienceMaskedImage: | reference MaskedImage |
candidateList: | a list of footprints/maskedImages for kernel candidates; if None then source detection is run.
|
Definition at line 702 of file imagePsfMatch.py.
|
private |
Return True if two image-like objects are the same size.
Definition at line 736 of file imagePsfMatch.py.
|
private |
Return True if the WCS of the two Exposures have the same origin and extent.
Definition at line 741 of file imagePsfMatch.py.
def lsst.ip.diffim.imagePsfMatch.ImagePsfMatchTask.getFwhmPix | ( | self, | |
psf | |||
) |
Return the FWHM in pixels of a Psf.
Definition at line 289 of file imagePsfMatch.py.
def lsst.ip.diffim.imagePsfMatch.ImagePsfMatchTask.getSelectSources | ( | self, | |
exposure, | |||
sigma = None , |
|||
doSmooth = True , |
|||
idFactory = None |
|||
) |
Get sources to use for Psf-matching.
This method runs detection and measurement on an exposure. The returned set of sources will be used as candidates for Psf-matching.
exposure: | Exposure on which to run detection/measurement |
sigma: | Detection threshold |
doSmooth: | Whether or not to smooth the Exposure with Psf before detection |
idFactory: | Factory for the generation of Source ids |
Definition at line 613 of file imagePsfMatch.py.
def lsst.ip.diffim.imagePsfMatch.ImagePsfMatchTask.makeCandidateList | ( | self, | |
templateExposure, | |||
scienceExposure, | |||
kernelSize, | |||
candidateList = None |
|||
) |
Make a list of acceptable KernelCandidates.
Accept or generate a list of candidate sources for Psf-matching, and examine the Mask planes in both of the images for indications of bad pixels
templateExposure: | Exposure that will be convolved |
scienceExposure: | Exposure that will be matched-to |
kernelSize: | Dimensions of the Psf-matching Kernel, used to grow detection footprints |
candidateList: | List of Sources to examine |
Definition at line 662 of file imagePsfMatch.py.
def lsst.ip.diffim.imagePsfMatch.ImagePsfMatchTask.matchExposures | ( | self, | |
templateExposure, | |||
scienceExposure, | |||
templateFwhmPix = None , |
|||
scienceFwhmPix = None , |
|||
candidateList = None , |
|||
doWarping = True , |
|||
convolveTemplate = True |
|||
) |
Warp and PSF-match an exposure to the reference.
Do the following, in order:
templateExposure: | Exposure to warp and PSF-match to the reference masked image |
scienceExposure: | Exposure whose WCS and PSF are to be matched to |
templateFwhmPix: | FWHM (in pixels) of the Psf in the template image (image to convolve) |
scienceFwhmPix: | FWHM (in pixels) of the Psf in the science image |
candidateList: | a list of footprints/maskedImages for kernel candidates; if None then source detection is run.
|
doWarping: | what to do if templateExposure's and scienceExposure's WCSs do not match:
|
convolveTemplate: | convolve the template image or the science image
|
Raise a RuntimeError if doWarping is False and templateExposure's and scienceExposure's WCSs do not match
Definition at line 297 of file imagePsfMatch.py.
def lsst.ip.diffim.imagePsfMatch.ImagePsfMatchTask.matchMaskedImages | ( | self, | |
templateMaskedImage, | |||
scienceMaskedImage, | |||
candidateList, | |||
templateFwhmPix = None , |
|||
scienceFwhmPix = None |
|||
) |
PSF-match a MaskedImage (templateMaskedImage) to a reference MaskedImage (scienceMaskedImage)
Do the following, in order:
templateMaskedImage: | masked image to PSF-match to the reference masked image; must be warped to match the reference masked image |
scienceMaskedImage: | maskedImage whose PSF is to be matched to |
templateFwhmPix: | FWHM (in pixels) of the Psf in the template image (image to convolve) |
scienceFwhmPix: | FWHM (in pixels) of the Psf in the science image |
candidateList: | a list of footprints/maskedImages for kernel candidates; if None then source detection is run.
|
Raise a RuntimeError if input images have different dimensions
Definition at line 378 of file imagePsfMatch.py.
def lsst.ip.diffim.imagePsfMatch.ImagePsfMatchTask.subtractExposures | ( | self, | |
templateExposure, | |||
scienceExposure, | |||
templateFwhmPix = None , |
|||
scienceFwhmPix = None , |
|||
candidateList = None , |
|||
doWarping = True , |
|||
convolveTemplate = True |
|||
) |
Register, Psf-match and subtract two Exposures.
Do the following, in order:
templateExposure: | exposure to PSF-match to scienceExposure |
scienceExposure: | reference Exposure |
templateFwhmPix: | FWHM (in pixels) of the Psf in the template image (image to convolve) |
scienceFwhmPix: | FWHM (in pixels) of the Psf in the science image |
candidateList: | a list of footprints/maskedImages for kernel candidates; if None then source detection is run.
|
doWarping: | what to do if templateExposure's and scienceExposure's WCSs do not match:
|
convolveTemplate: | convolve the template image or the science image
|
Definition at line 476 of file imagePsfMatch.py.
def lsst.ip.diffim.imagePsfMatch.ImagePsfMatchTask.subtractMaskedImages | ( | self, | |
templateMaskedImage, | |||
scienceMaskedImage, | |||
candidateList, | |||
templateFwhmPix = None , |
|||
scienceFwhmPix = None |
|||
) |
Psf-match and subtract two MaskedImages.
Do the following, in order:
templateMaskedImage: | MaskedImage to PSF-match to scienceMaskedImage |
scienceMaskedImage: | reference MaskedImage |
templateFwhmPix: | FWHM (in pixels) of the Psf in the template image (image to convolve) |
scienceFwhmPix: | FWHM (in pixels) of the Psf in the science image |
candidateList: | a list of footprints/maskedImages for kernel candidates; if None then source detection is run.
|
Definition at line 559 of file imagePsfMatch.py.
|
private |
Definition at line 283 of file imagePsfMatch.py.
|
static |
Definition at line 267 of file imagePsfMatch.py.
lsst.ip.diffim.imagePsfMatch.ImagePsfMatchTask.kConfig |
Definition at line 282 of file imagePsfMatch.py.
lsst.ip.diffim.imagePsfMatch.ImagePsfMatchTask.selectAlgMetadata |
Definition at line 285 of file imagePsfMatch.py.
lsst.ip.diffim.imagePsfMatch.ImagePsfMatchTask.selectSchema |
Definition at line 284 of file imagePsfMatch.py.