SubtractBackgroundTask

SubtractBackgroundTask fits a model of the background of an exposure and subtracts it.

Python API summary

from lsst.meas.algorithms.subtractBackground import SubtractBackgroundTask
classSubtractBackgroundTask(config=None, *, name=None, parentTask=None, log=None)

Subtract the background from an exposure...

attributeconfig

Access configuration fields and retargetable subtasks.

methodrun(exposure, background=None, stats=True, statsKeys=None)

Fit and subtract the background of an exposure...

See also

See the SubtractBackgroundTask API reference for complete details.

Retargetable subtasks

No subtasks.

Configuration fields

algorithm

Default
'AKIMA_SPLINE'
Field type

str ChoiceField (optional)

Choices
'CONSTANT'

Use a single constant value

'LINEAR'

Use linear interpolation

'NATURAL_SPLINE'

cubic spline with zero second derivative at endpoints

'AKIMA_SPLINE'

higher-level nonlinear spline that is more robust to outliers

'NONE'

No background estimation is to be attempted

None

Field is optional

how to interpolate the background values. This maps to an enum; see afw::math::Background

approxOrderX

Default
6
Field type

int Field

Approximation order in X for background Chebyshev (valid only with useApprox=True)

approxOrderY

Default
-1
Field type

int Field

Approximation order in Y for background Chebyshev (valid only with useApprox=True)

binSize

Default
128
Field type

int RangeField

Range

[1,inf)

how large a region of the sky should be used for each background point

binSizeX

Default
0
Field type

int RangeField

Range

[0,inf)

Sky region size to be used for each background point in X direction. If 0, the binSize config is used.

binSizeY

Default
0
Field type

int RangeField

Range

[0,inf)

Sky region size to be used for each background point in Y direction. If 0, the binSize config is used.

ignoredPixelMask

Default
['BAD', 'EDGE', 'DETECTED', 'DETECTED_NEGATIVE', 'NO_DATA']
Field type

str ListField

Names of mask planes to ignore while estimating the background

isNanSafe

Default
False
Field type

bool Field

Ignore NaNs when estimating the background

statisticsProperty

Default
'MEANCLIP'
Field type

str ChoiceField (optional)

Choices
'MEANCLIP'

clipped mean

'MEAN'

unclipped mean

'MEDIAN'

median

None

Field is optional

type of statistic to use for grid points

undersampleStyle

Default
'REDUCE_INTERP_ORDER'
Field type

str ChoiceField (optional)

Choices
'THROW_EXCEPTION'

throw an exception if there are too few points

'REDUCE_INTERP_ORDER'

use an interpolation style with a lower order.

'INCREASE_NXNYSAMPLE'

Increase the number of samples used to make the interpolation grid.

None

Field is optional

behaviour if there are too few points in grid for requested interpolation style

useApprox

Default
True
Field type

bool Field

Use Approximate (Chebyshev) to model background.

weighting

Default
True
Field type

bool Field

Use inverse variance weighting in calculation (valid only with useApprox=True)

In Depth

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:

  • BGMEAN: Mean value of the background

  • BGVAR: Standard deviation of background

Debugging

SubtractBackgroundTask has a debug dictionary containing three integer keys:

unsubtracted

int; If >0: fitBackground displays the unsubtracted masked image overlaid with the grid of cells used to fit the background in the specified frame.

subtracted

int; If >0: run displays the background-subtracted exposure in the specified frame.

background

int; If >0: run displays the background image in the specified frame.