lsst.pipe.tasks  21.0.0-149-gc9d3f519+332529d36c
Public Member Functions | Public Attributes | Static Public Attributes | List of all members
lsst.pipe.tasks.makeCoaddTempExp.MakeCoaddTempExpTask Class Reference

Warp and optionally PSF-Match calexps onto an a common projection. More...

Inheritance diagram for lsst.pipe.tasks.makeCoaddTempExp.MakeCoaddTempExpTask:
lsst.pipe.tasks.coaddBase.CoaddBaseTask

Public Member Functions

def __init__ (self, reuse=False, **kwargs)
 
def runDataRef (self, patchRef, selectDataList=[])
 Produce <coaddName>Coadd_<warpType>Warp images by warping and optionally PSF-matching. More...
 
def run (self, calExpList, ccdIdList, skyInfo, visitId=0, dataIdList=None, **kwargs)
 
def getCalibratedExposure (self, dataRef, bgSubtracted)
 
def getWarpTypeList (self)
 
def applySkyCorr (self, dataRef, calexp)
 
def selectExposures (self, patchRef, skyInfo=None, selectDataList=[])
 Select exposures to coadd. More...
 
def getSkyInfo (self, patchRef)
 Use getSkyinfo to return the skyMap, tract and patch information, wcs and the outer bbox of the patch. More...
 
def getCoaddDatasetName (self, warpType="direct")
 
def getTempExpDatasetName (self, warpType="direct")
 
def getBadPixelMask (self)
 Convenience method to provide the bitmask from the mask plane names. More...
 

Public Attributes

 reuse
 
 calexpType
 

Static Public Attributes

 ConfigClass = MakeCoaddTempExpConfig
 
 RunnerClass = CoaddTaskRunner
 

Detailed Description

Warp and optionally PSF-Match calexps onto an a common projection.

@anchor MakeCoaddTempExpTask_

@section pipe_tasks_makeCoaddTempExp_Contents  Contents

 - @ref pipe_tasks_makeCoaddTempExp_Purpose
 - @ref pipe_tasks_makeCoaddTempExp_Initialize
 - @ref pipe_tasks_makeCoaddTempExp_IO
 - @ref pipe_tasks_makeCoaddTempExp_Config
 - @ref pipe_tasks_makeCoaddTempExp_Debug
 - @ref pipe_tasks_makeCoaddTempExp_Example

@section pipe_tasks_makeCoaddTempExp_Purpose  Description

Warp and optionally PSF-Match calexps onto a common projection, by
performing the following operations:
- Group calexps by visit/run
- For each visit, generate a Warp by calling method @ref makeTempExp.
  makeTempExp loops over the visit's calexps calling @ref WarpAndPsfMatch
  on each visit

The result is a `directWarp` (and/or optionally a `psfMatchedWarp`).

@section pipe_tasks_makeCoaddTempExp_Initialize  Task Initialization

@copydoc \_\_init\_\_

This task has one special keyword argument: passing reuse=True will cause
the task to skip the creation of warps that are already present in the
output repositories.

@section pipe_tasks_makeCoaddTempExp_IO  Invoking the Task

This task is primarily designed to be run from the command line.

The main method is `runDataRef`, which takes a single butler data reference for the patch(es)
to process.

@copydoc run

WarpType identifies the types of convolutions applied to Warps (previously CoaddTempExps).
Only two types are available: direct (for regular Warps/Coadds) and psfMatched
(for Warps/Coadds with homogenized PSFs). We expect to add a third type, likelihood,
for generating likelihood Coadds with Warps that have been correlated with their own PSF.

@section pipe_tasks_makeCoaddTempExp_Config  Configuration parameters

See @ref MakeCoaddTempExpConfig and parameters inherited from
@link lsst.pipe.tasks.coaddBase.CoaddBaseConfig CoaddBaseConfig @endlink

@subsection pipe_tasks_MakeCoaddTempExp_psfMatching Guide to PSF-Matching Configs

To make `psfMatchedWarps`, select `config.makePsfMatched=True`. The subtask
@link lsst.ip.diffim.modelPsfMatch.ModelPsfMatchTask ModelPsfMatchTask @endlink
is responsible for the PSF-Matching, and its config is accessed via `config.warpAndPsfMatch.psfMatch`.
The optimal configuration depends on aspects of dataset: the pixel scale, average PSF FWHM and
dimensions of the PSF kernel. These configs include the requested model PSF, the matching kernel size,
padding of the science PSF thumbnail and spatial sampling frequency of the PSF.

