-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from lsst/tickets/DM-9887
DM-9887: Wrap meas_mosaic with pybind11 instead of swig
- Loading branch information
Showing
20 changed files
with
731 additions
and
251 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
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,8 @@ | ||
# -*- python -*- | ||
from lsst.sconsUtils import scripts | ||
scripts.BasicSConscript.python(['mosaicLib']) | ||
scripts.BasicSConscript.pybind11(['fluxfit', | ||
'matches', | ||
'mosaicfit/mosaicfit', | ||
'shimCameraGeom', | ||
'snapshot', | ||
'spatialCellSource'], 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,30 @@ | ||
import lsst.afw # this is necessary for avoiding segmentation falut. | ||
from mosaicLib import * | ||
from updateExposure import * | ||
# | ||
# 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/>. | ||
#/ | ||
|
||
from __future__ import absolute_import | ||
|
||
from .fluxfit import * | ||
from .matches import * | ||
from .mosaicfit import * | ||
from .shimCameraGeom import * | ||
from .snapshot import * | ||
from .spatialCellSource import * |
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,85 @@ | ||
/* | ||
* LSST Data Management System | ||
* Copyright 2008-2017 AURA/LSST. | ||
* | ||
* This product includes software developed by the | ||
* LSST Project (http: | ||
* | ||
* 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: | ||
*/ | ||
#include "pybind11/pybind11.h" | ||
#include "pybind11/stl.h" | ||
|
||
#include "lsst/meas/mosaic/fluxfit.h" | ||
|
||
namespace py = pybind11; | ||
using namespace pybind11::literals; | ||
|
||
namespace lsst { | ||
namespace meas { | ||
namespace mosaic { | ||
|
||
PYBIND11_PLUGIN(fluxfit) { | ||
py::module::import("lsst.afw.cameraGeom"); | ||
py::module::import("lsst.afw.image"); | ||
py::module::import("lsst.daf.base"); | ||
|
||
py::module mod("fluxfit"); | ||
|
||
py::class_<FluxFitParams, std::shared_ptr<FluxFitParams>> clsFluxFitParams(mod, "FluxFitParams"); | ||
|
||
clsFluxFitParams.def_readwrite("order", &FluxFitParams::order); | ||
clsFluxFitParams.def_readwrite("chebyshev", &FluxFitParams::chebyshev); | ||
clsFluxFitParams.def_readwrite("ncoeff", &FluxFitParams::ncoeff); | ||
clsFluxFitParams.def_readwrite("absolute", &FluxFitParams::absolute); | ||
clsFluxFitParams.def_readwrite("u_max", &FluxFitParams::u_max); | ||
clsFluxFitParams.def_readwrite("v_max", &FluxFitParams::v_max); | ||
clsFluxFitParams.def_readwrite("x0", &FluxFitParams::x0); | ||
clsFluxFitParams.def_readwrite("y0", &FluxFitParams::y0); | ||
|
||
clsFluxFitParams.def(py::init<int, bool, bool>(), "order"_a, "absolute"_a = false, "chebyshev"_a = false); | ||
clsFluxFitParams.def(py::init<lsst::daf::base::PropertySet::Ptr&>(), "metadata"_a); | ||
clsFluxFitParams.def(py::init<const FluxFitParams&>(), "p"_a); | ||
|
||
clsFluxFitParams.def("eval", (double (FluxFitParams::*)(double, double) const) & FluxFitParams::eval, | ||
"u"_a, "v"_a); | ||
clsFluxFitParams.def("getXorder", &FluxFitParams::getXorder); | ||
clsFluxFitParams.def("getYorder", &FluxFitParams::getYorder); | ||
clsFluxFitParams.def("getCoeff", &FluxFitParams::getCoeff); | ||
clsFluxFitParams.def("getIndex", &FluxFitParams::getIndex); | ||
|
||
// Workaround because fluxFit uses in/out arguments of STL container types | ||
mod.def("fluxFit", [](bool absolute, bool common, ObsVec matchVec, int nmatch, ObsVec sourceVec, | ||
int nsource, WcsDic wcsDic, CcdSet ccdSet, std::map<int, float> fexp, | ||
std::map<int, float> fchip, FfpSet ffpSet, bool solveCcd) { | ||
fluxFit(absolute, common, matchVec, nmatch, sourceVec, nsource, wcsDic, ccdSet, fexp, fchip, ffpSet, | ||
solveCcd); | ||
|
||
return std::make_tuple(matchVec, sourceVec, wcsDic, ccdSet, fexp, fchip, ffpSet); | ||
}); | ||
mod.def("convertFluxFitParams", convertFluxFitParams, "ffp"_a, "ccd"_a, "x0"_a = 0.0, "y0"_a = 0.0); | ||
mod.def("metadataFromFluxFitParams", metadataFromFluxFitParams); | ||
mod.def("getFCorImg", | ||
(lsst::afw::image::Image<float>::Ptr(*)( | ||
FluxFitParams::Ptr&, PTR(lsst::afw::cameraGeom::Detector)&, Coeff::Ptr&))getFCorImg); | ||
mod.def("getFCorImg", (lsst::afw::image::Image<float>::Ptr(*)(FluxFitParams::Ptr&, int, int))getFCorImg); | ||
mod.def("getFCorImg", (lsst::afw::image::Image<float>::Ptr(*)( | ||
FluxFitParams::Ptr&, PTR(lsst::afw::cameraGeom::Detector)&))getFCorImg); | ||
|
||
return mod.ptr(); | ||
} | ||
} | ||
} | ||
} |
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,53 @@ | ||
/* | ||
* LSST Data Management System | ||
* Copyright 2008-2017 AURA/LSST. | ||
* | ||
* This product includes software developed by the | ||
* LSST Project (http://www.lsst.org/). | ||
* | ||
* 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 "lsst/meas/mosaic/matches.h" | ||
|
||
namespace py = pybind11; | ||
using namespace pybind11::literals; | ||
|
||
namespace lsst { | ||
namespace meas { | ||
namespace mosaic { | ||
namespace { | ||
|
||
template <typename CatT> | ||
void declareCopyCatalog(py::module& mod) { | ||
mod.def("copyCatalog", copyCatalog<CatT>, "catalog"_a, "target"_a, "targetPrefix"_a = "", | ||
"sourcePrefix"_a = ""); | ||
} | ||
|
||
} // <anonymous> | ||
|
||
PYBIND11_PLUGIN(matches) { | ||
py::module mod("matches"); | ||
|
||
mod.def("copySchema", copySchema, "schema"_a, "target"_a, "targetPrefix"_a = "", "sourcePrefix"_a = ""); | ||
mod.def("matchesFromCatalog", matchesFromCatalog, "catalog"_a); | ||
|
||
return mod.ptr(); | ||
} | ||
|
||
} // mosaic | ||
} // meas | ||
} // lsst |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.