lsst.meas.extensions.psfex  14.0
 All Classes Namespaces Files Functions Variables Friends Macros Groups
psf.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 "numpy/arrayobject.h"
26 #include "ndarray/pybind11.h"
27 
28 #include "lsst/meas/extensions/psfex/psf.hh"
29 
30 namespace py = pybind11;
31 using namespace pybind11::literals;
32 
33 namespace lsst {
34 namespace meas {
35 namespace extensions {
36 namespace psfex {
37 
39  py::module mod("psf");
40 
41  if (_import_array() < 0) {
42  PyErr_SetString(PyExc_ImportError, "numpy.core.multiarray failed to import");
43  return nullptr;
44  };
45 
46  py::class_<Context> clsContext(mod, "Context");
47 
48  clsContext.attr("KEEPHIDDEN") = py::cast(static_cast<int>(Context::KEEPHIDDEN));
49  clsContext.attr("REMOVEHIDDEN") = py::cast(static_cast<int>(Context::REMOVEHIDDEN));
50 
51  clsContext.def(py::init<std::vector<std::string> const&, std::vector<int> const&, std::vector<int> const&, bool>(),
52  "names"_a, "group"_a, "degree"_a, "pcexflag"_a);
53 
54  clsContext.def("getName", &Context::getName);
55  clsContext.def("getNpc", &Context::getNpc);
56  clsContext.def("getPcflag", &Context::getPcflag);
57  clsContext.def("getPc", &Context::getPc);
58 
59  py::class_<Sample> clsSample(mod, "Sample");
60 
61  clsSample.def("getCatindex", &Sample::getCatindex);
62  clsSample.def("setCatindex", &Sample::setCatindex);
63  clsSample.def("getObjindex", &Sample::getObjindex);
64  clsSample.def("setObjindex", &Sample::setObjindex);
65  clsSample.def("getExtindex", &Sample::getExtindex);
66  clsSample.def("setExtindex", &Sample::setExtindex);
67  clsSample.def("setVig", &Sample::setVig);
68  clsSample.def("setNorm", &Sample::setNorm);
69  clsSample.def("setBacknoise2", &Sample::setBacknoise2);
70  clsSample.def("setGain", &Sample::setGain);
71  clsSample.def("setX", &Sample::setX);
72  clsSample.def("setY", &Sample::setY);
73  clsSample.def("setContext", &Sample::setContext);
74  clsSample.def("setFluxrad", &Sample::setFluxrad);
75  clsSample.def("getVig", &Sample::getVig);
76  clsSample.def("getVigResi", &Sample::getVigResi);
77  clsSample.def("getVigChi", &Sample::getVigChi);
78  clsSample.def("getVigWeight", &Sample::getVigWeight);
79  clsSample.def("getXY", &Sample::getXY);
80  clsSample.def("getNorm", &Sample::getNorm);
81 
82  py::class_<Set, std::shared_ptr<Set>> clsSet(mod, "Set");
83 
84  clsSet.def(py::init<Context &>());
85 
86  clsSet.def("newSample", &Set::newSample);
87  clsSet.def("trimMemory", &Set::trimMemory);
88  clsSet.def("getFwhm", &Set::getFwhm);
89  clsSet.def("setFwhm", &Set::setFwhm);
90  clsSet.def("getNcontext", &Set::getNcontext);
91  clsSet.def("getNsample", &Set::getNsample);
92  clsSet.def("getContextOffset", &Set::getContextOffset);
93  clsSet.def("setContextOffset", &Set::setContextOffset);
94  clsSet.def("getContextScale", &Set::getContextScale);
95  clsSet.def("setContextScale", &Set::setContextScale);
96  clsSet.def("getRecentroid", &Set::getRecentroid);
97  clsSet.def("setRecentroid", &Set::setRecentroid);
98  clsSet.def("setVigSize", &Set::setVigSize);
99  clsSet.def("finiSample", &Set::finiSample);
100  clsSet.def("empty", &Set::empty);
101  clsSet.def("getContextNames", &Set::getContextNames);
102  clsSet.def("setContextname", &Set::setContextname);
103  clsSet.def("setBadFlags", &Set::setBadFlags);
104  clsSet.def("getBadFlags", &Set::getBadFlags);
105  clsSet.def("setBadSN", &Set::setBadSN);
106  clsSet.def("getBadSN", &Set::getBadSN);
107  clsSet.def("setBadFrmin", &Set::setBadFrmin);
108  clsSet.def("getBadFrmin", &Set::getBadFrmin);
109  clsSet.def("setBadFrmax", &Set::setBadFrmax);
110  clsSet.def("getBadFrmax", &Set::getBadFrmax);
111  clsSet.def("setBadElong", &Set::setBadElong);
112  clsSet.def("getBadElong", &Set::getBadElong);
113  clsSet.def("setBadPix", &Set::setBadPix);
114  clsSet.def("getBadPix", &Set::getBadPix);
115  clsSet.def("getSample", &Set::getSample);
116 
117  py::class_<Psf> clsPsf(mod, "Psf");
118 
119  clsPsf.def(py::init<>());
120 
121  clsPsf.def("getLoc", &Psf::getLoc);
122  clsPsf.def("getResi", &Psf::getResi);
123  clsPsf.def("build", &Psf::build,
124  "x"_a, "y"_a, "other"_a=std::vector<double>());
125  clsPsf.def("clip", &Psf::clip);
126 
127  return mod.ptr();
128 }
129 
130 } // psfex
131 } // extensions
132 } // meas
133 } // lsst