*Config Guidelines*: The user must specify the size of the model PSF to which to match by setting
`config.modelPsf.defaultFwhm` in units of pixels. The appropriate values depends on science case.
In general, for a set of input images, this config should equal the FWHM of the visit
with the worst seeing. The smallest it should be set to is the median FWHM. The defaults
of the other config options offer a reasonable starting point.
The following list presents the most common problems that arise from a misconfigured
@link lsst.ip.diffim.modelPsfMatch.ModelPsfMatchTask ModelPsfMatchTask @endlink
and corresponding solutions. All assume the default Alard-Lupton kernel, with configs accessed via
```config.warpAndPsfMatch.psfMatch.kernel['AL']```. Each item in the list is formatted as:
Problem: Explanation. *Solution*

*Troublshooting PSF-Matching Configuration:*
- Matched PSFs look boxy: The matching kernel is too small. _Increase the matching kernel size.
    For example:_

        config.warpAndPsfMatch.psfMatch.kernel['AL'].kernelSize=27  # default 21

    Note that increasing the kernel size also increases runtime.
- Matched PSFs look ugly (dipoles, quadropoles, donuts): unable to find good solution
    for matching kernel. _Provide the matcher with more data by either increasing
    the spatial sampling by decreasing the spatial cell size,_

        config.warpAndPsfMatch.psfMatch.kernel['AL'].sizeCellX = 64  # default 128
        config.warpAndPsfMatch.psfMatch.kernel['AL'].sizeCellY = 64  # default 128

    _or increasing the padding around the Science PSF, for example:_

        config.warpAndPsfMatch.psfMatch.autoPadPsfTo=1.6  # default 1.4

    Increasing `autoPadPsfTo` increases the minimum ratio of input PSF dimensions to the
    matching kernel dimensions, thus increasing the number of pixels available to fit
    after convolving the PSF with the matching kernel.
    Optionally, for debugging the effects of padding, the level of padding may be manually
    controlled by setting turning off the automatic padding and setting the number
    of pixels by which to pad the PSF:

        config.warpAndPsfMatch.psfMatch.doAutoPadPsf = False  # default True
        config.warpAndPsfMatch.psfMatch.padPsfBy = 6  # pixels. default 0

- Deconvolution: Matching a large PSF to a smaller PSF produces
    a telltale noise pattern which looks like ripples or a brain.
    _Increase the size of the requested model PSF. For example:_

        config.modelPsf.defaultFwhm = 11  # Gaussian sigma in units of pixels.

- High frequency (sometimes checkered) noise: The matching basis functions are too small.
    _Increase the width of the Gaussian basis functions. For example:_

        config.warpAndPsfMatch.psfMatch.kernel['AL'].alardSigGauss=[1.5, 3.0, 6.0]
        # from default [0.7, 1.5, 3.0]


@section pipe_tasks_makeCoaddTempExp_Debug  Debug variables

MakeCoaddTempExpTask has no debug output, but its subtasks do.

@section pipe_tasks_makeCoaddTempExp_Example   A complete example of using MakeCoaddTempExpTask

This example uses the package ci_hsc to show how MakeCoaddTempExp fits
into the larger Data Release Processing.
Set up by running:

    setup ci_hsc
    cd $CI_HSC_DIR
    # if not built already:
    python $(which scons)  # this will take a while

The following assumes that `processCcd.py` and `makeSkyMap.py` have previously been run
(e.g. by building `ci_hsc` above) to generate a repository of calexps and an
output respository with the desired SkyMap. The command,

    makeCoaddTempExp.py $CI_HSC_DIR/DATA --rerun ci_hsc \
     --id patch=5,4 tract=0 filter=HSC-I \
     --selectId visit=903988 ccd=16 --selectId visit=903988 ccd=17 \
     --selectId visit=903988 ccd=23 --selectId visit=903988 ccd=24 \
     --config doApplyExternalPhotoCalib=False doApplyExternalSkyWcs=False \
     makePsfMatched=True modelPsf.defaultFwhm=11

