lsst.ip.diffim  13.0-22-g3839dbb+8
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
basisLists.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 <Eigen/Core>
26 
27 #include "numpy/arrayobject.h"
28 #include "ndarray/pybind11.h"
29 
31 
32 namespace py = pybind11;
33 using namespace pybind11::literals;
34 
35 namespace lsst {
36 namespace ip {
37 namespace diffim {
38 
39 PYBIND11_PLUGIN(basisLists) {
40  py::module::import("lsst.afw.math");
41  py::module::import("lsst.pex.policy");
42 
43  py::module mod("basisLists");
44 
45  // Need to import numpy for ndarray and eigen conversions
46  if (_import_array() < 0) {
47  PyErr_SetString(PyExc_ImportError, "numpy.core.multiarray failed to import");
48  return nullptr;
49  }
50 
51  mod.def("makeDeltaFunctionBasisList", &makeDeltaFunctionBasisList, "width"_a, "height"_a);
52  mod.def("makeRegularizationMatrix", &makeRegularizationMatrix, "policy"_a);
53  mod.def("makeForwardDifferenceMatrix", &makeForwardDifferenceMatrix, "width"_a, "height"_a, "orders"_a,
54  "borderPenalty"_a, "fitForBackground"_a);
55  mod.def("makeCentralDifferenceMatrix", &makeCentralDifferenceMatrix, "width"_a, "height"_a, "stencil"_a,
56  "borderPenalty"_a, "fitForBackground"_a);
57  mod.def("renormalizeKernelList", &renormalizeKernelList, "kernelListIn"_a);
58  mod.def("makeAlardLuptonBasisList", &makeAlardLuptonBasisList, "halfWidth"_a, "nGauss"_a, "sigGauss"_a,
59  "degGauss"_a);
60 
61  return mod.ptr();
62 }
63 
64 } // diffim
65 } // ip
66 } // lsst
lsst::afw::math::KernelList renormalizeKernelList(lsst::afw::math::KernelList const &kernelListIn)
Renormalize a list of basis kernels.
Definition: BasisLists.cc:414
Eigen::MatrixXd makeForwardDifferenceMatrix(int width, int height, std::vector< int > const &orders, float borderPenalty, bool fitForBackground)
Build a forward difference regularization matrix for Delta function kernels.
Definition: BasisLists.cc:311
Eigen::MatrixXd makeRegularizationMatrix(lsst::pex::policy::Policy policy)
Build a regularization matrix for Delta function kernels.
Definition: BasisLists.cc:149
Eigen::MatrixXd makeCentralDifferenceMatrix(int width, int height, int stencil, float borderPenalty, bool fitForBackground)
Build a central difference Laplacian regularization matrix for Delta function kernels.
Definition: BasisLists.cc:209
lsst::afw::math::KernelList makeDeltaFunctionBasisList(int width, int height)
Build a set of Delta Function basis kernels.
Definition: BasisLists.cc:47
Subroutines associated with generating, normalising, and regularising Basis functions.
PYBIND11_PLUGIN(basisLists)
Definition: basisLists.cc:39
lsst::afw::math::KernelList makeAlardLuptonBasisList(int halfWidth, int nGauss, std::vector< double > const &sigGauss, std::vector< int > const &degGauss)
Build a set of Alard/Lupton basis kernels.
Definition: BasisLists.cc:78