Loading [MathJax]/extensions/tex2jax.js
LSST Applications g04a91732dc+cc8870d3f5,g07dc498a13+5aa0b8792f,g0fba68d861+80045be308,g1409bbee79+5aa0b8792f,g1a7e361dbc+5aa0b8792f,g1fd858c14a+f64bc332a9,g208c678f98+1ae86710ed,g35bb328faa+fcb1d3bbc8,g4d2262a081+47ad8a29a8,g4d39ba7253+9633a327c1,g4e0f332c67+5d362be553,g53246c7159+fcb1d3bbc8,g60b5630c4e+9633a327c1,g668ecb457e+25d63fd678,g78460c75b0+2f9a1b4bcd,g786e29fd12+cf7ec2a62a,g7b71ed6315+fcb1d3bbc8,g8852436030+8b64ca622a,g89139ef638+5aa0b8792f,g89e1512fd8+04325574d3,g8d6b6b353c+9633a327c1,g9125e01d80+fcb1d3bbc8,g989de1cb63+5aa0b8792f,g9f33ca652e+b196626af7,ga9baa6287d+9633a327c1,gaaedd4e678+5aa0b8792f,gabe3b4be73+1e0a283bba,gb1101e3267+71e32094df,gb58c049af0+f03b321e39,gb90eeb9370+2807b1ad02,gcf25f946ba+8b64ca622a,gd315a588df+a39986a76f,gd6cbbdb0b4+c8606af20c,gd9a9a58781+fcb1d3bbc8,gde0f65d7ad+4e42d81ab7,ge278dab8ac+932305ba37,ge82c20c137+76d20ab76d,gfe73954cf8+a1301e4c20,w.2025.11
LSST Data Management Base Package
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
lsst.meas.algorithms.subtractBackground Namespace Reference

Classes

class  SubtractBackgroundConfig
 
class  SubtractBackgroundTask
 

Functions

 backgroundFlatContext (maskedImage, doApply, backgroundToPhotometricRatio=None)
 

Function Documentation

◆ backgroundFlatContext()

lsst.meas.algorithms.subtractBackground.backgroundFlatContext ( maskedImage,
doApply,
backgroundToPhotometricRatio = None )
Context manager to convert from photometric-flattened to background-
flattened image.

Parameters
----------
maskedImage : `lsst.afw.image.MaskedImage`
    Masked image (image + mask + variance) to convert from a
    photometrically flat image to an image suitable for background
    subtraction.
doApply : `bool`
    Apply the conversion? If False, this context manager will not
    do anything.
backgroundToPhotometricRatio : `lsst.afw.image.Image`, optional
    Image to multiply a photometrically-flattened image by to obtain a
    background-flattened image.
    Only used if ``doApply`` is ``True``.

Yields
------
maskedImage : `lsst.afw.image.MaskedImage`
    Masked image converted into an image suitable for background
    subtraction.

Raises
------
RuntimeError if doApply is True and no ratio is supplied.
ValueError if the ratio is not an `lsst.afw.image.Image`.

Definition at line 41 of file subtractBackground.py.

41def backgroundFlatContext(maskedImage, doApply, backgroundToPhotometricRatio=None):
42 """Context manager to convert from photometric-flattened to background-
43 flattened image.
44
45 Parameters
46 ----------
47 maskedImage : `lsst.afw.image.MaskedImage`
48 Masked image (image + mask + variance) to convert from a
49 photometrically flat image to an image suitable for background
50 subtraction.
51 doApply : `bool`
52 Apply the conversion? If False, this context manager will not
53 do anything.
54 backgroundToPhotometricRatio : `lsst.afw.image.Image`, optional
55 Image to multiply a photometrically-flattened image by to obtain a
56 background-flattened image.
57 Only used if ``doApply`` is ``True``.
58
59 Yields
60 ------
61 maskedImage : `lsst.afw.image.MaskedImage`
62 Masked image converted into an image suitable for background
63 subtraction.
64
65 Raises
66 ------
67 RuntimeError if doApply is True and no ratio is supplied.
68 ValueError if the ratio is not an `lsst.afw.image.Image`.
69 """
70 if doApply:
71 if backgroundToPhotometricRatio is None:
72 raise RuntimeError("backgroundFlatContext called with doApply=True, "
73 "but without a backgroundToPhotometricRatio")
74 if not isinstance(backgroundToPhotometricRatio, afwImage.Image):
75 raise ValueError("The backgroundToPhotometricRatio must be an lsst.afw.image.Image")
76
77 maskedImage *= backgroundToPhotometricRatio
78
79 try:
80 yield maskedImage
81 finally:
82 if doApply:
83 maskedImage /= backgroundToPhotometricRatio
84
85
A class to represent a 2-dimensional array of pixels.
Definition Image.h:51