lsst.pipe.tasks gb1d6de0934+c320316d7a
Public Member Functions | Static Public Attributes | List of all members
lsst.pipe.tasks.repair.RepairTask Class Reference

More...

Inheritance diagram for lsst.pipe.tasks.repair.RepairTask:

Public Member Functions

def __init__ (self, **kwargs)
 
def run (self, exposure, defects=None, keepCRs=None)
 Repair an Exposure's defects and cosmic rays. More...
 
def cosmicRay (self, exposure, keepCRs=None)
 

Static Public Attributes

 ConfigClass = RepairConfig
 

Detailed Description

Interpolate over defects in an exposure and handle cosmic rays

Contents

Description

This task operates on an lsst.afw.image.Exposure in place to interpolate over a set of lsst.meas.algorithms.Defect objects. It will also, optionally, find and interpolate any cosmic rays in the lsst.afw.image.Exposure.

Task initialization

See: lsst.pipe.base.task.Task.__init__

Inputs/Outputs to the run method

Repair an Exposure's defects and cosmic rays.

    @param[in, out] exposure  lsst.afw.image.Exposure to process.  Exposure must have a valid Psf.
                              Modified in place.
    @param[in]      defects   an lsst.meas.algorithms.DefectListT object.  If None, do no
                              defect correction.
    @param[in]      keepCRs   don't interpolate over the CR pixels (defer to RepairConfig if None)

    @throws AssertionError with the following strings:

    <DL>
      <DT> No exposure provided
      <DD> The object provided as exposure evaluates to False
      <DT> No PSF provided
      <DD> The Exposure has no associated Psf
    </DL>

Configuration parameters

See RepairConfig

Debug variables

The command line task interface supports a flag -d to import debug.py from your PYTHONPATH; see Debugging Tasks with lsstDebug for more about debug.py files.

The available variables in RepairTask are:

display
A dictionary containing debug point names as keys with frame number as value. Valid keys are:
repair.before
display image before any repair is done
repair.after
display image after cosmic ray and defect correction
displayCR
If True, display the exposure on display's frame 1 and overlay bounding boxes around detects CRs.

A complete example of using RepairTask

This code is in runRepair.py in the examples directory, and can be run as e.g.

examples/runRepair.py

Import the task. There are other imports. Read the source file for more info.

0from lsst.pipe.tasks.repair import RepairTask

For this example, we manufacture a test image to run on.

First, create a pure Poisson noise image and a Psf to go with it. The mask plane and variance can be constructed at the same time.

35 randArr = numpy.random.poisson(1000., xsize*ysize)
36 randArr = numpy.array(randArr.reshape(ysize, xsize), dtype=numpy.float32) # force to ImageF
37 factory = measAlg.GaussianPsfFactory()
38 factory.addWing = False
39 psf = factory.apply(4) # FWHM in pixels
40
41 img = afwImage.makeImageFromArray(randArr)
42 var = afwImage.ImageF(img, True) # copy constructor
43 mask = afwImage.Mask(xsize, ysize)

Inject some cosmic rays and generate the Exposure. Exposures are MaskedImages (image + mask + variance) with other metadata (e.g. Psf and Wcs objects).

49 # set some CRs
50 for xi, yi in zip(xind, yind):
51 xi, yi = int(xi), int(yi)
52 img.set(xi, yi, 1e6)
53
54 mi = afwImage.makeMaskedImage(img, mask, var)
55 exp = afwImage.makeExposure(mi)
56 exp.setPsf(psf)

Defects are represented as bad columns of random lengths. A defect list must be constructed to pass on to the RepairTask.

Bug:
This is addressed in DM-963

Finally, the exposure can be repaired. Create an instance of the task and run it. The exposure is modified in place.


To investigate the Debug variables, put something like

import lsstDebug
def DebugInfo(name):
di = lsstDebug.getInfo(name) # N.b. lsstDebug.Info(name) would call us recursively
if name == "lsst.pipe.tasks.repair":
di.display = {'repair.before':2, 'repair.after':3}
di.displayCR = True
return di
lsstDebug.Info = DebugInfo

into your debug.py file and run runRepair.py with the –debug flag.

Conversion notes: Display code should be updated once we settle on a standard way of controlling what is displayed.

Definition at line 66 of file repair.py.

Constructor & Destructor Documentation

◆ __init__()

def lsst.pipe.tasks.repair.RepairTask.__init__ (   self,
**  kwargs 
)

Definition at line 177 of file repair.py.

Member Function Documentation

◆ cosmicRay()

def lsst.pipe.tasks.repair.RepairTask.cosmicRay (   self,
  exposure,
  keepCRs = None 
)
Mask cosmic rays

@param[in,out] exposure Exposure to process
@param[in]     keepCRs  Don't interpolate over the CR pixels (defer to pex_config if None)

Definition at line 219 of file repair.py.

◆ run()

def lsst.pipe.tasks.repair.RepairTask.run (   self,
  exposure,
  defects = None,
  keepCRs = None 
)

Repair an Exposure's defects and cosmic rays.

    @param[in, out] exposure  lsst.afw.image.Exposure to process.  Exposure must have a valid Psf.
                              Modified in place.
    @param[in]      defects   an lsst.meas.algorithms.DefectListT object.  If None, do no
                              defect correction.
    @param[in]      keepCRs   don't interpolate over the CR pixels (defer to RepairConfig if None)

    @throws AssertionError with the following strings:

    <DL>
      <DT> No exposure provided
      <DD> The object provided as exposure evaluates to False
      <DT> No PSF provided
      <DD> The Exposure has no associated Psf
    </DL>

Definition at line 183 of file repair.py.

Member Data Documentation

◆ ConfigClass

lsst.pipe.tasks.repair.RepairTask.ConfigClass = RepairConfig
static

Definition at line 174 of file repair.py.


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