LSSTApplications  15.0+21,16.0+1,16.0+3,16.0+4,16.0+8,16.0-1-g2115a9e+2,16.0-1-g4515a79+6,16.0-1-g5c6f5ee+4,16.0-1-g7bb14cc,16.0-1-g80120d7+4,16.0-1-g98efed3+4,16.0-1-gb7f560d+1,16.0-14-gb4f0cd2fa,16.0-2-g1ad129e+1,16.0-2-g2ed7261+1,16.0-2-g311bfd2,16.0-2-g568a347+3,16.0-2-g852da13+6,16.0-2-gd4c87cb+3,16.0-3-g099ede0,16.0-3-g150e024+3,16.0-3-g1f513a6,16.0-3-g958ce35,16.0-4-g08dccf71+4,16.0-4-g128aaef,16.0-4-g84f75fb+5,16.0-4-gcfd1396+4,16.0-4-gde8cee2,16.0-4-gdfb0d14+1,16.0-5-g7bc0afb+3,16.0-5-g86fb31a+3,16.0-6-g2dd73041+4,16.0-7-g95fb7bf,16.0-7-gc37dbc2+4,w.2018.28
LSSTDataManagementBasePackage
peak.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 
25 #include <memory>
26 #include <sstream>
27 
28 //#include <pybind11/stl.h>
29 
30 #include "lsst/utils/python.h"
31 
37 
38 namespace py = pybind11;
39 using namespace py::literals;
40 
41 namespace lsst {
42 namespace afw {
43 namespace detection {
44 
45 namespace {
46 
47 using PyPeakRecord = py::class_<PeakRecord, std::shared_ptr<PeakRecord>, table::BaseRecord>;
48 using PyPeakTable = py::class_<PeakTable, std::shared_ptr<PeakTable>, table::BaseTable>;
49 
53 void declarePeakRecord(PyPeakRecord &cls) {
54  cls.def("getTable", &PeakRecord::getTable);
55  cls.def_property_readonly("table", &PeakRecord::getTable);
56  cls.def("getId", &PeakRecord::getId);
57  cls.def("setId", &PeakRecord::setId);
58  cls.def("getIx", &PeakRecord::getIx);
59  cls.def("getIy", &PeakRecord::getIy);
60  cls.def("setIx", &PeakRecord::setIx);
61  cls.def("setIy", &PeakRecord::setIy);
62  cls.def("getI", &PeakRecord::getI);
63  cls.def("getCentroid", (lsst::geom::Point2I (PeakRecord::*)(bool) const) & PeakRecord::getCentroid);
64  cls.def("getCentroid", (lsst::geom::Point2D (PeakRecord::*)() const) & PeakRecord::getCentroid);
65  cls.def("getFx", &PeakRecord::getFx);
66  cls.def("getFy", &PeakRecord::getFy);
67  cls.def("setFx", &PeakRecord::setFx);
68  cls.def("setFy", &PeakRecord::setFy);
69  cls.def("getF", &PeakRecord::getF);
70  cls.def("getPeakValue", &PeakRecord::getPeakValue);
71  cls.def("setPeakValue", &PeakRecord::setPeakValue);
72  utils::python::addOutputOp(cls, "__str__");
73  utils::python::addOutputOp(cls, "__repr__");
74 }
75 
79 void declarePeakTable(PyPeakTable &cls) {
80  cls.def_static("make", &PeakTable::make, "schema"_a, "forceNew"_a = false);
81  cls.def_static("makeMinimalSchema", &PeakTable::makeMinimalSchema);
82  cls.def_static("checkSchema", &PeakTable::checkSchema, "schema"_a);
83  cls.def("getIdFactory", (std::shared_ptr<table::IdFactory> (PeakTable::*)()) & PeakTable::getIdFactory);
84  cls.def("setIdFactory", &PeakTable::setIdFactory, "factory"_a);
85  cls.def_static("getIdKey", &PeakTable::getIdKey);
86  cls.def_static("getIxKey", &PeakTable::getIxKey);
87  cls.def_static("getIyKey", &PeakTable::getIyKey);
88  cls.def_static("getFxKey", &PeakTable::getFxKey);
89  cls.def_static("getFyKey", &PeakTable::getFyKey);
90  cls.def_static("getPeakValueKey", &PeakTable::getPeakValueKey);
91  cls.def("clone", &PeakTable::clone);
92  cls.def("makeRecord", &PeakTable::makeRecord);
93  cls.def("copyRecord", (std::shared_ptr<PeakRecord> (PeakTable::*)(afw::table::BaseRecord const &)) &
94  PeakTable::copyRecord);
95  cls.def("copyRecord", (std::shared_ptr<PeakRecord> (PeakTable::*)(afw::table::BaseRecord const &,
96  afw::table::SchemaMapper const &)) &
97  PeakTable::copyRecord);
98 }
99 
100 } // lsst::afw::detection::<anonymous>
101 
103  py::module mod("_peak", "Python wrapper for afw _peak library");
104 
105  /* Module level */
106  PyPeakRecord clsPeakRecord(mod, "PeakRecord");
107  PyPeakTable clsPeakTable(mod, "PeakTable");
108 
109  /* Members */
110  declarePeakRecord(clsPeakRecord);
111  declarePeakTable(clsPeakTable);
112  auto clsPeakColumnView = table::python::declareColumnView<PeakRecord>(mod, "Peak");
113  auto clsPeakCatalog = table::python::declareCatalog<PeakRecord>(mod, "Peak");
114 
115  clsPeakRecord.attr("Table") = clsPeakTable;
116  clsPeakRecord.attr("ColumnView") = clsPeakColumnView;
117  clsPeakRecord.attr("Catalog") = clsPeakCatalog;
118  clsPeakTable.attr("Record") = clsPeakRecord;
119  clsPeakTable.attr("ColumnView") = clsPeakColumnView;
120  clsPeakTable.attr("Catalog") = clsPeakCatalog;
121  clsPeakCatalog.attr("Record") = clsPeakRecord;
122  clsPeakCatalog.attr("Table") = clsPeakTable;
123  clsPeakCatalog.attr("ColumnView") = clsPeakColumnView;
124 
125  return mod.ptr();
126 }
127 }
128 }
129 } // lsst::afw::detection
void addOutputOp(PyClass &cls, std::string const &method)
Add __str__ or __repr__ method implemented by operator<<.
Definition: python.h:82
A base class for image defects.
Definition: cameraGeom.dox:3
PYBIND11_PLUGIN(_peak)
Definition: peak.cc:102