LSSTApplications  18.1.0
LSSTDataManagementBasePackage
heavyFootprint.cc
Go to the documentation of this file.
1 /*
2  * LSST Data Management System
3  * Copyright 2008-2016 AURA/LSST.
4  *
5  * This product includes software developed by the
6  * LSST Project (http://www.lsst.org/).
7  *
8  * This program is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the LSST License Statement and
19  * the GNU General Public License along with this program. If not,
20  * see <https://www.lsstcorp.org/LegalNotices/>.
21  */
22 
23 #include <pybind11/pybind11.h>
24 #include <pybind11/stl.h>
25 
26 #include "ndarray/pybind11.h"
27 
31 
32 namespace py = pybind11;
33 using namespace py::literals;
34 
35 namespace lsst {
36 namespace afw {
37 namespace detection {
38 
39 namespace {
40 template <typename ImagePixelT, typename MaskPixelT = lsst::afw::image::MaskPixel,
41  typename VariancePixelT = lsst::afw::image::VariancePixel>
42 void declareHeavyFootprint(py::module &mod, std::string const &suffix) {
43  using Class = HeavyFootprint<ImagePixelT>;
44  py::class_<Class, std::shared_ptr<Class>, Footprint> clsHeavyFootprint(
45  mod, ("HeavyFootprint" + suffix).c_str());
46 
47  /* Constructors */
48  clsHeavyFootprint.def(
49  py::init<Footprint const &,
51  HeavyFootprintCtrl const *>(),
52  "foot"_a, "mimage"_a, "ctrl"_a = nullptr);
53  clsHeavyFootprint.def(py::init<Footprint const &, HeavyFootprintCtrl const *>(), "foot"_a,
54  "ctrl"_a = nullptr);
55 
56  /* Members */
57  clsHeavyFootprint.def("isHeavy", &Class::isHeavy);
58  clsHeavyFootprint.def(
59  "insert", (void (Class::*)(lsst::afw::image::MaskedImage<ImagePixelT> &) const) & Class::insert);
60  clsHeavyFootprint.def("insert",
61  (void (Class::*)(lsst::afw::image::Image<ImagePixelT> &) const) & Class::insert);
62  clsHeavyFootprint.def("getImageArray",
63  (ndarray::Array<ImagePixelT, 1, 1> (Class::*)()) & Class::getImageArray);
64  clsHeavyFootprint.def("getMaskArray",
65  (ndarray::Array<MaskPixelT, 1, 1> (Class::*)()) & Class::getMaskArray);
66  clsHeavyFootprint.def("getVarianceArray",
67  (ndarray::Array<VariancePixelT, 1, 1> (Class::*)()) & Class::getVarianceArray);
68  clsHeavyFootprint.def("getMaskBitsSet", &Class::getMaskBitsSet);
69  clsHeavyFootprint.def("dot", &Class::dot);
70 
71  /* Module level */
72  mod.def("makeHeavyFootprint",
73  (Class(*)(Footprint const &,
75  HeavyFootprintCtrl const *))makeHeavyFootprint<ImagePixelT, MaskPixelT, VariancePixelT>,
76  "foot"_a, "img"_a, "ctrl"_a = nullptr);
77 
78  // In Swig this seems to be suffixed with a type (i.e. mergeHeavyFootprintsF)
79  // but there really doesn't seem any good reason why that is done, so removed it
80  mod.def("mergeHeavyFootprints", mergeHeavyFootprints<ImagePixelT, MaskPixelT, VariancePixelT>);
81 }
82 } // namespace
83 
85  declareHeavyFootprint<int>(mod, "I");
86  declareHeavyFootprint<std::uint16_t>(mod, "U");
87  declareHeavyFootprint<float>(mod, "F");
88  declareHeavyFootprint<double>(mod, "D");
89 }
90 }
91 }
92 } // lsst::afw::detection
PYBIND11_MODULE(heavyFootprint, mod)
def init()
Definition: tests.py:75
def dot(symb, c, r, frame=None, size=2, ctype=None, origin=afwImage.PARENT, args, kwargs)
Definition: ds9.py:101
STL class.
A base class for image defects.
A class to manipulate images, masks, and variance as a single object.
Definition: MaskedImage.h:74
std::int32_t MaskPixel
default type for Masks and MaskedImage Masks
lsst::afw::detection::Footprint Footprint
Definition: Source.h:61
float VariancePixel
default type for MaskedImage variance images
A class to represent a 2-dimensional array of pixels.
Definition: Image.h:59