lsst.meas.algorithms  13.0-23-gb99accf8
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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/afw/table/io/python.h"
27 
28 namespace py = pybind11;
29 using namespace pybind11::literals;
30 
31 namespace lsst {
32 namespace meas {
33 namespace algorithms {
34 
35 PYBIND11_PLUGIN(coaddBoundedField) {
36  py::module mod("coaddBoundedField");
37 
38  py::class_<CoaddBoundedFieldElement> clsCoaddBoundedFieldElement(mod, "CoaddBoundedFieldElement");
39 
40  clsCoaddBoundedFieldElement.def(
41  "__init__",
42  [](CoaddBoundedFieldElement &instance,
43  std::shared_ptr<afw::math::BoundedField> field,
44  std::shared_ptr<afw::image::Wcs const> wcs,
45  py::object polygon,
46  double weight) {
47  if (polygon == py::none()) {
48  new (&instance) CoaddBoundedFieldElement(field, wcs, nullptr, weight);
49  } else {
50  auto pgon = py::cast<std::shared_ptr<afw::geom::polygon::Polygon const>>(polygon);
51  new (&instance) CoaddBoundedFieldElement(field, wcs, pgon, weight);
52  }
53  },
54  "field"_a, "wcs"_a, "validPolygon"_a, "weight"_a = 1.0);
55 
56  clsCoaddBoundedFieldElement.def_readwrite("field", &CoaddBoundedFieldElement::field);
57  clsCoaddBoundedFieldElement.def_readwrite("wcs", &CoaddBoundedFieldElement::wcs);
58  clsCoaddBoundedFieldElement.def_readwrite("validPolygon", &CoaddBoundedFieldElement::validPolygon);
59  clsCoaddBoundedFieldElement.def_readwrite("weight", &CoaddBoundedFieldElement::weight);
60 
61  afw::table::io::python::declarePersistableFacade<CoaddBoundedField>(mod, "CoaddBoundedField");
62 
63  py::class_<CoaddBoundedField, std::shared_ptr<CoaddBoundedField>,
64  afw::table::io::PersistableFacade<CoaddBoundedField>, afw::math::BoundedField>
65  clsCoaddBoundedField(mod, "CoaddBoundedField");
66 
67  clsCoaddBoundedField.attr("Element") = clsCoaddBoundedFieldElement;
68 
69  /* Constructors */
70  clsCoaddBoundedField.def(py::init<afw::geom::Box2I const &, std::shared_ptr<afw::image::Wcs const>,
71  typename CoaddBoundedField::ElementVector const &>(),
72  "bbox"_a, "coaddWcs"_a, "elements"_a);
73  clsCoaddBoundedField.def(py::init<afw::geom::Box2I const &, std::shared_ptr<afw::image::Wcs const>,
74  typename CoaddBoundedField::ElementVector const &, double>(),
75  "bbox"_a, "coaddWcs"_a, "elements"_a, "default"_a);
76 
77  /* Operators */
78  clsCoaddBoundedField.def("__eq__", &CoaddBoundedField::operator==, py::is_operator());
79  clsCoaddBoundedField.def("__ne__", &CoaddBoundedField::operator!=, py::is_operator());
80  clsCoaddBoundedField.def("__imul__", &CoaddBoundedField::operator*);
81 
82  /* Members */
83  clsCoaddBoundedField.def("evaluate", &CoaddBoundedField::evaluate);
84  clsCoaddBoundedField.def("isPersistable", &CoaddBoundedField::isPersistable);
85 
86  return mod.ptr();
87 }
88 
89 } // algorithms
90 } // meas
91 } // lsst
Struct used to hold one Exposure&#39;s data in a CoaddBoundedField.
tbl::Key< double > weight
tbl::Key< int > wcs
tbl::Key< int > validPolygon
PYBIND11_PLUGIN(binnedWcs)
Definition: binnedWcs.cc:33
tbl::Key< int > field