writes a direct and PSF-Matched Warp to
- `$CI_HSC_DIR/DATA/rerun/ci_hsc/deepCoadd/HSC-I/0/5,4/warp-HSC-I-0-5,4-903988.fits` and
- `$CI_HSC_DIR/DATA/rerun/ci_hsc/deepCoadd/HSC-I/0/5,4/psfMatchedWarp-HSC-I-0-5,4-903988.fits`
    respectively.

@note PSF-Matching in this particular dataset would benefit from adding
`--configfile ./matchingConfig.py` to
the command line arguments where `matchingConfig.py` is defined by:

    echo "
    config.warpAndPsfMatch.psfMatch.kernel['AL'].kernelSize=27
    config.warpAndPsfMatch.psfMatch.kernel['AL'].alardSigGauss=[1.5, 3.0, 6.0]" > matchingConfig.py


Add the option `--help` to see more options.

Definition at line 120 of file makeCoaddTempExp.py.

Constructor & Destructor Documentation

◆ __init__()

def lsst.pipe.tasks.makeCoaddTempExp.MakeCoaddTempExpTask.__init__ (   self,
  reuse = False,
**  kwargs 
)

Definition at line 278 of file makeCoaddTempExp.py.

Member Function Documentation

◆ applySkyCorr()

def lsst.pipe.tasks.makeCoaddTempExp.MakeCoaddTempExpTask.applySkyCorr (   self,
  dataRef,
  calexp 
)
Apply correction to the sky background level

Sky corrections can be generated with the 'skyCorrection.py'
executable in pipe_drivers. Because the sky model used by that
code extends over the entire focal plane, this can produce
better sky subtraction.

The calexp is updated in-place.

Parameters
----------
dataRef : `lsst.daf.persistence.ButlerDataRef`
    Data reference for calexp.
calexp : `lsst.afw.image.Exposure` or `lsst.afw.image.MaskedImage`
    Calibrated exposure.

Definition at line 557 of file makeCoaddTempExp.py.

◆ getBadPixelMask()

def lsst.pipe.tasks.coaddBase.CoaddBaseTask.getBadPixelMask (   self)
inherited

Convenience method to provide the bitmask from the mask plane names.

Definition at line 239 of file coaddBase.py.

◆ getCalibratedExposure()

def lsst.pipe.tasks.makeCoaddTempExp.MakeCoaddTempExpTask.getCalibratedExposure (   self,
  dataRef,
  bgSubtracted 
)
Return one calibrated Exposure, possibly with an updated SkyWcs.

@param[in] dataRef        a sensor-level data reference
@param[in] bgSubtracted   return calexp with background subtracted? If False get the
                          calexp's background background model and add it to the calexp.
@return calibrated exposure

@raises MissingExposureError If data for the exposure is not available.

If config.doApplyExternalPhotoCalib is `True`, the photometric calibration
(`photoCalib`) is taken from `config.externalPhotoCalibName` via the
`name_photoCalib` dataset.  Otherwise, the photometric calibration is
retrieved from the processed exposure.  When
`config.doApplyExternalSkyWcs` is `True`, the astrometric calibration
is taken from `config.externalSkyWcsName` with the `name_wcs` dataset.
Otherwise, the astrometric calibration is taken from the processed
exposure.

Definition at line 488 of file makeCoaddTempExp.py.

◆ getCoaddDatasetName()

def lsst.pipe.tasks.coaddBase.CoaddBaseTask.getCoaddDatasetName (   self,
  warpType = "direct" 
)
inherited
Return coadd name for given warpType and task config

Parameters
----------
warpType : string
    Either 'direct' or 'psfMatched'

Returns
-------
CoaddDatasetName : `string`

Definition at line 190 of file coaddBase.py.

◆ getSkyInfo()

def lsst.pipe.tasks.coaddBase.CoaddBaseTask.getSkyInfo (   self,
  patchRef 
)
inherited

Use getSkyinfo to return the skyMap, tract and patch information, wcs and the outer bbox of the patch.

Parameters
[in]patchRefdata reference for sky map. Must include keys "tract" and "patch"
Returns
pipe_base Struct containing:
  • skyMap: sky map
  • tractInfo: information for chosen tract of sky map
  • patchInfo: information about chosen patch of tract
  • wcs: WCS of tract
  • bbox: outer bbox of patch, as an geom Box2I

Definition at line 174 of file coaddBase.py.

◆ getTempExpDatasetName()

def lsst.pipe.tasks.coaddBase.CoaddBaseTask.getTempExpDatasetName (   self,
  warpType = "direct" 
)
inherited
Return warp name for given warpType and task config

