LSST Applications g0265f82a02+0e5473021a,g02d81e74bb+0dd8ce4237,g1470d8bcf6+3ea6592b6f,g2079a07aa2+86d27d4dc4,g2305ad1205+5ca4c0b359,g295015adf3+d10818ec9d,g2a9a014e59+6f9be1b9cd,g2bbee38e9b+0e5473021a,g337abbeb29+0e5473021a,g3ddfee87b4+703ba97ebf,g487adcacf7+4fa16da234,g50ff169b8f+96c6868917,g52b1c1532d+585e252eca,g591dd9f2cf+ffa42b374e,g5a732f18d5+53520f316c,g64a986408d+0dd8ce4237,g858d7b2824+0dd8ce4237,g8a8a8dda67+585e252eca,g99cad8db69+d39438377f,g9ddcbc5298+9a081db1e4,ga1e77700b3+15fc3df1f7,ga8c6da7877+f1d96605c8,gb0e22166c9+60f28cb32d,gb6a65358fc+0e5473021a,gba4ed39666+c2a2e4ac27,gbb8dafda3b+e5339d463f,gc120e1dc64+da31e9920e,gc28159a63d+0e5473021a,gcf0d15dbbd+703ba97ebf,gdaeeff99f8+f9a426f77a,ge6526c86ff+889fc9d533,ge79ae78c31+0e5473021a,gee10cc3b42+585e252eca,gf18bd8381d+7268b93478,gff1a9f87cc+0dd8ce4237,w.2024.16
LSST Data Management Base Package
Loading...
Searching...
No Matches
Namespaces | Functions
lsst::coadd::utils Namespace Reference

Namespaces

namespace  version
 

Functions

template<typename CoaddPixelT , typename WeightPixelT >
lsst::geom::Box2I addToCoadd (lsst::afw::image::Image< CoaddPixelT > &coadd, lsst::afw::image::Image< WeightPixelT > &weightMap, lsst::afw::image::Image< CoaddPixelT > const &image, WeightPixelT weight)
 add good pixels from an image to a coadd and associated weight map
 
template<typename CoaddPixelT , typename WeightPixelT >
lsst::geom::Box2I addToCoadd (lsst::afw::image::MaskedImage< CoaddPixelT, lsst::afw::image::MaskPixel, lsst::afw::image::VariancePixel > &coadd, lsst::afw::image::Image< WeightPixelT > &weightMap, lsst::afw::image::MaskedImage< CoaddPixelT, lsst::afw::image::MaskPixel, lsst::afw::image::VariancePixel > const &maskedImage, lsst::afw::image::MaskPixel const badPixelMask, WeightPixelT weight)
 add good pixels from a masked image to a coadd image and associated weight map
 
template<typename ImagePixelT >
int copyGoodPixels (lsst::afw::image::Image< ImagePixelT > &destImage, lsst::afw::image::Image< ImagePixelT > const &srcImage)
 copy good pixels from one image to another
 
template<typename ImagePixelT >
int copyGoodPixels (lsst::afw::image::MaskedImage< ImagePixelT, lsst::afw::image::MaskPixel, lsst::afw::image::VariancePixel > &destImage, lsst::afw::image::MaskedImage< ImagePixelT, lsst::afw::image::MaskPixel, lsst::afw::image::VariancePixel > const &srcImage, lsst::afw::image::MaskPixel const badPixelMask)
 copy good pixels from one masked image to another
 
template<typename WeightPixelT >
void setCoaddEdgeBits (lsst::afw::image::Mask< lsst::afw::image::MaskPixel > &coaddMask, lsst::afw::image::Image< WeightPixelT > const &weightMap)
 set edge bits of coadd mask based on weight map
 
void wrapAddtoCoadd (WrapperCollection &wrappers)
 
void wrapCopyGoodPixels (WrapperCollection &wrappers)
 
void wrapSetCoaddEdgeBits (WrapperCollection &wrappers)
 
 PYBIND11_MODULE (_coaddUtilsLib, mod)
 

Detailed Description

lsst.coadd.utils

Function Documentation

◆ addToCoadd() [1/2]

template<typename CoaddPixelT , typename WeightPixelT >
lsst::geom::Box2I lsst::coadd::utils::addToCoadd ( lsst::afw::image::Image< CoaddPixelT > & coadd,
lsst::afw::image::Image< WeightPixelT > & weightMap,
lsst::afw::image::Image< CoaddPixelT > const & image,
WeightPixelT weight )

add good pixels from an image to a coadd and associated weight map

The images are assumed to be registered to the same wcs and parent origin, thus: coadd[i+coadd.x0, j+coadd.y0] += image[i+image.x0, j+image.y0] weightMap[i+weightMap.x0, j+weightMap.y0] += weight for all good image pixels that overlap a coadd pixel. Good pixels are those that are not NaN (thus they do include +/- inf).

