Skip to content

Commit

Permalink
Wrap in Python
Browse files Browse the repository at this point in the history
  • Loading branch information
arunkannawadi committed Jan 23, 2024
1 parent 534ae87 commit 9bd0abd
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 0 deletions.
1 change: 1 addition & 0 deletions python/lsst/meas/algorithms/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ from lsst.sconsUtils import scripts

scripts.BasicSConscript.python(['_algorithmsLib'], [
'_algorithmsLib.cc',
'cloughTocher2DInterpolatorUtils.cc',
'cr.cc',
'coaddBoundedField.cc',
'coaddPsf/coaddPsf.cc',
Expand Down
2 changes: 2 additions & 0 deletions python/lsst/meas/algorithms/_algorithmsLib.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ void wrapSpatialModelPsf(WrapperCollection &wrappers);
void wrapCoaddPsf(WrapperCollection &wrappers);
void wrapCoaddBoundedField(WrapperCollection &wrappers);
void wrapCr(WrapperCollection &wrappers);
void wrapCloughTocher2DInterpolatorUtils(WrapperCollection &wrappers);

PYBIND11_MODULE(_algorithmsLib, mod) {
WrapperCollection wrappers(mod, "lsst.meas.algorithms");
Expand All @@ -65,6 +66,7 @@ WrapperCollection wrappers(mod, "lsst.meas.algorithms");
wrapCoaddPsf(wrappers);
wrapCoaddBoundedField(wrappers);
wrapCr(wrappers);
wrapCloughTocher2DInterpolatorUtils(wrappers);
wrappers.finish();
}

Expand Down
64 changes: 64 additions & 0 deletions python/lsst/meas/algorithms/cloughTocher2DInterpolatorUtils.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
// -*- LSST-C++ -*-
/*
* This file is part of meas_algorithms.
*
* Developed for the LSST Data Management System.
* This product includes software developed by the LSST Project
* (https://www.lsst.org).
* See the COPYRIGHT file at the top-level directory of this distribution
* for details of code ownership.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include "pybind11/pybind11.h"
#include "ndarray/pybind11.h"
#include "lsst/cpputils/python.h"
#include "pybind11/stl.h"

#include "lsst/geom/Box.h"
#include "lsst/meas/algorithms/CloughTocher2DInterpolatorUtils.h"

namespace py = pybind11;
using namespace pybind11::literals;

namespace lsst {
namespace meas {
namespace algorithms {
namespace {

void declareCloughTocher2DInterpolatorUtils(lsst::cpputils::python::WrapperCollection &wrappers) {
using PyCloughTocher2DInterpolatorUtils =
py::class_<CloughTocher2DInterpolatorUtils, std::shared_ptr<CloughTocher2DInterpolatorUtils>>;
auto clsCloughTocher2DInterpolatorUtils = wrappers.wrapType(
PyCloughTocher2DInterpolatorUtils(wrappers.module, "CloughTocher2DInterpolatorUtils"),
[](auto &mod, auto &cls) {
// cls.def(py::init<>()); // can we get away without it?
cls.def_static("findGoodPixelsAroundBadPixels",
&CloughTocher2DInterpolatorUtils::findGoodPixelsAroundBadPixels, "mimage"_a,
"badList"_a, "buffer"_a);
cls.def_static("updateArrayFromImage", &CloughTocher2DInterpolatorUtils::updateArrayFromImage,
"array"_a, "image"_a);
cls.def_static("updateImageFromArray", &CloughTocher2DInterpolatorUtils::updateImageFromArray,
"image"_a, "array"_a);
});
}
} // namespace

void wrapCloughTocher2DInterpolatorUtils(lsst::cpputils::python::WrapperCollection &wrappers) {
declareCloughTocher2DInterpolatorUtils(wrappers);
}

} // namespace algorithms
} // namespace meas
} // namespace lsst

0 comments on commit 9bd0abd

Please sign in to comment.