LSSTApplications  20.0.0
LSSTDataManagementBasePackage
coaddBoundedField.cc
Go to the documentation of this file.
1 /*
2  * LSST Data Management System
3  *
4  * This product includes software developed by the
5  * LSST Project (http://www.lsst.org/).
6  * See the COPYRIGHT file
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 #include "pybind11/pybind11.h"
23 #include "pybind11/stl.h"
24 
25 #include "lsst/geom/Box.h"
28 
29 namespace py = pybind11;
30 using namespace pybind11::literals;
31 
32 namespace lsst {
33 namespace meas {
34 namespace algorithms {
35 namespace {
36 
37 PYBIND11_MODULE(coaddBoundedField, mod) {
38  py::class_<CoaddBoundedFieldElement> clsCoaddBoundedFieldElement(mod, "CoaddBoundedFieldElement");
39 
40  clsCoaddBoundedFieldElement.def(
42  std::shared_ptr<afw::geom::SkyWcs const> wcs, py::object polygon, double weight) {
43  if (polygon.is(py::none())) {
44  return new CoaddBoundedFieldElement(field, wcs, nullptr, weight);
45  } else {
46  auto pgon = py::cast<std::shared_ptr<afw::geom::polygon::Polygon const>>(polygon);
47  return new CoaddBoundedFieldElement(field, wcs, pgon, weight);
48  }
49  }),
50  "field"_a, "wcs"_a, "validPolygon"_a, "weight"_a = 1.0);
51 
52  clsCoaddBoundedFieldElement.def_readwrite("field", &CoaddBoundedFieldElement::field);
53  clsCoaddBoundedFieldElement.def_readwrite("wcs", &CoaddBoundedFieldElement::wcs);
54  clsCoaddBoundedFieldElement.def_readwrite("validPolygon", &CoaddBoundedFieldElement::validPolygon);
55  clsCoaddBoundedFieldElement.def_readwrite("weight", &CoaddBoundedFieldElement::weight);
56 
57  clsCoaddBoundedFieldElement.def("__eq__", &CoaddBoundedFieldElement::operator==, py::is_operator());
58  clsCoaddBoundedFieldElement.def("__ne__", &CoaddBoundedFieldElement::operator!=, py::is_operator());
59 
60  afw::table::io::python::declarePersistableFacade<CoaddBoundedField>(mod, "CoaddBoundedField");
61 
62  py::class_<CoaddBoundedField, std::shared_ptr<CoaddBoundedField>,
63  afw::table::io::PersistableFacade<CoaddBoundedField>, afw::math::BoundedField>
64  clsCoaddBoundedField(mod, "CoaddBoundedField");
65 
66  clsCoaddBoundedField.attr("Element") = clsCoaddBoundedFieldElement;
67 
68  /* Constructors */
69  clsCoaddBoundedField.def(py::init<geom::Box2I const &, std::shared_ptr<afw::geom::SkyWcs const>,
70  typename CoaddBoundedField::ElementVector const &>(),
71  "bbox"_a, "coaddWcs"_a, "elements"_a);
72  clsCoaddBoundedField.def(py::init<geom::Box2I const &, std::shared_ptr<afw::geom::SkyWcs const>,
73  typename CoaddBoundedField::ElementVector const &, double>(),
74  "bbox"_a, "coaddWcs"_a, "elements"_a, "default"_a);
75 
76  /* Operators */
77  clsCoaddBoundedField.def("__eq__", &CoaddBoundedField::operator==, py::is_operator());
78  clsCoaddBoundedField.def("__ne__", &CoaddBoundedField::operator!=, py::is_operator());
79  clsCoaddBoundedField.def("__imul__", &CoaddBoundedField::operator*);
80 
81  /* Members */
82  clsCoaddBoundedField.def("evaluate", &CoaddBoundedField::evaluate);
83  clsCoaddBoundedField.def("getCoaddWcs", &CoaddBoundedField::getCoaddWcs);
84  clsCoaddBoundedField.def("getDefault", &CoaddBoundedField::getDefault);
85  clsCoaddBoundedField.def("getElements", &CoaddBoundedField::getElements);
86  clsCoaddBoundedField.def("isPersistable", &CoaddBoundedField::isPersistable);
87 }
88 
89 } // namespace
90 } // namespace algorithms
91 } // namespace meas
92 } // namespace lsst
Box.h
CoaddBoundedField.h
std::shared_ptr
STL class.
wcs
table::Key< table::Array< std::uint8_t > > wcs
Definition: SkyWcs.cc:71
validPolygon
Key< int > validPolygon
Definition: Exposure.cc:69
field
table::Key< int > field
Definition: ApCorrMap.cc:77
weight
afw::table::Key< double > weight
Definition: CoaddBoundedField.cc:166
lsst
A base class for image defects.
Definition: imageAlgorithm.dox:1
python.h
lsst::geom::Box2I
An integer coordinate rectangle.
Definition: Box.h:55
pybind11
Definition: _GenericMap.cc:40
lsst::utils.tests.init
def init()
Definition: tests.py:58
lsst::afw::cameraGeom::PYBIND11_MODULE
PYBIND11_MODULE(camera, mod)
Definition: camera.cc:133