25#include "pybind11/pybind11.h"
27#include "pybind11/eigen.h"
28#include "pybind11/stl.h"
37using namespace pybind11::literals;
44 using PyPhotometryModel = py::class_<PhotometryModel, std::shared_ptr<PhotometryModel>>;
46 wrappers.
wrapType(PyPhotometryModel(wrappers.module,
"PhotometryModel"), [](
auto &mod,
auto &cls) {
47 cls.def(
"assignIndices", &PhotometryModel::assignIndices);
48 cls.def(
"freezeErrorTransform", &PhotometryModel::freezeErrorTransform);
50 cls.def(
"offsetParams", &PhotometryModel::offsetParams);
51 cls.def(
"offsetFittedStar", &PhotometryModel::offsetFittedStar);
53 cls.def(
"transform", &PhotometryModel::transform);
54 cls.def(
"transformError", &PhotometryModel::transformError);
55 cls.def(
"computeResidual", &PhotometryModel::computeResidual);
57 cls.def(
"getRefError", &PhotometryModel::getRefError);
58 cls.def(
"computeRefResidual", &PhotometryModel::computeRefResidual);
60 cls.def(
"checkPositiveOnBBox", &PhotometryModel::checkPositiveOnBBox);
61 cls.def(
"validate", &PhotometryModel::validate);
63 cls.def(
"getMappingIndices", &PhotometryModel::getMappingIndices);
64 cls.def(
"computeParameterDerivatives",
65 [](PhotometryModel const &self, MeasuredStar const &star, CcdImage const &ccdImage) {
66 Eigen::VectorXd derivatives(self.getNpar(ccdImage));
67 self.computeParameterDerivatives(star, ccdImage, derivatives);
77 cls.def(
"__str__", [](PhotometryModel
const &self) {
return "PhotometryModel"; });
82 using PySimplePhotometryModel =
83 py::class_<SimplePhotometryModel, std::shared_ptr<SimplePhotometryModel>, PhotometryModel>;
85 wrappers.
wrapType(PySimplePhotometryModel(wrappers.module,
"SimplePhotometryModel"), [](
auto &mod,
auto &cls) {
86 cls.def(
"__str__", [](SimplePhotometryModel const &self) { return
"SimplePhotometryModel"; });
91 using PySimpleFluxModel =
92 py::class_<SimpleFluxModel, std::shared_ptr<SimpleFluxModel>, SimplePhotometryModel, PhotometryModel>;
94 wrappers.
wrapType(PySimpleFluxModel(wrappers.module,
"SimpleFluxModel"), [](
auto &mod,
auto &cls) {
95 cls.def(py::init<CcdImageList const &, double>(),
"ccdImageList"_a,
"errorPedestal"_a = 0);
96 cls.def(
"__str__", [](SimpleFluxModel const &self) { return
"SimpleFluxModel"; });
101 using PySimpleMagnitudeModel = py::class_<SimpleMagnitudeModel, std::shared_ptr<SimpleMagnitudeModel>, SimplePhotometryModel,
104 wrappers.
wrapType(PySimpleMagnitudeModel(wrappers.module,
"SimpleMagnitudeModel"), [](
auto &mod,
auto &cls) {
105 cls.def(py::init<CcdImageList const &, double>(),
"ccdImageList"_a,
"errorPedestal"_a = 0);
106 cls.def(
"__str__", [](SimpleMagnitudeModel const &self) { return
"SimpleMagnitudeModel"; });
111 using PyConstrainedPhotometryModel =
112 py::class_<ConstrainedPhotometryModel, std::shared_ptr<ConstrainedPhotometryModel>, PhotometryModel>;
115 PyConstrainedPhotometryModel(wrappers.module,
"ConstrainedPhotometryModel"), [](
auto &mod,
auto &cls) {
117 [](ConstrainedPhotometryModel const &self) { return
"ConstrainedPhotometryModel"; });
122 using PyConstrainedFluxModel = py::class_<ConstrainedFluxModel, std::shared_ptr<ConstrainedFluxModel>, PhotometryModel>;
124 wrappers.
wrapType(PyConstrainedFluxModel(wrappers.module,
"ConstrainedFluxModel"), [](
auto &mod,
auto &cls) {
125 cls.def(py::init<CcdImageList const &, lsst::geom::Box2D const &, int, double>(),
"CcdImageList"_a,
126 "bbox"_a,
"visitOrder"_a = 7,
"errorPedestal"_a = 0);
131 using PyConstrainedMagnitudeModel = py::class_<ConstrainedMagnitudeModel, std::shared_ptr<ConstrainedMagnitudeModel>, PhotometryModel>;
133 wrappers.
wrapType(PyConstrainedMagnitudeModel(wrappers.module,
"ConstrainedMagnitudeModel"), [](
auto &mod,
auto &cls) {
134 cls.def(py::init<CcdImageList const &, lsst::geom::Box2D const &, int, double>(),
"CcdImageList"_a,
135 "bbox"_a,
"visitOrder"_a = 7,
"errorPedestal"_a = 0);
136 cls.def(
"__str__", [](ConstrainedMagnitudeModel const &self) { return
"ConstrainedMagnitudeModel"; });
142 declarePhotometryModel(wrappers);
143 declareSimplePhotometryModel(wrappers);
144 declareSimpleFluxModel(wrappers);
145 declareSimpleMagnitudeModel(wrappers);
146 declareConstrainedPhotometryModel(wrappers);
147 declareConstrainedFluxModel(wrappers);
148 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 addOutputOp(PyClass &cls, std::string const &method)
Add __str__ or __repr__ method implemented by operator<<.
void wrapPhotometryModels(WrapperCollection &wrappers)