24#include "pybind11/pybind11.h"
27#include "pybind11/stl.h"
34using namespace py::literals;
40using PyCamera = py::class_<Camera, DetectorCollection, std::shared_ptr<Camera>>;
41using PyCameraBuilder = py::class_<Camera::Builder, DetectorCollectionBase<Detector::InCameraBuilder>,
48void wrapCamera(lsst::utils::python::WrapperCollection &wrappers) {
49 wrappers.addInheritanceDependency(
"lsst.afw.table.io");
50 wrappers.addSignatureDependency(
"lsst.afw.cameraGeom");
51 auto camera = wrappers.wrapType(
PyCamera(wrappers.module,
"Camera"), [](
auto &mod,
auto &cls) {
52 cls.def(
"rebuild", &Camera::rebuild);
53 cls.def(
"getName", &Camera::getName);
54 cls.def(
"getPupilFactoryName", &Camera::getPupilFactoryName);
55 cls.def(
"findDetectors", &Camera::findDetectors,
"point"_a,
"cameraSys"_a);
56 cls.def(
"findDetectorsList", &Camera::findDetectorsList,
"pointList"_a,
"cameraSys"_a);
60 [](Camera const &self, CameraSys const &fromSys, CameraSys const &toSys) {
62 return self.getTransform(fromSys, toSys);
63 } catch (pex::exceptions::NotFoundError &err) {
64 PyErr_SetString(PyExc_KeyError, err.what());
65 throw py::error_already_set();
68 "fromSys"_a,
"toSys"_a);
75 return self.transform(point, fromSys, toSys);
77 PyErr_SetString(PyExc_KeyError, err.
what());
78 throw py::error_already_set();
81 "point"_a,
"fromSys"_a,
"toSys"_a);
87 return self.transform(points, fromSys, toSys);
89 PyErr_SetString(PyExc_KeyError, err.
what());
90 throw py::error_already_set();
93 "points"_a,
"fromSys"_a,
"toSys"_a);
96 wrappers.wrapType(
PyCameraBuilder(camera,
"Builder"), [](
auto &mod,
auto &cls) {
97 cls.def(py::init<std::string const &>(),
"name"_a);
98 cls.def(py::init<Camera const &>(),
"camera"_a);
104 cls.def(
"setPupilFactoryClass", [](Camera::Builder &
self, py::object pupilFactoryClass) {
106 if (!pupilFactoryClass.is(py::none())) {
108 pupilFactoryClass.attr(
"__name__"));
table::Key< std::string > pupilFactoryName
void setPupilFactoryName(std::string const &pupilFactoryName)
Set the fully-qualified name of the Python class that provides this Camera's PupilFactory.
void setTransformFromFocalPlaneTo(CameraSys const &toSys, std::shared_ptr< afw::geom::TransformPoint2ToPoint2 const > transform)
Set the transformation from FOCAL_PLANE to the given coordinate system.
std::string getName() const
Return the name of the camera.
std::string getPupilFactoryName() const
Return the fully-qualified name of the Python class that provides this Camera's PupilFactory.
std::shared_ptr< Detector::InCameraBuilder > add(std::string const &name, int id)
Add a new Detector with the given name and ID.
void remove(std::string const &name)
Remove the detector with the given name or ID.
bool discardTransformFromFocalPlaneTo(CameraSys const &toSys)
Remove any transformation from FOCAL_PLANE to the given coordinate system.
void setName(std::string const &name)
Set the name of the camera.
std::shared_ptr< Camera const > finish() const
Construct a new Camera from the state of the Builder.
An immutable representation of a camera.
std::shared_ptr< TransformMap const > getTransformMap() const noexcept
Obtain the transform registry.
Camera coordinate system; used as a key in in TransformMap.
virtual char const * what(void) const noexcept
Return a character string summarizing this exception.
Reports attempts to access elements using an invalid key.
py::class_< Camera, DetectorCollection, std::shared_ptr< Camera > > PyCamera
void wrapCamera(lsst::utils::python::WrapperCollection &wrappers)
py::class_< Camera::Builder, DetectorCollectionBase< Detector::InCameraBuilder >, std::shared_ptr< Camera::Builder > > PyCameraBuilder
void addPersistableMethods(pybind11::class_< Class, Args... > &cls)
Add table::io::Persistable and PersistableFacade methods to the pybind11 wrapper for a class.
A base class for image defects.