Parameters
----------
warpType : string
    Either 'direct' or 'psfMatched'

Returns
-------
WarpDatasetName : `string`

Definition at line 204 of file coaddBase.py.

◆ getWarpTypeList()

def lsst.pipe.tasks.makeCoaddTempExp.MakeCoaddTempExpTask.getWarpTypeList (   self)
Return list of requested warp types per the config.

Definition at line 547 of file makeCoaddTempExp.py.

◆ run()

def lsst.pipe.tasks.makeCoaddTempExp.MakeCoaddTempExpTask.run (   self,
  calExpList,
  ccdIdList,
  skyInfo,
  visitId = 0,
  dataIdList = None,
**  kwargs 
)
Create a Warp from inputs

We iterate over the multiple calexps in a single exposure to construct
the warp (previously called a coaddTempExp) of that exposure to the
supplied tract/patch.

Pixels that receive no pixels are set to NAN; this is not correct
(violates LSST algorithms group policy), but will be fixed up by
interpolating after the coaddition.

@param calexpRefList: List of data references for calexps that (may)
    overlap the patch of interest
@param skyInfo: Struct from CoaddBaseTask.getSkyInfo() with geometric
    information about the patch
@param visitId: integer identifier for visit, for the table that will
    produce the CoaddPsf
@return a pipeBase Struct containing:
  - exposures: a dictionary containing the warps requested:
        "direct": direct warp if config.makeDirect
        "psfMatched": PSF-matched warp if config.makePsfMatched

Definition at line 388 of file makeCoaddTempExp.py.

◆ runDataRef()

def lsst.pipe.tasks.makeCoaddTempExp.MakeCoaddTempExpTask.runDataRef (   self,
  patchRef,
  selectDataList = [] 
)

Produce <coaddName>Coadd_<warpType>Warp images by warping and optionally PSF-matching.

    @param[in] patchRef: data reference for sky map patch. Must include keys "tract", "patch",
        plus the camera-specific filter key (e.g. "filter" or "band")
    @return: dataRefList: a list of data references for the new <coaddName>Coadd_directWarps
        if direct or both warp types are requested and <coaddName>Coadd_psfMatchedWarps if only psfMatched
        warps are requested.

    @warning: this task assumes that all exposures in a warp (coaddTempExp) have the same filter.

    @warning: this task sets the PhotoCalib of the coaddTempExp to the PhotoCalib of the first calexp
    with any good pixels in the patch. For a mosaic camera the resulting PhotoCalib should be ignored
    (assembleCoadd should determine zeropoint scaling without referring to it).

Definition at line 288 of file makeCoaddTempExp.py.

◆ selectExposures()

def lsst.pipe.tasks.coaddBase.CoaddBaseTask.selectExposures (   self,
  patchRef,
  skyInfo = None,
  selectDataList = [] 
)
inherited

Select exposures to coadd.

Get the corners of the bbox supplied in skyInfo using geom::Box2D and convert the pixel positions of the bbox corners to sky coordinates using skyInfo.wcs.pixelToSky. Use the WcsSelectImagesTask to select exposures that lie inside the patch indicated by the dataRef.

Parameters
[in]patchRefdata reference for sky map patch. Must include keys "tract", "patch", plus the camera-specific filter key (e.g. "filter" or "band")
[in]skyInfogeometry for the patch; output from getSkyInfo
Returns
a list of science exposures to coadd, as butler data references

Definition at line 154 of file coaddBase.py.

Member Data Documentation

◆ calexpType

lsst.pipe.tasks.makeCoaddTempExp.MakeCoaddTempExpTask.calexpType

Definition at line 283 of file makeCoaddTempExp.py.

◆ ConfigClass

lsst.pipe.tasks.makeCoaddTempExp.MakeCoaddTempExpTask.ConfigClass = MakeCoaddTempExpConfig
static

Definition at line 275 of file makeCoaddTempExp.py.

◆ reuse

lsst.pipe.tasks.makeCoaddTempExp.MakeCoaddTempExpTask.reuse

Definition at line 280 of file makeCoaddTempExp.py.

◆ RunnerClass

lsst.pipe.tasks.coaddBase.CoaddBaseTask.RunnerClass = CoaddTaskRunner
staticinherited

Definition at line 147 of file coaddBase.py.


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