24#include "pybind11/pybind11.h"
26#include "ndarray/pybind11.h"
35using namespace pybind11::literals;
43 using PyPrior = py::class_<Prior, std::shared_ptr<Prior>>;
44 PyPrior cls(mod,
"Prior");
48 "nonlinearGradient"_a,
"amplitudeGradient"_a,
"nonlinearHessian"_a,
"amplitudeHessian"_a,
51 cls.def(
"maximize", &
Prior::maximize,
"gradient"_a,
"hessian"_a,
"nonlinear"_a,
"amplitudes"_a);
53 "amplitudes"_a,
"weights"_a,
"multiplyWeights"_a =
false);
56static void declareMixturePrior(
py::module &mod) {
57 using Class = MixturePrior;
58 using PyClass = py::class_<Class, std::shared_ptr<Class>, Prior>;
59 PyClass cls(mod,
"MixturePrior");
61 cls.def_static(
"getUpdateRestriction", &Class::getUpdateRestriction,
62 py::return_value_policy::reference);
63 cls.def(
"getMixture", &Class::getMixture);
67static void declareSemiEmpiricalPrior(
py::module &mod) {
68 using Class = SemiEmpiricalPrior;
69 using Control = SemiEmpiricalPriorControl;
70 using PyControl = py::class_<Control, std::shared_ptr<Control>>;
71 using PyClass = py::class_<Class, std::shared_ptr<Class>, Prior>;
73 PyControl clsControl(mod,
"SemiEmpiricalPriorControl");
74 clsControl.def(py::init<>());
84 PyClass cls(mod,
"SemiEmpiricalPrior");
85 cls.def(py::init<Control>(),
"ctrl"_a);
86 cls.attr(
"Control") = clsControl;
90static void declareSoftenedLinearPrior(
py::module &mod) {
91 using Class = SoftenedLinearPrior;
92 using Control = SoftenedLinearPriorControl;
93 using PyControl = py::class_<Control, std::shared_ptr<Control>>;
94 using PyClass = py::class_<Class, std::shared_ptr<Class>, Prior>;
96 PyControl clsControl(mod,
"SoftenedLinearPriorControl");
97 clsControl.def(py::init<>());
106 PyClass cls(mod,
"SoftenedLinearPrior");
107 cls.def(py::init<Control>(),
"ctrl"_a);
108 cls.def(
"getControl", &Class::getControl, py::return_value_policy::copy);
109 cls.attr(
"Control") = clsControl;
114 py::module::import(
"lsst.meas.modelfit.mixture");
117 declareMixturePrior(mod);
118 declareSemiEmpiricalPrior(mod);
119 declareSoftenedLinearPrior(mod);
virtual Scalar marginalize(Vector const &gradient, Matrix const &hessian, ndarray::Array< Scalar const, 1, 1 > const &nonlinear) const =0
Return the -log amplitude integral of the prior*likelihood product.
virtual Scalar maximize(Vector const &gradient, Matrix const &hessian, ndarray::Array< Scalar const, 1, 1 > const &nonlinear, ndarray::Array< Scalar, 1, 1 > const &litudes) const =0
Compute the amplitude vector that maximizes the prior x likelihood product.
virtual Scalar evaluate(ndarray::Array< Scalar const, 1, 1 > const &nonlinear, ndarray::Array< Scalar const, 1, 1 > const &litudes) const =0
Evaluate the prior at the given point in nonlinear and amplitude space.
std::string const & getTag() const
virtual void drawAmplitudes(Vector const &gradient, Matrix const &hessian, ndarray::Array< Scalar const, 1, 1 > const &nonlinear, afw::math::Random &rng, ndarray::Array< Scalar, 2, 1 > const &litudes, ndarray::Array< Scalar, 1, 1 > const &weights, bool multiplyWeights=false) const =0
Draw a set of Monte Carlo amplitude vectors.
virtual void evaluateDerivatives(ndarray::Array< Scalar const, 1, 1 > const &nonlinear, ndarray::Array< Scalar const, 1, 1 > const &litudes, ndarray::Array< Scalar, 1, 1 > const &nonlinearGradient, ndarray::Array< Scalar, 1, 1 > const &litudeGradient, ndarray::Array< Scalar, 2, 1 > const &nonlinearHessian, ndarray::Array< Scalar, 2, 1 > const &litudeHessian, ndarray::Array< Scalar, 2, 1 > const &crossHessian) const =0
Evaluate the derivatives of the prior at the given point in nonlinear and amplitude space.
PYBIND11_MODULE(_cameraGeom, mod)
py::class_< PixelAreaBoundedField, std::shared_ptr< PixelAreaBoundedField >, BoundedField > PyClass
A base class for image defects.
#define LSST_DECLARE_CONTROL_FIELD(WRAPPER, CLASS, NAME)
Macro used to wrap fields declared by LSST_CONTROL_FIELD using Pybind11.