LSSTApplications
19.0.0-14-gb0260a2+72efe9b372,20.0.0+7927753e06,20.0.0+8829bf0056,20.0.0+995114c5d2,20.0.0+b6f4b2abd1,20.0.0+bddc4f4cbe,20.0.0-1-g253301a+8829bf0056,20.0.0-1-g2b7511a+0d71a2d77f,20.0.0-1-g5b95a8c+7461dd0434,20.0.0-12-g321c96ea+23efe4bbff,20.0.0-16-gfab17e72e+fdf35455f6,20.0.0-2-g0070d88+ba3ffc8f0b,20.0.0-2-g4dae9ad+ee58a624b3,20.0.0-2-g61b8584+5d3db074ba,20.0.0-2-gb780d76+d529cf1a41,20.0.0-2-ged6426c+226a441f5f,20.0.0-2-gf072044+8829bf0056,20.0.0-2-gf1f7952+ee58a624b3,20.0.0-20-geae50cf+e37fec0aee,20.0.0-25-g3dcad98+544a109665,20.0.0-25-g5eafb0f+ee58a624b3,20.0.0-27-g64178ef+f1f297b00a,20.0.0-3-g4cc78c6+e0676b0dc8,20.0.0-3-g8f21e14+4fd2c12c9a,20.0.0-3-gbd60e8c+187b78b4b8,20.0.0-3-gbecbe05+48431fa087,20.0.0-38-ge4adf513+a12e1f8e37,20.0.0-4-g97dc21a+544a109665,20.0.0-4-gb4befbc+087873070b,20.0.0-4-gf910f65+5d3db074ba,20.0.0-5-gdfe0fee+199202a608,20.0.0-5-gfbfe500+d529cf1a41,20.0.0-6-g64f541c+d529cf1a41,20.0.0-6-g9a5b7a1+a1cd37312e,20.0.0-68-ga3f3dda+5fca18c6a4,20.0.0-9-g4aef684+e18322736b,w.2020.45
LSSTDataManagementBasePackage
|
Go to the documentation of this file.
39 namespace ex = pex::exceptions;
63 bool const haveDefault = !
std::isnan(defaultValue);
70 }
else if (haveDefault) {
80 template <
typename ImageT>
82 :
Background(img, bgCtrl), _statsImage(
image::MaskedImage<InternalPixelT>()) {
93 for (
int iX = 0; iX < nxSample; ++iX) {
94 for (
int iY = 0; iY < nySample; ++iY) {
95 ImageT subimg = ImageT(img,
103 im(iX, iY) = res.first;
104 var(iX, iY) = res.second;
110 :
Background(imageBBox, statsImage.getWidth(), statsImage.getHeight()), _statsImage(statsImage) {}
118 _gridColumns[iX].
resize(height);
128 cullNan(
_ycen, _grid, ycenTmp, gridTmp);
134 switch (undersampleStyle) {
139 if (gridTmp.
empty()) {
152 e,
"The BackgroundControl UndersampleStyle INCREASE_NXNYSAMPLE is not supported.");
156 "UndersampleStyle %d is not defined.") %
165 for (
int iY = 0; iY < height; ++iY) {
166 _gridColumns[iX][iY] = intobj->interpolate(ypix[iY]);
171 _statsImage += delta;
176 _statsImage -= delta;
180 template <
typename PixelT>
189 str(
boost::format(
"BBox (%d:%d,%d:%d) out of range (%d:%d,%d:%d)") %
bbox.getMinX() %
193 int const nxSample = _statsImage.
getWidth();
194 int const nySample = _statsImage.
getHeight();
213 switch (undersampleStyle) {
215 if (isXundersampled && isYundersampled) {
218 "nxSample and nySample have too few points for requested interpolation style.");
219 }
else if (isXundersampled) {
221 "nxSample has too few points for requested interpolation style.");
222 }
else if (isYundersampled) {
224 "nySample has too few points for requested interpolation style.");
228 if (isXundersampled || isYundersampled) {
231 interpStyle = (nxSample < nySample) ? xStyle : yStyle;
236 if (isXundersampled || isYundersampled) {
239 "The BackgroundControl UndersampleStyle INCREASE_NXNYSAMPLE is not supported.");
245 "UndersampleStyle %d is not defined.") %
263 for (
int iY = 0; iY < height; ++iY) {
267 _gridColumns.
resize(width);
268 for (
int iX = 0; iX < nxSample; ++iX) {
269 _setGridColumns(interpStyle, undersampleStyle, iX, ypix);
288 for (
int y = 0, iY = bboxOff.getY();
y <
bbox.getHeight(); ++
y, ++iY) {
291 for (
int iX = 0; iX < nxSample; iX++) {
292 bg_x[iX] =
static_cast<double>(_gridColumns[iX][iY]);
294 cullNan(
_xcen, bg_x, xcenTmp, bgTmp, defaultValue);
299 }
catch (pex::exceptions::OutOfRangeError& e) {
300 switch (undersampleStyle) {
306 xcenTmp.push_back(0);
307 bgTmp.push_back(defaultValue);
318 "The BackgroundControl UndersampleStyle INCREASE_NXNYSAMPLE is not supported.");
322 "UndersampleStyle %d is not defined.") %
332 for (
int iX = bboxOff.getX(),
x = 0;
x <
bbox.getWidth(); ++iX, ++
x) {
333 (*bg)(
x,
y) =
static_cast<PixelT>(intobj->interpolate(iX));
336 bg->setXY0(
bbox.getMin());
341 template <
typename PixelT>
343 ApproximateControl
const& actrl,
355 #define CREATE_BACKGROUND(m, v, TYPE) \
356 template BackgroundMI::BackgroundMI(image::Image<TYPE> const& img, BackgroundControl const& bgCtrl); \
357 template BackgroundMI::BackgroundMI(image::MaskedImage<TYPE> const& img, \
358 BackgroundControl const& bgCtrl); \
359 std::shared_ptr<image::Image<TYPE>> BackgroundMI::_getImage( \
360 lsst::geom::Box2I const& bbox, \
361 Interpolate::Style const interpStyle, \
362 UndersampleStyle const undersampleStyle, \
365 return BackgroundMI::doGetImage<TYPE>(bbox, interpStyle, undersampleStyle); \
368 #define CREATE_getApproximate(m, v, TYPE) \
369 std::shared_ptr<Approximate<TYPE>> BackgroundMI::_getApproximate( \
370 ApproximateControl const& actrl, \
371 UndersampleStyle const undersampleStyle, \
374 return BackgroundMI::doGetApproximate<TYPE>(actrl, undersampleStyle); \
Backwards-compatibility support for depersisting the old Calib (FluxMag0/FluxMag0Err) objects.
y_iterator col_begin(int x) const
Return an y_iterator to the start of the y'th row.
std::shared_ptr< Interpolate > makeInterpolate(std::vector< double > const &x, std::vector< double > const &y, Interpolate::Style const style=Interpolate::AKIMA_SPLINE)
A factory function to make Interpolate objects.
BackgroundMI(ImageT const &img, BackgroundControl const &bgCtrl)
Constructor for BackgroundMI.
std::vector< int > _ysize
y size ...
int getHeight() const noexcept
std::shared_ptr< Approximate< PixelT > > makeApproximate(std::vector< double > const &x, std::vector< double > const &y, image::MaskedImage< PixelT > const &im, lsst::geom::Box2I const &bbox, ApproximateControl const &ctrl)
Construct a new Approximate object, inferring the type from the type of the given MaskedImage.
Extent2I const getDimensions() const noexcept
#define LSST_EXCEPT_ADD(e, m)
Add the current location and a message to an existing exception before rethrowing it.
Point2I const getMin() const noexcept
A class to evaluate image background levels.
def format(config, name=None, writeSourceLine=True, prefix="", verbose=False)
int getWidth() const
Return the number of columns in the image.
std::shared_ptr< StatisticsControl > getStatisticsControl()
int getHeight() const
Return the number of rows in the image.
#define LSST_makeBackground_getImage_types
std::vector< int > _yorig
y origin ...
Statistics makeStatistics(lsst::afw::image::Image< Pixel > const &img, lsst::afw::image::Mask< image::MaskPixel > const &msk, int const flags, StatisticsControl const &sctrl=StatisticsControl())
Handle a watered-down front-end to the constructor (no variance)
Value getResult(Property const prop=NOTHING) const
Return the value and error in the specified statistic (e.g.
int getWidth() const noexcept
A virtual base class to evaluate image background levels.
std::vector< double > _xcen
x center pix coords of sub images
std::shared_ptr< BackgroundControl > _bctrl
control info set by user.
UndersampleStyle _asUsedUndersampleStyle
the undersampleStyle we actually used
Reports attempts to exceed implementation-defined length limits for some classes.
bool contains(Point2I const &point) const noexcept
Return true if the box contains the point.
Pass parameters to a Background object.
std::vector< int > _xsize
x size of sub images
int lookupMinInterpPoints(Interpolate::Style const style)
Get the minimum number of points needed to use the requested interpolation style.
@ ERRORS
Include errors of requested quantities.
BOOST_PP_SEQ_FOR_EACH(INSTANTIATE_COLUMNVIEW_SCALAR, _, BOOST_PP_TUPLE_TO_SEQ(AFW_TABLE_SCALAR_FIELD_TYPE_N, AFW_TABLE_SCALAR_FIELD_TYPE_TUPLE)) BOOST_PP_SEQ_FOR_EACH(INSTANTIATE_COLUMNVIEW_ARRAY
A base class for image defects.
VariancePtr getVariance() const
Return a (shared_ptr to) the MaskedImage's variance.
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
BackgroundMI & operator+=(float const delta) override
Add a scalar to the Background (equivalent to adding a constant to the original image)
std::vector< int > _xorig
x origin pix coords of sub images
Interpolate::Style lookupMaxInterpStyle(int const n)
Get the highest order Interpolation::Style available for 'n' points.
#define LSST_makeBackground_getApproximate_types
Reports invalid arguments.
int getMaxY() const noexcept
int getMaxX() const noexcept
Interpolate::Style _asUsedInterpStyle
the style we actually used
Reports attempts to access elements outside a valid range of indices.
An integer coordinate rectangle.
lsst::geom::Box2I _imgBBox
size and origin of input image
int getMinX() const noexcept
ImagePtr getImage() const
Return a (shared_ptr to) the MaskedImage's image.
Provides consistent interface for LSST exceptions.
BackgroundMI & operator-=(float const delta) override
Subtract a scalar from the Background (equivalent to subtracting a constant from the original image)
y_iterator col_end(int x) const
Return an y_iterator to the start of the y'th row.
std::vector< double > _ycen
y center ...
int getMinY() const noexcept
Property getStatisticsProperty() const