24 #include "pybind11/pybind11.h"
25 #include "pybind11/stl.h"
30 #include "ndarray/pybind11.h"
42 using namespace pybind11::literals;
51 [](
auto &mod,
auto &cls) {
52 cls.def(py::init<double, double>(),
"value"_a,
"error"_a);
53 cls.def_readonly(
"value", &Measurement::value);
54 cls.def_readonly(
"error", &Measurement::error);
56 utils::python::addOutputOp(cls,
"__str__");
57 cls.def(
"__repr__", [](Measurement const &self) {
58 std::ostringstream os;
59 os <<
"Measurement(" << self <<
")";
69 [](
auto &mod,
auto &cls) {
71 cls.def(py::init<>());
72 cls.def(py::init<double, double, lsst::geom::Box2I>(),
"calibrationMean"_a,
73 "calibrationErr"_a = 0.0,
"bbox"_a = lsst::geom::Box2I());
74 cls.def(py::init<std::shared_ptr<afw::math::BoundedField>, double>(),
"calibration"_a,
75 "calibrationErr"_a = 0.0);
76 cls.def(py::init<double, double, std::shared_ptr<afw::math::BoundedField>, bool>(),
77 "calibrationMean"_a,
"calibrationErr"_a,
"calibration"_a,
"isConstant"_a);
79 table::io::python::addPersistableMethods<PhotoCalib>(cls);
82 cls.def(
"instFluxToNanojansky",
83 (double (PhotoCalib::*)(double, lsst::geom::Point<double, 2> const &) const) &
84 PhotoCalib::instFluxToNanojansky,
85 "instFlux"_a,
"point"_a);
86 cls.def(
"instFluxToNanojansky",
87 (double (PhotoCalib::*)(double) const) & PhotoCalib::instFluxToNanojansky,
90 cls.def(
"instFluxToNanojansky",
91 (Measurement(PhotoCalib::*)(double, double, lsst::geom::Point<double, 2> const &)
93 PhotoCalib::instFluxToNanojansky,
94 "instFlux"_a,
"instFluxErr"_a,
"point"_a);
95 cls.def(
"instFluxToNanojansky",
96 (Measurement(PhotoCalib::*)(double, double) const) & PhotoCalib::instFluxToNanojansky,
97 "instFlux"_a,
"instFluxErr"_a);
99 cls.def(
"instFluxToNanojansky",
100 (Measurement(PhotoCalib::*)(afw::table::SourceRecord const &, std::string const &)
102 PhotoCalib::instFluxToNanojansky,
103 "sourceRecord"_a,
"instFluxField"_a);
105 cls.def(
"instFluxToNanojansky",
106 (ndarray::Array<double, 2, 2>(PhotoCalib::*)(afw::table::SourceCatalog const &,
107 std::string const &) const) &
108 PhotoCalib::instFluxToNanojansky,
109 "sourceCatalog"_a,
"instFluxField"_a);
111 cls.def(
"instFluxToNanojansky",
112 (void (PhotoCalib::*)(afw::table::SourceCatalog &, std::string const &,
113 std::string const &) const) &
114 PhotoCalib::instFluxToNanojansky,
115 "sourceCatalog"_a,
"instFluxField"_a,
"outField"_a);
118 cls.def(
"instFluxToMagnitude",
119 (double (PhotoCalib::*)(double, lsst::geom::Point<double, 2> const &) const) &
120 PhotoCalib::instFluxToMagnitude,
121 "instFlux"_a,
"point"_a);
122 cls.def(
"instFluxToMagnitude",
123 (double (PhotoCalib::*)(double) const) & PhotoCalib::instFluxToMagnitude,
126 cls.def(
"instFluxToMagnitude",
127 (Measurement(PhotoCalib::*)(double, double, lsst::geom::Point<double, 2> const &)
129 PhotoCalib::instFluxToMagnitude,
130 "instFlux"_a,
"instFluxErr"_a,
"point"_a);
131 cls.def(
"instFluxToMagnitude",
132 (Measurement(PhotoCalib::*)(double, double) const) & PhotoCalib::instFluxToMagnitude,
133 "instFlux"_a,
"instFluxErr"_a);
135 cls.def(
"instFluxToMagnitude",
136 (Measurement(PhotoCalib::*)(afw::table::SourceRecord const &, std::string const &)
138 PhotoCalib::instFluxToMagnitude,
139 "sourceRecord"_a,
"instFluxField"_a);
141 cls.def(
"instFluxToMagnitude",
142 (ndarray::Array<double, 2, 2>(PhotoCalib::*)(afw::table::SourceCatalog const &,
143 std::string const &) const) &
144 PhotoCalib::instFluxToMagnitude,
145 "sourceCatalog"_a,
"instFluxField"_a);
147 cls.def(
"instFluxToMagnitude",
148 (void (PhotoCalib::*)(afw::table::SourceCatalog &, std::string const &,
149 std::string const &) const) &
150 PhotoCalib::instFluxToMagnitude,
151 "sourceCatalog"_a,
"instFluxField"_a,
"outField"_a);
154 cls.def(
"magnitudeToInstFlux",
155 py::overload_cast<double, lsst::geom::Point<double, 2> const &>(
156 &PhotoCalib::magnitudeToInstFlux, py::const_),
157 "instFlux"_a,
"point"_a);
158 cls.def(
"magnitudeToInstFlux",
159 py::overload_cast<double>(&PhotoCalib::magnitudeToInstFlux, py::const_),
163 cls.def(
"getCalibrationMean", &PhotoCalib::getCalibrationMean);
164 cls.def(
"getCalibrationErr", &PhotoCalib::getCalibrationErr);
165 cls.def(
"getInstFluxAtZeroMagnitude", &PhotoCalib::getInstFluxAtZeroMagnitude);
166 cls.def(
"getLocalCalibration", &PhotoCalib::getLocalCalibration,
"point"_a);
168 cls.def(
"computeScaledCalibration", &PhotoCalib::computeScaledCalibration);
169 cls.def(
"computeScalingTo", &PhotoCalib::computeScalingTo);
171 cls.def(
"calibrateImage", &PhotoCalib::calibrateImage,
"maskedImage"_a,
172 "includeScaleUncertainty"_a = true);
174 cls.def(
"calibrateCatalog",
175 py::overload_cast<afw::table::SourceCatalog const &,
176 std::vector<std::string> const &>(&PhotoCalib::calibrateCatalog,
178 "maskedImage"_a,
"fluxFields"_a);
179 cls.def(
"calibrateCatalog",
180 py::overload_cast<afw::table::SourceCatalog const &>(&PhotoCalib::calibrateCatalog,
185 cls.def(
"__eq__", &PhotoCalib::operator==, py::is_operator());
186 cls.def(
"__ne__", &PhotoCalib::operator!=, py::is_operator());
187 utils::python::addOutputOp(cls,
"__str__");
188 cls.def(
"__repr__", [](PhotoCalib const &self) {
189 std::ostringstream os;
190 os <<
"PhotoCalib(" << self <<
")";
197 wrappers.
wrap([](
auto &mod) {
199 mod.def(
"makePhotoCalibFromMetadata",
202 mod.def(
"makePhotoCalibFromCalibZeroPoint",
204 "instFluxMag0Err"_a =
false);
211 wrapMeasurement(wrappers);
212 wrapPhotoCalib(wrappers);
Implementation of the Photometric Calibration class.
A helper class for subdividing pybind11 module across multiple translation units (i....
pybind11::module module
The module object passed to the PYBIND11_MODULE block that contains this WrapperCollection.
void finish()
Invoke all deferred wrapper-declaring callables.
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...
void addInheritanceDependency(std::string const &name)
Indicate an external module that provides a base class for a subsequent addType call.
void wrap(WrapperCallback function)
Add a set of wrappers without defining a class.
PYBIND11_MODULE(imageUtils, mod)
Backwards-compatibility support for depersisting the old Calib (FluxMag0/FluxMag0Err) objects.
std::shared_ptr< PhotoCalib > makePhotoCalibFromCalibZeroPoint(double instFluxMag0, double instFluxMag0Err)
Construct a PhotoCalib from the deprecated Calib-style instFluxMag0/instFluxMag0Err values.
std::shared_ptr< PhotoCalib > makePhotoCalibFromMetadata(daf::base::PropertySet &metadata, bool strip=false)
Construct a PhotoCalib from FITS FLUXMAG0/FLUXMAG0ERR keywords.
A base class for image defects.