Returns
overlapBBox: overlapping bounding box, relative to parent image (hence xy0 is taken into account)
Exceptions
pexExcept::InvalidParameterErrorif coadd and weightMap dimensions or xy0 do not match.
Parameters
[in,out]coaddcoadd to be modified
[in,out]weightMapweight map to be modified; this is the sum of weights of all images contributing each pixel of the coadd
imageimage to add to coadd
weightrelative weight of this image

Definition at line 127 of file addToCoadd.cc.

133 {
135 return addToCoaddImpl<Image, WeightPixelT, CheckKnownValue>(coadd, weightMap, image, 0x0, weight);
136}
A class to represent a 2-dimensional array of pixels.
Definition Image.h:51
afw::table::Key< double > weight

◆ addToCoadd() [2/2]

template<typename CoaddPixelT , typename WeightPixelT >
lsst::geom::Box2I lsst::coadd::utils::addToCoadd ( lsst::afw::image::MaskedImage< CoaddPixelT, lsst::afw::image::MaskPixel, lsst::afw::image::VariancePixel > & coadd,
lsst::afw::image::Image< WeightPixelT > & weightMap,
lsst::afw::image::MaskedImage< CoaddPixelT, lsst::afw::image::MaskPixel, lsst::afw::image::VariancePixel > const & maskedImage,
lsst::afw::image::MaskPixel const badPixelMask,
WeightPixelT weight )

add good pixels from a masked image to a coadd image and associated weight map

The images are assumed to be registered to the same wcs and parent origin, thus: coadd[i+coadd.x0, j+coadd.y0] += image[i+image.x0, j+image.y0] weightMap[i+weightMap.x0, j+weightMap.y0] += weight for all good image pixels that overlap a coadd pixel. Good pixels are those for which mask & badPixelMask == 0.

Returns
overlapBBox: overlapping bounding box, relative to parent image (hence xy0 is taken into account)
Exceptions
pexExcept::InvalidParameterErrorif coadd and weightMap dimensions or xy0 do not match.
Parameters
[in,out]coaddcoadd to be modified
[in,out]weightMapweight map to be modified; this is the sum of weights of all images contributing each pixel of the coadd
maskedImagemasked image to add to coadd
badPixelMaskskip input pixel if input mask & badPixelMask !=0
weightrelative weight of this image

Definition at line 139 of file addToCoadd.cc.

148 {
150 return addToCoaddImpl<Image,WeightPixelT,CheckMask>(coadd, weightMap, maskedImage, badPixelMask, weight);
151}
A class to manipulate images, masks, and variance as a single object.
Definition MaskedImage.h:74

◆ copyGoodPixels() [1/2]

template<typename ImagePixelT >
int lsst::coadd::utils::copyGoodPixels ( lsst::afw::image::Image< ImagePixelT > & destImage,
lsst::afw::image::Image< ImagePixelT > const & srcImage )

copy good pixels from one image to another

Good pixels are those that are not NaN (thus they do include +/- inf).

Only the overlapping pixels (relative to the parent) are copied; thus the images do not have to be the same size.

Returns
number of pixels copied
Parameters
[in,out]destImageimage to be modified
srcImageimage to copy

Definition at line 116 of file copyGoodPixels.cc.

120 {
122 return copyGoodPixelsImpl<Image, CheckKnownValue>(destImage, srcImage, 0x0);
123}

◆ copyGoodPixels() [2/2]

template<typename ImagePixelT >
int lsst::coadd::utils::copyGoodPixels ( lsst::afw::image::MaskedImage< ImagePixelT, lsst::afw::image::MaskPixel, lsst::afw::image::VariancePixel > & destImage,
lsst::afw::image::MaskedImage< ImagePixelT, lsst::afw::image::MaskPixel, lsst::afw::image::VariancePixel > const & srcImage,
lsst::afw::image::MaskPixel const badPixelMask )

copy good pixels from one masked image to another

Good pixels are those for which mask & badPixelMask == 0.

Only the overlapping pixels (relative to the parent) are copied; thus the images do not have to be the same size.

Returns
number of pixels copied
Parameters
[in,out]destImageimage to be modified
srcImageimage to copy
badPixelMaskskip input pixel if src mask & badPixelMask != 0

Definition at line 126 of file copyGoodPixels.cc.

133 {
135 return copyGoodPixelsImpl<Image, CheckMask>(destImage, srcImage, badPixelMask);
136}

◆ PYBIND11_MODULE()

lsst::coadd::utils::PYBIND11_MODULE ( _coaddUtilsLib ,
mod  )

Definition at line 36 of file _coaddUtilsLib.cc.

