-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
186 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,8 +8,6 @@ config.log | |
*.so | ||
*.cfgc | ||
*.pyc | ||
*_wrap.cc | ||
*Lib.py | ||
doc/html | ||
doc/*.tag | ||
doc/*.inc | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
# -*- python -*- | ||
## -*- python -*- | ||
from lsst.sconsUtils import scripts | ||
scripts.BasicSConscript.python(['isrLib']) | ||
scripts.BasicSConscript.pybind11(["applyLookupTable", "isr"], addUnderscore=False) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* LSST Data Management System | ||
* | ||
* This product includes software developed by the | ||
* LSST Project (http://www.lsst.org/). | ||
* See the COPYRIGHT file | ||
* | ||
* 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 LSST License Statement and | ||
* the GNU General Public License along with this program. If not, | ||
* see <https://www.lsstcorp.org/LegalNotices/>. | ||
*/ | ||
#include "pybind11/pybind11.h" | ||
#include "pybind11/stl.h" | ||
#include "numpy/arrayobject.h" | ||
#include "ndarray/pybind11.h" | ||
|
||
#include "lsst/ip/isr/applyLookupTable.h" | ||
|
||
namespace py = pybind11; | ||
using namespace pybind11::literals; | ||
|
||
namespace lsst { | ||
namespace ip { | ||
namespace isr { | ||
|
||
namespace { | ||
|
||
template <typename PixelT> | ||
static void declareApplyLookupTable(py::module& mod) { | ||
mod.def("applyLookupTable", &applyLookupTable<PixelT>, "image"_a, "table"_a, "indOffset"_a); | ||
} | ||
|
||
} // namespace lsst::ip::isr::<anonymous> | ||
|
||
PYBIND11_PLUGIN(applyLookupTable) { | ||
py::module mod("applyLookupTable"); | ||
|
||
// Need to import numpy for ndarray and eigen conversions | ||
if (_import_array() < 0) { | ||
PyErr_SetString(PyExc_ImportError, "numpy.core.multiarray failed to import"); | ||
return nullptr; | ||
} | ||
|
||
declareApplyLookupTable<float>(mod); | ||
declareApplyLookupTable<double>(mod); | ||
|
||
return mod.ptr(); | ||
} | ||
} | ||
} | ||
} // lsst::ip::isr |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/* | ||
* LSST Data Management System | ||
* | ||
* This product includes software developed by the | ||
* LSST Project (http://www.lsst.org/). | ||
* See the COPYRIGHT file | ||
* | ||
* 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 LSST License Statement and | ||
* the GNU General Public License along with this program. If not, | ||
* see <https://www.lsstcorp.org/LegalNotices/>. | ||
*/ | ||
#include <memory> | ||
|
||
#include "pybind11/pybind11.h" | ||
|
||
#include "lsst/ip/isr/isr.h" | ||
|
||
namespace py = pybind11; | ||
using namespace pybind11::literals; | ||
|
||
namespace lsst { | ||
namespace ip { | ||
namespace isr { | ||
|
||
namespace { | ||
|
||
template <typename PixelT> | ||
static void declareCountMaskedPixels(py::module& mod, std::string const& suffix) { | ||
py::class_<CountMaskedPixels<PixelT>, std::shared_ptr<CountMaskedPixels<PixelT>>> cls( | ||
mod, ("CountMaskedPixels" + suffix).c_str()); | ||
|
||
cls.def("reset", &CountMaskedPixels<PixelT>::reset); | ||
cls.def("apply", &CountMaskedPixels<PixelT>::apply, "image"_a, "bitmask"_a); | ||
cls.def("getCount", &CountMaskedPixels<PixelT>::getCount); | ||
} | ||
|
||
/** | ||
* Wrap all code in Isr.h for a given template parameter | ||
* | ||
* @tparam PixelT Pixel type; typically `float` or `double` (potentially could also be | ||
* and integer class, but so far we have not needed those) | ||
* @param mod pybind11 module to which to add the wrappers. | ||
* @param[in] suffix Class name suffix associated with `PixelT`, e.g. "F" for `float` and "D" for `double` | ||
* | ||
* Note that the second (function type) template parameter of `fitOverscanImage` is always `double`. | ||
*/ | ||
template <typename PixelT> | ||
static void declareAll(py::module& mod, std::string const& suffix) { | ||
declareCountMaskedPixels<PixelT>(mod, suffix); | ||
|
||
mod.def("maskNans", &maskNans<PixelT>, "maskedImage"_a, "maskVal"_a, "allow"_a = 0); | ||
mod.def("fitOverscanImage", &fitOverscanImage<PixelT, double>, "overscanFunction"_a, "overscan"_a, | ||
"stepSize"_a = 1.1, "sigma"_a = 1); | ||
} | ||
|
||
} // namespace lsst::ip::isr::<anonymous> | ||
|
||
PYBIND11_PLUGIN(isr) { | ||
py::module mod("isr"); | ||
|
||
declareAll<float>(mod, "F"); | ||
declareAll<double>(mod, "D"); | ||
|
||
return mod.ptr(); | ||
} | ||
} | ||
} | ||
} // lsst::ip::isr |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.