lsst.meas.algorithms  21.0.0-16-gaea1be32+112fba10e1
Public Member Functions | Static Public Attributes | List of all members
lsst.meas.algorithms.subtractBackground.SubtractBackgroundTask Class Reference

Subtract the background from an exposure. More...

Inheritance diagram for lsst.meas.algorithms.subtractBackground.SubtractBackgroundTask:

Public Member Functions

def run (self, exposure, background=None, stats=True, statsKeys=None)
 Fit and subtract the background of an exposure. More...
 
def fitBackground (self, maskedImage, nx=0, ny=0, algorithm=None)
 Estimate the background of a masked image. More...
 

Static Public Attributes

 ConfigClass = SubtractBackgroundConfig
 

Detailed Description

Subtract the background from an exposure.

@anchor SubtractBackgroundTask_

@section meas_algorithms_subtractBackground_Contents  Contents

 - @ref meas_algorithms_subtractBackground_Purpose
 - @ref meas_algorithms_subtractBackground_Initialize
 - @ref meas_algorithms_subtractBackground_IO
 - @ref meas_algorithms_subtractBackground_Config
 - @ref meas_algorithms_subtractBackground_Metadata
 - @ref meas_algorithms_subtractBackground_Debug
 - @ref meas_algorithms_subtractBackground_Example

@section meas_algorithms_subtractBackground_Purpose  Description

Fit a model of the background of an exposure and subtract it.

@section meas_algorithms_subtractBackground_Initialize  Task initialisation

@copydoc \_\_init\_\_

@section meas_algorithms_subtractBackground_IO  Invoking the Task

Call `run` to fit the background and subtract it.

Call `fitBackground` to fit the background without subtracting it.

@section meas_algorithms_subtractBackground_Config  Configuration parameters

See @ref SubtractBackgroundConfig

@section meas_algorithms_subtractBackground_Metadata  Quantities set in exposure Metadata

The `run` method will optionally set the following items of exposure metadata;
the names may be overridden; the defaults are shown:
<dl>
    <dt>BGMEAN <dd>mean value of background
    <dt>BGVAR  <dd>standard deviation of background
</dl>

@section meas_algorithms_subtractBackground_Debug  Debug variables

The @link lsst.pipe.base.cmdLineTask.CmdLineTask command line task@endlink interface supports a flag
`--debug` to import `debug.py` from your `$PYTHONPATH`; see @ref baseDebug for more about `debug.py`.

SubtractBackgroundTask has a debug dictionary containing three integer keys:
<dl>
<dt>unsubtracted
<dd>If >0: `fitBackground` displays the unsubtracted masked image overlaid with the grid of cells
            used to fit the background in the specified frame
<dt>subtracted
<dd>If >0: `run` displays the background-subtracted exposure is the specified frame
<dt>background
<dd>If >0: `run` displays the background image in the specified frame
</dl>

For example, put something like:
@code{.py}
    import lsstDebug
    def DebugInfo(name):
        di = lsstDebug.getInfo(name)  # N.b. lsstDebug.Info(name) would call us recursively
        if name == "lsst.meas.algorithms.subtractBackground":
            di.display = dict(
                unsubtracted = 1,
                subtracted = 2,
                background = 3,
            )

        return di

    lsstDebug.Info = DebugInfo
@endcode
into your `debug.py` file and run your task with the `--debug` flag.

@section meas_algorithms_subtractBackground_Example   A complete example of using SubtractBackgroundTask

This code is in @link subtractBackgroundExample.py@endlink in the examples directory, and can be run as:
@code
python examples/subtractBackgroundExample.py
@endcode
@dontinclude subtractBackgroundExample.py

Import the task (there are some other standard imports; read the file if you're curious)
@skipline import SubtractBackgroundTask

Create the task, run it, and report mean and variance of background.
@skip create the task
@until print

Definition at line 126 of file subtractBackground.py.

Member Function Documentation

◆ fitBackground()

def lsst.meas.algorithms.subtractBackground.SubtractBackgroundTask.fitBackground (   self,
  maskedImage,
  nx = 0,
  ny = 0,
  algorithm = None 
)

Estimate the background of a masked image.

    @param[in] maskedImage  masked image whose background is to be computed
    @param[in] nx  number of x bands; if 0 compute from width and config.binSizeX
    @param[in] ny  number of y bands; if 0 compute from height and config.binSizeY
    @param[in] algorithm  name of interpolation algorithm; if None use self.config.algorithm

    @return fit background as an lsst.afw.math.Background

    @throw RuntimeError if lsst.afw.math.makeBackground returns None,
        which is apparently one way it indicates failure

Definition at line 285 of file subtractBackground.py.

◆ run()

def lsst.meas.algorithms.subtractBackground.SubtractBackgroundTask.run (   self,
  exposure,
  background = None,
  stats = True,
  statsKeys = None 
)

Fit and subtract the background of an exposure.

    @param[in,out] exposure  exposure whose background is to be subtracted
    @param[in,out] background  initial background model already subtracted from exposure
        (an lsst.afw.math.BackgroundList). May be None if no background has been subtracted.
    @param[in] stats  if True then measure the mean and variance of the full background model
                    and record the results in the exposure's metadata
    @param[in] statsKeys  key names used to store the mean and variance of the background
        in the exposure's metadata (a pair of strings); if None then use ("BGMEAN", "BGVAR");
        ignored if stats is false

    @return an lsst.pipe.base.Struct containing:
    - background  full background model (initial model with changes), an lsst.afw.math.BackgroundList

Definition at line 220 of file subtractBackground.py.

Member Data Documentation

◆ ConfigClass

lsst.meas.algorithms.subtractBackground.SubtractBackgroundTask.ConfigClass = SubtractBackgroundConfig
static

Definition at line 217 of file subtractBackground.py.


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