36 {
37 lsst::cpputils::python::WrapperCollection wrappers(mod, "lsst.coadd.utils");
38 wrappers.addSignatureDependency("lsst.afw.image");
39 wrappers.addSignatureDependency("lsst.afw.geom");
40 wrapAddtoCoadd(wrappers);
41 wrapCopyGoodPixels(wrappers);
42 wrapSetCoaddEdgeBits(wrappers);
43 wrappers.finish();
44}
A helper class for subdividing pybind11 module across multiple translation units (i....
Definition python.h:242
void wrapAddtoCoadd(WrapperCollection &wrappers)
Definition addToCoadd.cc:57
void wrapCopyGoodPixels(WrapperCollection &wrappers)
void wrapSetCoaddEdgeBits(WrapperCollection &wrappers)

◆ setCoaddEdgeBits()

template<typename WeightPixelT >
void lsst::coadd::utils::setCoaddEdgeBits ( lsst::afw::image::Mask< lsst::afw::image::MaskPixel > & coaddMask,
lsst::afw::image::Image< WeightPixelT > const & weightMap )

set edge bits of coadd mask based on weight map

Set pixels in the image to the edge pixel when the corresponding pixel in the weight map is zero. The edge pixel is image=nan, variance=inf, mask=NO_DATA for masked images and image=nan for plain images.

Exceptions
pexExcept::InvalidParameterErrorif the dimensions of coaddMask and weightMap do not match.
Parameters
[in,out]coaddMaskmask of coadd
weightMapweight map

Definition at line 42 of file setCoaddEdgeBits.cc.

46 {
48 typedef typename afwImage::Image<WeightPixelT>::const_x_iterator WeightMapConstXIter;
49
50 if (coaddMask.getDimensions() != weightMap.getDimensions()) {
52 (boost::format("coaddMask and weightMap dimensions differ: %dx%d != %dx%d") %
53 coaddMask.getWidth() % coaddMask.getHeight() % weightMap.getWidth() % weightMap.getHeight()
54 ).str());
55 }
56
58
59 // Set the pixels row by row, to avoid repeated checks for end-of-row
60 for (int y = 0, endY = weightMap.getHeight(); y != endY; ++y) {
61 WeightMapConstXIter weightMapPtr = weightMap.row_begin(y);
62 WeightMapConstXIter const weightMapEndPtr = weightMap.row_end(y);
63 MaskXIter coaddMaskPtr = coaddMask.row_begin(y);
64 for (; weightMapPtr != weightMapEndPtr; ++weightMapPtr, ++coaddMaskPtr) {
65 if (*weightMapPtr == 0) {
66 (*coaddMaskPtr) = (*coaddMaskPtr) | edgeMask;
67 }
68 }
69 }
70}
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition Exception.h:48
int y
Definition SpanSet.cc:48
int getWidth() const
Return the number of columns in the image.
Definition ImageBase.h:294
lsst::geom::Extent2I getDimensions() const
Return the image's size; useful for passing to constructors.
Definition ImageBase.h:356
int getHeight() const
Return the number of rows in the image.
Definition ImageBase.h:296
x_iterator row_begin(int y) const
Return an x_iterator to the start of the y'th row.
Definition ImageBase.h:401
x_iterator row_end(int y) const
Return an x_iterator to the end of the y'th row.
Definition ImageBase.h:404
Represent a 2-dimensional array of bitmask pixels.
Definition Mask.h:77
Reports invalid arguments.
Definition Runtime.h:66

◆ wrapAddtoCoadd()

void lsst::coadd::utils::wrapAddtoCoadd ( WrapperCollection & wrappers)

Definition at line 57 of file addToCoadd.cc.

57 {
58 auto &mod = wrappers.module;
59 declareAddToCoadd<double, double>(mod);
60 declareAddToCoadd<double, float>(mod);
61 declareAddToCoadd<double, int>(mod);
62 declareAddToCoadd<double, std::uint16_t>(mod);
63 declareAddToCoadd<float, double>(mod);
64 declareAddToCoadd<float, float>(mod);
65 declareAddToCoadd<float, int>(mod);
66 declareAddToCoadd<float, std::uint16_t>(mod);
67}

◆ wrapCopyGoodPixels()

void lsst::coadd::utils::wrapCopyGoodPixels ( WrapperCollection & wrappers)

Definition at line 53 of file copyGoodPixels.cc.

53 {
54 auto &mod = wrappers.module;
55 declareCopyGoodPixels<double>(mod);
56 declareCopyGoodPixels<float>(mod);
57 declareCopyGoodPixels<int>(mod);
58 declareCopyGoodPixels<std::uint16_t>(mod);
59}

◆ wrapSetCoaddEdgeBits()

void lsst::coadd::utils::wrapSetCoaddEdgeBits ( WrapperCollection & wrappers)

Definition at line 49 of file setCoaddEdgeBits.cc.

49 {
50 auto &mod = wrappers.module;
51 declareSetCoaddEdgeBits<double>(mod);
52 declareSetCoaddEdgeBits<float>(mod);
53 declareSetCoaddEdgeBits<int>(mod);
54 declareSetCoaddEdgeBits<std::uint16_t>(mod);
55}