Skip to content

Commit

Permalink
Merge pull request #25 from lsst/tickets/DM-20566-coadd_utils
Browse files Browse the repository at this point in the history
DM-20566: Switch from afwGeom to geom
  • Loading branch information
timj committed Jul 16, 2019
2 parents adf6c7a + e687e9d commit 1349e88
Show file tree
Hide file tree
Showing 9 changed files with 84 additions and 84 deletions.
6 changes: 3 additions & 3 deletions include/lsst/coadd/utils/addToCoadd.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
*
* @author Russell Owen
*/
#include "lsst/afw/geom.h"
#include "lsst/geom.h"
#include "lsst/afw/image.h"

namespace lsst {
Expand All @@ -50,7 +50,7 @@ namespace utils {
* @throw pexExcept::InvalidParameterError if coadd and weightMap dimensions or xy0 do not match.
*/
template <typename CoaddPixelT, typename WeightPixelT>
lsst::afw::geom::Box2I addToCoadd(
lsst::geom::Box2I addToCoadd(
lsst::afw::image::Image<CoaddPixelT> &coadd, ///< [in,out] coadd to be modified
lsst::afw::image::Image<WeightPixelT> &
weightMap, ///< [in,out] weight map to be modified;
Expand All @@ -73,7 +73,7 @@ lsst::afw::geom::Box2I addToCoadd(
* @throw pexExcept::InvalidParameterError if coadd and weightMap dimensions or xy0 do not match.
*/
template <typename CoaddPixelT, typename WeightPixelT>
lsst::afw::geom::Box2I addToCoadd(
lsst::geom::Box2I addToCoadd(
lsst::afw::image::MaskedImage<CoaddPixelT, lsst::afw::image::MaskPixel,
lsst::afw::image::VariancePixel>
&coadd, ///< [in,out] coadd to be modified
Expand Down
2 changes: 1 addition & 1 deletion include/lsst/coadd/utils/copyGoodPixels.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
*
* @author Russell Owen
*/
#include "lsst/afw/geom.h"
#include "lsst/geom.h"
#include "lsst/afw/image.h"

namespace lsst {
Expand Down
6 changes: 3 additions & 3 deletions python/lsst/coadd/utils/addToCoadd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,16 @@ namespace {

template <typename CoaddPixelT, typename WeightPixelT>
void declareAddToCoadd(py::module &mod) {
namespace afwGeom = lsst::afw::geom;
namespace geom = lsst::geom;
namespace afwImage = lsst::afw::image;

mod.def("addToCoadd",
(afwGeom::Box2I(*)(afwImage::Image<CoaddPixelT> &, afwImage::Image<WeightPixelT> &,
(geom::Box2I(*)(afwImage::Image<CoaddPixelT> &, afwImage::Image<WeightPixelT> &,
afwImage::Image<CoaddPixelT> const &, WeightPixelT)) &
addToCoadd,
"coadd"_a, "weightMap"_a, "image"_a, "weight"_a);
mod.def("addToCoadd",
(afwGeom::Box2I(*)(afwImage::MaskedImage<CoaddPixelT> &, afwImage::Image<WeightPixelT> &,
(geom::Box2I(*)(afwImage::MaskedImage<CoaddPixelT> &, afwImage::Image<WeightPixelT> &,
afwImage::MaskedImage<CoaddPixelT> const &, afwImage::MaskPixel const,
WeightPixelT)) &
addToCoadd,
Expand Down
50 changes: 25 additions & 25 deletions src/addToCoadd.cc
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
// -*- LSST-C++ -*-

/*
/*
* LSST Data Management System
* Copyright 2008, 2009, 2010 LSST Corporation.
*
*
* This product includes software developed by the
* LSST Project (http://www.lsst.org/).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the LSST License Statement and
* the GNU General Public License along with this program. If not,
*
* You should have received a copy of the LSST License Statement and
* the GNU General Public License along with this program. If not,
* see <http://www.lsstcorp.org/LegalNotices/>.
*/

/**
* @file
*
Expand All @@ -33,11 +33,11 @@
#include "boost/format.hpp"

#include "lsst/pex/exceptions.h"
#include "lsst/afw/geom.h"
#include "lsst/geom.h"
#include "lsst/coadd/utils/addToCoadd.h"

namespace pexExcept = lsst::pex::exceptions;
namespace afwGeom = lsst::afw::geom;
namespace geom = lsst::geom;
namespace afwImage = lsst::afw::image;
namespace coaddUtils = lsst::coadd::utils;

Expand All @@ -47,28 +47,28 @@ namespace {
*/
struct CheckMask {
CheckMask(lsst::afw::image::MaskPixel badPixel) : _badPixel(badPixel) {}

template<typename T>
bool operator()(T val) const {
return ((val.mask() & _badPixel) == 0) ? true : false;
}
private:
lsst::afw::image::MaskPixel _badPixel;
};

/*
* A boolean functor to test if an Image pixel has known value (not NaN)
*/
*/
struct CheckKnownValue {
CheckKnownValue(lsst::afw::image::MaskPixel) {}

template<typename T>
bool operator()(T val) const {
return !std::isnan(static_cast<float>(*val));
}
};
/*

/*
* Implementation of addToCoadd
*
* The template parameter isValidPixel is a functor with operator()
Expand All @@ -79,31 +79,31 @@ namespace {
* @return overlapping bounding box, relative to parent image
*/
template <typename CoaddT, typename WeightPixelT, typename isValidPixel>
static lsst::afw::geom::Box2I addToCoaddImpl(
static lsst::geom::Box2I addToCoaddImpl(
CoaddT &coadd, ///< [in,out] coadd to be modified
lsst::afw::image::Image<WeightPixelT> &weightMap, ///< [in,out] weight map to be modified
CoaddT const &image, ///< image to add to coadd
lsst::afw::image::MaskPixel const badPixelMask, ///< bad pixel mask; may be ignored
WeightPixelT weight ///< relative weight of this image
) {
typedef typename afwImage::Image<WeightPixelT> WeightMapT;

if (coadd.getBBox() != weightMap.getBBox()) {
throw LSST_EXCEPT(pexExcept::InvalidParameterError,
(boost::format("coadd and weightMap parent bboxes differ: %s != %s") %
coadd.getBBox() % weightMap.getBBox()).str());
}
afwGeom::Box2I overlapBBox = coadd.getBBox();

geom::Box2I overlapBBox = coadd.getBBox();
overlapBBox.clip(image.getBBox());
if (overlapBBox.isEmpty()) {
return overlapBBox;
}

CoaddT coaddView(coadd, overlapBBox, afwImage::PARENT, false);
WeightMapT weightMapView(weightMap, overlapBBox, afwImage::PARENT, false);
CoaddT imageView(image, overlapBBox, afwImage::PARENT, false);

isValidPixel const isValid(badPixelMask); // functor to check if a pixel is good
for (int y = 0, endY = imageView.getHeight(); y != endY; ++y) {
typename CoaddT::const_x_iterator imageIter = imageView.row_begin(y);
Expand All @@ -124,7 +124,7 @@ namespace {
} // anonymous namespace

template <typename CoaddPixelT, typename WeightPixelT>
lsst::afw::geom::Box2I coaddUtils::addToCoadd(
lsst::geom::Box2I coaddUtils::addToCoadd(
// spell out lsst:afw::image to make Doxygen happy
lsst::afw::image::Image<CoaddPixelT> &coadd,
lsst::afw::image::Image<WeightPixelT> &weightMap,
Expand All @@ -136,7 +136,7 @@ lsst::afw::geom::Box2I coaddUtils::addToCoadd(
}

template <typename CoaddPixelT, typename WeightPixelT>
lsst::afw::geom::Box2I coaddUtils::addToCoadd(
lsst::geom::Box2I coaddUtils::addToCoadd(
// spell out lsst:afw::image to make Doxygen happy
lsst::afw::image::MaskedImage<CoaddPixelT, lsst::afw::image::MaskPixel,
lsst::afw::image::VariancePixel> &coadd,
Expand All @@ -156,14 +156,14 @@ lsst::afw::geom::Box2I coaddUtils::addToCoadd(
#define MASKEDIMAGE(IMAGEPIXEL) afwImage::MaskedImage<IMAGEPIXEL, \
afwImage::MaskPixel, afwImage::VariancePixel>
#define INSTANTIATE(COADDPIXEL, WEIGHTPIXEL) \
template lsst::afw::geom::Box2I coaddUtils::addToCoadd<COADDPIXEL, WEIGHTPIXEL>( \
template lsst::geom::Box2I coaddUtils::addToCoadd<COADDPIXEL, WEIGHTPIXEL>( \
afwImage::Image<COADDPIXEL> &coadd, \
afwImage::Image<WEIGHTPIXEL> &weightMap, \
afwImage::Image<COADDPIXEL> const &image, \
WEIGHTPIXEL weight \
); \
\
template lsst::afw::geom::Box2I coaddUtils::addToCoadd<COADDPIXEL, WEIGHTPIXEL>( \
template lsst::geom::Box2I coaddUtils::addToCoadd<COADDPIXEL, WEIGHTPIXEL>( \
MASKEDIMAGE(COADDPIXEL) &coadd, \
afwImage::Image<WEIGHTPIXEL> &weightMap, \
MASKEDIMAGE(COADDPIXEL) const &image, \
Expand Down
36 changes: 18 additions & 18 deletions src/copyGoodPixels.cc
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
// -*- LSST-C++ -*-

/*
/*
* LSST Data Management System
* Copyright 2008, 2009, 2010 LSST Corporation.
*
*
* This product includes software developed by the
* LSST Project (http://www.lsst.org/).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the LSST License Statement and
* the GNU General Public License along with this program. If not,
*
* You should have received a copy of the LSST License Statement and
* the GNU General Public License along with this program. If not,
* see <http://www.lsstcorp.org/LegalNotices/>.
*/

/**
* @file
*
Expand All @@ -33,11 +33,11 @@
#include "boost/format.hpp"

#include "lsst/pex/exceptions.h"
#include "lsst/afw/geom.h"
#include "lsst/geom.h"
#include "lsst/coadd/utils/copyGoodPixels.h"

namespace pexExcept = lsst::pex::exceptions;
namespace afwGeom = lsst::afw::geom;
namespace geom = lsst::geom;
namespace afwImage = lsst::afw::image;
namespace coaddUtils = lsst::coadd::utils;

Expand All @@ -47,28 +47,28 @@ namespace {
*/
struct CheckMask {
CheckMask(lsst::afw::image::MaskPixel badPixel) : _badPixel(badPixel) {}

template<typename T>
bool operator()(T val) const {
return ((val.mask() & _badPixel) == 0) ? true : false;
}
private:
lsst::afw::image::MaskPixel _badPixel;
};

/*
* A boolean functor to test if an Image pixel has known value (not NaN)
*/
*/
struct CheckKnownValue {
CheckKnownValue(lsst::afw::image::MaskPixel) {}

template<typename T>
bool operator()(T val) const {
return !std::isnan(static_cast<float>(*val));
}
};
/*

/*
* Implementation of copyGoodPixels
*
* The template parameter isValidPixel is a functor with operator()
Expand All @@ -84,15 +84,15 @@ namespace {
ImageT const &srcImage, ///< image to copy
lsst::afw::image::MaskPixel const badPixelMask ///< bad pixel mask; may be ignored
) {
afwGeom::Box2I overlapBBox = destImage.getBBox();
geom::Box2I overlapBBox = destImage.getBBox();
overlapBBox.clip(srcImage.getBBox());
if (overlapBBox.isEmpty()) {
return 0;
}

ImageT destView(destImage, overlapBBox, afwImage::PARENT, false);
ImageT srcView(srcImage, overlapBBox, afwImage::PARENT, false);

isValidPixel const isValid(badPixelMask); // functor to check if a pixel is good
int numGoodPix = 0;
for (int y = 0, endY = srcView.getHeight(); y != endY; ++y) {
Expand Down
16 changes: 8 additions & 8 deletions src/setCoaddEdgeBits.cc
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
// -*- LSST-C++ -*-

/*
/*
* LSST Data Management System
* Copyright 2008, 2009, 2010 LSST Corporation.
*
*
* This product includes software developed by the
* LSST Project (http://www.lsst.org/).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the LSST License Statement and
* the GNU General Public License along with this program. If not,
*
* You should have received a copy of the LSST License Statement and
* the GNU General Public License along with this program. If not,
* see <http://www.lsstcorp.org/LegalNotices/>.
*/

/**
* @file
*
Expand Down Expand Up @@ -53,7 +53,7 @@ void coaddUtils::setCoaddEdgeBits(
coaddMask.getWidth() % coaddMask.getHeight() % weightMap.getWidth() % weightMap.getHeight()
).str());
}

afwImage::MaskPixel const edgeMask = afwImage::Mask<afwImage::MaskPixel>::getPlaneBitMask("NO_DATA");

// Set the pixels row by row, to avoid repeated checks for end-of-row
Expand Down

0 comments on commit 1349e88

Please sign in to comment.