LSST Applications g04e9c324dd+8c5ae1fdc5,g134cb467dc+b203dec576,g18429d2f64+358861cd2c,g199a45376c+0ba108daf9,g1fd858c14a+dd066899e3,g262e1987ae+ebfced1d55,g29ae962dfc+72fd90588e,g2cef7863aa+aef1011c0b,g35bb328faa+8c5ae1fdc5,g3fd5ace14f+b668f15bc5,g4595892280+3897dae354,g47891489e3+abcf9c3559,g4d44eb3520+fb4ddce128,g53246c7159+8c5ae1fdc5,g67b6fd64d1+abcf9c3559,g67fd3c3899+1f72b5a9f7,g74acd417e5+cb6b47f07b,g786e29fd12+668abc6043,g87389fa792+8856018cbb,g89139ef638+abcf9c3559,g8d7436a09f+bcf525d20c,g8ea07a8fe4+9f5ccc88ac,g90f42f885a+6054cc57f1,g97be763408+06f794da49,g9dd6db0277+1f72b5a9f7,ga681d05dcb+7e36ad54cd,gabf8522325+735880ea63,gac2eed3f23+abcf9c3559,gb89ab40317+abcf9c3559,gbf99507273+8c5ae1fdc5,gd8ff7fe66e+1f72b5a9f7,gdab6d2f7ff+cb6b47f07b,gdc713202bf+1f72b5a9f7,gdfd2d52018+8225f2b331,ge365c994fd+375fc21c71,ge410e46f29+abcf9c3559,geaed405ab2+562b3308c0,gf9a733ac38+8c5ae1fdc5,w.2025.35
LSST Data Management Base Package
Loading...
Searching...
No Matches
_functionLibrary.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#include <memory>
23
24#include <pybind11/pybind11.h>
26
27#include <pybind11/stl.h>
28
29#include "lsst/geom/Box.h"
30#include "lsst/geom/Point.h"
31
34
35namespace py = pybind11;
36using namespace pybind11::literals;
37
38namespace lsst {
39namespace afw {
40namespace math {
41
42template <typename ReturnT>
44 /* PolynomialFunction1 */
45
46 wrappers.wrapType(
48 Function1<ReturnT>>(wrappers.module, ("PolynomialFunction1" + suffix).c_str()),
49 [](auto &mod, auto &cls) {
50 cls.def(py::init<std::vector<double> const &>(), "params"_a);
51 cls.def(py::init<unsigned int>(), "order"_a);
52
53 cls.def("__call__", &PolynomialFunction1<ReturnT>::operator(), "x"_a);
54 cls.def("clone", &PolynomialFunction1<ReturnT>::clone);
55 cls.def("isLinearCombination", &PolynomialFunction1<ReturnT>::isLinearCombination);
56 cls.def("getOrder", &PolynomialFunction1<ReturnT>::getOrder);
57 cls.def("toString", &PolynomialFunction1<ReturnT>::toString, "prefix"_a = "");
58 });
59 /* PolynomialFunction2 */
60 wrappers.wrapType(py::classh<PolynomialFunction2<ReturnT>,
62 ("PolynomialFunction2" + suffix).c_str()),
63 [](auto &mod, auto &cls) {
64 cls.def(py::init<std::vector<double> const &>(), "params"_a);
65 cls.def(py::init<unsigned int>(), "order"_a);
66
67 cls.def("__call__", &PolynomialFunction2<ReturnT>::operator(), "x"_a, "y"_a);
68 cls.def("clone", &PolynomialFunction2<ReturnT>::clone);
69 cls.def("getOrder", &PolynomialFunction2<ReturnT>::getOrder);
70 cls.def("getDFuncDParameters", &PolynomialFunction2<ReturnT>::getDFuncDParameters);
71 cls.def("toString", &PolynomialFunction2<ReturnT>::toString, "prefix"_a = "");
72 cls.def("isPersistable", &PolynomialFunction2<ReturnT>::isPersistable);
73 });
74};
75
76template <typename ReturnT>
78 /* Chebyshev1Function1 */
79
80 wrappers.wrapType(
82 Function1<ReturnT>>(wrappers.module, ("Chebyshev1Function1" + suffix).c_str()),
83 [](auto &mod, auto &cls) {
84 cls.def(py::init<std::vector<double>, double, double>(), "params"_a, "minX"_a = -1,
85 "maxX"_a = 1);
86 cls.def(py::init<unsigned int, double, double>(), "order"_a, "minX"_a = -1, "maxX"_a = 1);
87
88 cls.def("__call__", &Chebyshev1Function1<ReturnT>::operator(), "x"_a);
89 cls.def("clone", &Chebyshev1Function1<ReturnT>::clone);
90 cls.def("getMinX", &Chebyshev1Function1<ReturnT>::getMinX);
91 cls.def("getMaxX", &Chebyshev1Function1<ReturnT>::getMaxX);
92 cls.def("getOrder", &Chebyshev1Function1<ReturnT>::getOrder);
93 cls.def("isLinearCombination", &Chebyshev1Function1<ReturnT>::isLinearCombination);
94 cls.def("toString", &Chebyshev1Function1<ReturnT>::toString, "prefix"_a = "");
95
96 /* Chebyshev1Function2 */
97 });
98 wrappers.wrapType(py::classh<Chebyshev1Function2<ReturnT>,
100 ("Chebyshev1Function2" + suffix).c_str()),
101 [](auto &mod, auto &cls) {
102 cls.def(py::init<std::vector<double>, lsst::geom::Box2D const &>(), "params"_a,
103 "xyRange"_a = lsst::geom::Box2D(lsst::geom::Point2D(-1.0, -1.0),
104 lsst::geom::Point2D(1.0, 1.0)));
105 cls.def(py::init<unsigned int, lsst::geom::Box2D const &>(), "order"_a,
106 "xyRange"_a = lsst::geom::Box2D(lsst::geom::Point2D(-1.0, -1.0),
107 lsst::geom::Point2D(1.0, 1.0)));
108
109 cls.def("__call__", &Chebyshev1Function2<ReturnT>::operator(), "x"_a, "y"_a);
110 cls.def("clone", &Chebyshev1Function2<ReturnT>::clone);
111 cls.def("getXYRange", &Chebyshev1Function2<ReturnT>::getXYRange);
112 cls.def("truncate", &Chebyshev1Function2<ReturnT>::truncate, "order"_a);
113 cls.def("toString", &Chebyshev1Function2<ReturnT>::toString, "prefix"_a = "");
114 cls.def("isPersistable", &Chebyshev1Function2<ReturnT>::isPersistable);
115 });
116};
117
118template <typename ReturnT>
120 /* GaussianFunction1 */
121 wrappers.wrapType(py::classh<GaussianFunction1<ReturnT>,
122 Function1<ReturnT>>(wrappers.module, ("GaussianFunction1" + suffix).c_str()),
123 [](auto &mod, auto &cls) {
124 cls.def(py::init<double>(), "sigma"_a);
125
126 cls.def("__call__", &GaussianFunction1<ReturnT>::operator(), "x"_a);
127 cls.def("clone", &GaussianFunction1<ReturnT>::clone);
128 cls.def("toString", &GaussianFunction1<ReturnT>::toString, "prefix"_a = "");
129 });
130
131 wrappers.wrapType(py::classh<GaussianFunction2<ReturnT>,
132 Function2<ReturnT>>(wrappers.module, ("GaussianFunction2" + suffix).c_str()),
133 [](auto &mod, auto &cls) {
134 /* GaussianFunction2 */
135
136 cls.def(py::init<double, double, double>(), "sigma1"_a, "sigma2"_a,
137 "angle"_a = 0.0);
138
139 cls.def("__call__", &GaussianFunction2<ReturnT>::operator(), "x"_a, "y"_a);
140 cls.def("clone", &GaussianFunction2<ReturnT>::clone);
141 cls.def("toString", &GaussianFunction2<ReturnT>::toString, "prefix"_a = "");
142 cls.def("isPersistable", &GaussianFunction2<ReturnT>::isPersistable);
143 });
144 /* DoubleGaussianFunction2 */
145
146 wrappers.wrapType(
148 Function2<ReturnT>>(wrappers.module, ("DoubleGaussianFunction2" + suffix).c_str()),
149 [](auto &mod, auto &cls) {
150 cls.def(py::init<double, double, double>(), "sigma1"_a, "sigma2"_a = 0, "ampl"_a = 0);
151
152 cls.def("__call__", &DoubleGaussianFunction2<ReturnT>::operator(), "x"_a, "y"_a);
153 cls.def("clone", &DoubleGaussianFunction2<ReturnT>::clone);
154 cls.def("toString", &DoubleGaussianFunction2<ReturnT>::toString, "prefix"_a = "");
155 cls.def("isPersistable", &DoubleGaussianFunction2<ReturnT>::isPersistable);
156 });
157};
158
159template <typename ReturnT>
161 const std::string &suffix) {
162 /* IntegerDeltaFunction1 */
163
164 wrappers.wrapType(
166 Function1<ReturnT>>(wrappers.module, ("IntegerDeltaFunction1" + suffix).c_str()),
167 [](auto &mod, auto &cls) {
168 cls.def(py::init<double>(), "xo"_a);
169
170 cls.def("__call__", &IntegerDeltaFunction1<ReturnT>::operator(), "x"_a);
171 cls.def("clone", &IntegerDeltaFunction1<ReturnT>::clone);
172 cls.def("toString", &IntegerDeltaFunction1<ReturnT>::toString, "prefix"_a = "");
173 });
174 /* IntegerDeltaFunction2 */
175
176 wrappers.wrapType(
178 Function2<ReturnT>>(wrappers.module, ("IntegerDeltaFunction2" + suffix).c_str()),
179 [](auto &mod, auto &cls) {
180 cls.def(py::init<double, double>(), "xo"_a, "yo"_a);
181
182 cls.def("__call__", &IntegerDeltaFunction2<ReturnT>::operator(), "x"_a, "y"_a);
183 cls.def("clone", &IntegerDeltaFunction2<ReturnT>::clone);
184 cls.def("toString", &IntegerDeltaFunction2<ReturnT>::toString, "prefix"_a = "");
185 });
186};
187
188template <typename ReturnT>
190 /* LanczosFunction1 */
191
192 wrappers.wrapType(py::classh<LanczosFunction1<ReturnT>,
193 Function1<ReturnT>>(wrappers.module, ("LanczosFunction1" + suffix).c_str()),
194 [](auto &mod, auto &cls) {
195 cls.def(py::init<unsigned int, double>(), "n"_a, "xOffset"_a = 0.0);
196
197 cls.def("__call__", &LanczosFunction1<ReturnT>::operator(), "x"_a);
198 cls.def("clone", &LanczosFunction1<ReturnT>::clone);
199 cls.def("getOrder", &LanczosFunction1<ReturnT>::getOrder);
200 cls.def("toString", &LanczosFunction1<ReturnT>::toString, "prefix"_a = "");
201 });
202 /* LanczosFunction2 */
203
204 wrappers.wrapType(py::classh<LanczosFunction2<ReturnT>,
205 Function2<ReturnT>>(wrappers.module, ("LanczosFunction2" + suffix).c_str()),
206 [](auto &mod, auto &cls) {
207 /* LanczosFunction2 */
208 cls.def(py::init<unsigned int, double, double>(), "n"_a, "xOffset"_a = 0.0,
209 "yOffset"_a = 0.0);
210
211 cls.def("__call__", &LanczosFunction2<ReturnT>::operator(), "x"_a, "y"_a);
212 cls.def("clone", &LanczosFunction2<ReturnT>::clone);
213 cls.def("getOrder", &LanczosFunction2<ReturnT>::getOrder);
214 cls.def("toString", &LanczosFunction2<ReturnT>::toString, "prefix"_a = "");
215 });
216};
217
232
233} // namespace math
234} // namespace afw
235} // namespace lsst
Base class for 2-dimensional polynomials of the form:
Definition Function.h:326
1-dimensional weighted sum of Chebyshev polynomials of the first kind.
2-dimensional weighted sum of Chebyshev polynomials of the first kind.
double Guassian (sum of two Gaussians)
A Function taking one argument.
Definition Function.h:202
A Function taking two arguments.
Definition Function.h:259
1-dimensional integer delta function.
2-dimensional integer delta function.
1-dimensional Lanczos function
2-dimensional separable Lanczos function
1-dimensional polynomial function.
2-dimensional polynomial function with cross terms
A helper class for subdividing pybind11 module across multiple translation units (i....
Definition python.h:242
void addInheritanceDependency(std::string const &name)
Indicate an external module that provides a base class for a subsequent addType call.
Definition python.h:343
PyType wrapType(PyType cls, ClassWrapperCallback function, bool setModuleName=true)
Add a type (class or enum) wrapper, deferring method and other attribute definitions until finish() i...
Definition python.h:391
pybind11::module module
The module object passed to the PYBIND11_MODULE block that contains this WrapperCollection.
Definition python.h:448
void declareChebyshevFunctions(lsst::cpputils::python::WrapperCollection &wrappers, const std::string &suffix)
void declareGaussianFunctions(lsst::cpputils::python::WrapperCollection &wrappers, const std::string &suffix)
void declareLanczosFunctions(lsst::cpputils::python::WrapperCollection &wrappers, const std::string &suffix)
void declareIntegerDeltaFunctions(lsst::cpputils::python::WrapperCollection &wrappers, const std::string &suffix)
void declarePolynomialFunctions(lsst::cpputils::python::WrapperCollection &wrappers, const std::string &suffix)
void wrapFunctionLibrary(lsst::cpputils::python::WrapperCollection &wrappers)