26#include "pybind11/pybind11.h"
28#include "pybind11/eigen.h"
29#include "pybind11/stl.h"
38using namespace pybind11::literals;
45 using PyPhotometryModel = py::class_<PhotometryModel, std::shared_ptr<PhotometryModel>>;
47 wrappers.
wrapType(PyPhotometryModel(wrappers.module,
"PhotometryModel"), [](
auto &mod,
auto &cls) {
48 cls.def(
"assignIndices", &PhotometryModel::assignIndices);
49 cls.def(
"freezeErrorTransform", &PhotometryModel::freezeErrorTransform);
51 cls.def(
"offsetParams", &PhotometryModel::offsetParams);
52 cls.def(
"offsetFittedStar", &PhotometryModel::offsetFittedStar);
54 cls.def(
"transform", &PhotometryModel::transform);
55 cls.def(
"transformError", &PhotometryModel::transformError);
56 cls.def(
"computeResidual", &PhotometryModel::computeResidual);
58 cls.def(
"getRefError", &PhotometryModel::getRefError);
59 cls.def(
"computeRefResidual", &PhotometryModel::computeRefResidual);
61 cls.def(
"checkPositiveOnBBox", &PhotometryModel::checkPositiveOnBBox);
62 cls.def(
"validate", &PhotometryModel::validate);
64 cls.def(
"getMappingIndices", &PhotometryModel::getMappingIndices);
65 cls.def(
"computeParameterDerivatives",
66 [](PhotometryModel const &self, MeasuredStar const &star, CcdImage const &ccdImage) {
67 Eigen::VectorXd derivatives(self.getNpar(ccdImage));
68 self.computeParameterDerivatives(star, ccdImage, derivatives);
77 utils::python::addOutputOp(cls,
"__repr__");
78 cls.def(
"__str__", [](PhotometryModel
const &self) {
return "PhotometryModel"; });
83 using PySimplePhotometryModel =
84 py::class_<SimplePhotometryModel, std::shared_ptr<SimplePhotometryModel>, PhotometryModel>;
86 wrappers.
wrapType(PySimplePhotometryModel(wrappers.module,
"SimplePhotometryModel"), [](
auto &mod,
auto &cls) {
87 cls.def(
"__str__", [](SimplePhotometryModel const &self) { return
"SimplePhotometryModel"; });
92 using PySimpleFluxModel =
93 py::class_<SimpleFluxModel, std::shared_ptr<SimpleFluxModel>, SimplePhotometryModel, PhotometryModel>;
95 wrappers.
wrapType(PySimpleFluxModel(wrappers.module,
"SimpleFluxModel"), [](
auto &mod,
auto &cls) {
96 cls.def(py::init<CcdImageList const &, double>(),
"ccdImageList"_a,
"errorPedestal"_a = 0);
97 cls.def(
"__str__", [](SimpleFluxModel const &self) { return
"SimpleFluxModel"; });
102 using PySimpleMagnitudeModel = py::class_<SimpleMagnitudeModel, std::shared_ptr<SimpleMagnitudeModel>, SimplePhotometryModel,
105 wrappers.
wrapType(PySimpleMagnitudeModel(wrappers.module,
"SimpleMagnitudeModel"), [](
auto &mod,
auto &cls) {
106 cls.def(py::init<CcdImageList const &, double>(),
"ccdImageList"_a,
"errorPedestal"_a = 0);
107 cls.def(
"__str__", [](SimpleMagnitudeModel const &self) { return
"SimpleMagnitudeModel"; });
112 using PyConstrainedPhotometryModel =
113 py::class_<ConstrainedPhotometryModel, std::shared_ptr<ConstrainedPhotometryModel>, PhotometryModel>;
116 PyConstrainedPhotometryModel(wrappers.module,
"ConstrainedPhotometryModel"), [](
auto &mod,
auto &cls) {
118 [](ConstrainedPhotometryModel const &self) { return
"ConstrainedPhotometryModel"; });
123 using PyConstrainedFluxModel = py::class_<ConstrainedFluxModel, std::shared_ptr<ConstrainedFluxModel>, PhotometryModel>;
125 wrappers.
wrapType(PyConstrainedFluxModel(wrappers.module,
"ConstrainedFluxModel"), [](
auto &mod,
auto &cls) {
126 cls.def(py::init<CcdImageList const &, lsst::geom::Box2D const &, int, double>(),
"CcdImageList"_a,
127 "bbox"_a,
"visitOrder"_a = 7,
"errorPedestal"_a = 0);
132 using PyConstrainedMagnitudeModel = py::class_<ConstrainedMagnitudeModel, std::shared_ptr<ConstrainedMagnitudeModel>, PhotometryModel>;
134 wrappers.
wrapType(PyConstrainedMagnitudeModel(wrappers.module,
"ConstrainedMagnitudeModel"), [](
auto &mod,
auto &cls) {
135 cls.def(py::init<CcdImageList const &, lsst::geom::Box2D const &, int, double>(),
"CcdImageList"_a,
136 "bbox"_a,
"visitOrder"_a = 7,
"errorPedestal"_a = 0);
137 cls.def(
"__str__", [](ConstrainedMagnitudeModel const &self) { return
"ConstrainedMagnitudeModel"; });
143 declarePhotometryModel(wrappers);
144 declareSimplePhotometryModel(wrappers);
145 declareSimpleFluxModel(wrappers);
146 declareSimpleMagnitudeModel(wrappers);
147 declareConstrainedPhotometryModel(wrappers);
148 declareConstrainedFluxModel(wrappers);
149 declareConstrainedMagnitudeModel(wrappers);
A helper class for subdividing pybind11 module across multiple translation units (i....
PyType wrapType(PyType cls, ClassWrapperCallback function, bool setModuleName=true)
Add a type (class or enum) wrapper, deferring method and other attribute definitions until finish() i...
virtual std::size_t getTotalParameters() const =0
Return the total number of parameters in this model.
PhotometryMappingBase const & getMapping(CcdImage const &ccdImage) const
Get the mapping associated with ccdImage.
std::size_t getNpar(CcdImage const &ccdImage) const
Return the number of parameters in the mapping of CcdImage.
virtual std::shared_ptr< afw::image::PhotoCalib > toPhotoCalib(CcdImage const &ccdImage) const =0
Return the mapping of ccdImage represented as a PhotoCalib.
void wrapPhotometryModels(WrapperCollection &wrappers)