lsst.meas.modelfit  13.0-10-g4e34388+12
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Pages
unitTransformedLikelihood.cc
Go to the documentation of this file.
1 // -*- lsst-c++ -*-
2 /*
3  * LSST Data Management System
4  * Copyright 2008-2013 LSST Corporation.
5  *
6  * This product includes software developed by the
7  * LSST Project (http://www.lsst.org/).
8  *
9  * This program is free software: you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation, either version 3 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the LSST License Statement and
20  * the GNU General Public License along with this program. If not,
21  * see <http://www.lsstcorp.org/LegalNotices/>.
22  */
23 
24 #include "pybind11/pybind11.h"
25 #include "pybind11/stl.h"
26 
27 #include "numpy/arrayobject.h"
28 #include "ndarray/pybind11.h"
29 
30 #include "lsst/pex/config/python.h"
32 
33 namespace py = pybind11;
34 using namespace pybind11::literals;
35 
36 namespace lsst {
37 namespace meas {
38 namespace modelfit {
39 namespace {
40 
41 using PyUnitTransformedLikelihoodControl =
42  py::class_<UnitTransformedLikelihoodControl, std::shared_ptr<UnitTransformedLikelihoodControl>>;
43 
44 using PyEpochFootprint = py::class_<EpochFootprint, std::shared_ptr<EpochFootprint>>;
45 
46 using PyUnitTransformedLikelihood =
47  py::class_<UnitTransformedLikelihood, std::shared_ptr<UnitTransformedLikelihood>, Likelihood>;
48 
49 PYBIND11_PLUGIN(unitTransformedLikelihood) {
50  py::module::import("lsst.afw.geom.ellipses");
51  py::module::import("lsst.afw.detection");
52  py::module::import("lsst.afw.image");
53  py::module::import("lsst.meas.modelfit.model");
54  py::module::import("lsst.meas.modelfit.likelihood");
55  py::module::import("lsst.meas.modelfit.unitSystem");
56 
57  py::module mod("unitTransformedLikelihood");
58 
59  if (_import_array() < 0) {
60  PyErr_SetString(PyExc_ImportError, "numpy.core.multiarray failed to import");
61  return nullptr;
62  }
63 
64  PyUnitTransformedLikelihoodControl clsControl(mod, "UnitTransformedLikelihoodControl");
65  LSST_DECLARE_CONTROL_FIELD(clsControl, UnitTransformedLikelihoodControl, usePixelWeights);
66  LSST_DECLARE_CONTROL_FIELD(clsControl, UnitTransformedLikelihoodControl, weightsMultiplier);
67  clsControl.def(py::init<bool>(), "usePixelWeights"_a = false);
68 
69  PyEpochFootprint clsEpochFootprint(mod, "EpochFootprint");
70  clsEpochFootprint.def(py::init<afw::detection::Footprint const &, afw::image::Exposure<Pixel> const &,
71  shapelet::MultiShapeletFunction const &>(),
72  "footprint"_a, "exposure"_a, "psf"_a);
73  clsEpochFootprint.def_readonly("footprint", &EpochFootprint::footprint);
74  clsEpochFootprint.def_readonly("exposure", &EpochFootprint::exposure);
75  clsEpochFootprint.def_readonly("psf", &EpochFootprint::psf);
76 
77  PyUnitTransformedLikelihood clsUnitTransformedLikelihood(mod, "UnitTransformedLikelihood");
78  clsUnitTransformedLikelihood.def(
79  py::init<std::shared_ptr<Model>, ndarray::Array<Scalar const, 1, 1> const &, UnitSystem const &,
80  afw::coord::Coord const &, afw::image::Exposure<Pixel> const &,
81  afw::detection::Footprint const &, shapelet::MultiShapeletFunction const &,
82  UnitTransformedLikelihoodControl const &>(),
83  "model"_a, "fixed"_a, "fitSys"_a, "position"_a, "exposure"_a, "footprint"_a, "psf"_a, "ctrl"_a);
84  clsUnitTransformedLikelihood.def(
85  py::init<std::shared_ptr<Model>, ndarray::Array<Scalar const, 1, 1> const &, UnitSystem const &,
86  afw::coord::Coord const &, std::vector<std::shared_ptr<EpochFootprint>> const &,
87  UnitTransformedLikelihoodControl const &>(),
88  "model"_a, "fixed"_a, "fitSys"_a, "position"_a, "epochFootprintList"_a, "ctrl"_a);
89 
90  return mod.ptr();
91 }
92 }
93 }
94 }
95 } // namespace lsst::meas::modelfit::anonymous