Loading [MathJax]/extensions/tex2jax.js
LSST Applications g0fba68d861+05816baf74,g1ec0fe41b4+f536777771,g1fd858c14a+a9301854fb,g35bb328faa+fcb1d3bbc8,g4af146b050+a5c07d5b1d,g4d2262a081+6e5fcc2a4e,g53246c7159+fcb1d3bbc8,g56a49b3a55+9c12191793,g5a012ec0e7+3632fc3ff3,g60b5630c4e+ded28b650d,g67b6fd64d1+ed4b5058f4,g78460c75b0+2f9a1b4bcd,g786e29fd12+cf7ec2a62a,g8352419a5c+fcb1d3bbc8,g87b7deb4dc+7b42cf88bf,g8852436030+e5453db6e6,g89139ef638+ed4b5058f4,g8e3bb8577d+d38d73bdbd,g9125e01d80+fcb1d3bbc8,g94187f82dc+ded28b650d,g989de1cb63+ed4b5058f4,g9d31334357+ded28b650d,g9f33ca652e+50a8019d8c,gabe3b4be73+1e0a283bba,gabf8522325+fa80ff7197,gb1101e3267+d9fb1f8026,gb58c049af0+f03b321e39,gb665e3612d+2a0c9e9e84,gb89ab40317+ed4b5058f4,gcf25f946ba+e5453db6e6,gd6cbbdb0b4+bb83cc51f8,gdd1046aedd+ded28b650d,gde0f65d7ad+941d412827,ge278dab8ac+d65b3c2b70,ge410e46f29+ed4b5058f4,gf23fb2af72+b7cae620c0,gf5e32f922b+fcb1d3bbc8,gf67bdafdda+ed4b5058f4,w.2025.16
LSST Data Management Base Package
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
_cameraSys.cc
Go to the documentation of this file.
1/*
2 * This file is part of afw.
3 *
4 * Developed for the LSST Data Management System.
5 * This product includes software developed by the LSST Project
6 * (https://www.lsst.org).
7 * See the COPYRIGHT file at the top-level directory of this distribution
8 * for details of code ownership.
9 *
10 * This program is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation, either version 3 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program. If not, see <https://www.gnu.org/licenses/>.
22 */
23
24#include <string>
25
26#include <pybind11/pybind11.h>
28
30
31namespace py = pybind11;
32using namespace py::literals;
33
34namespace lsst {
35namespace afw {
36namespace cameraGeom {
37
38namespace {
45template <typename CppClass, typename PyClass>
46void declareCommonSysMethods(PyClass &cls) {
47 /* Operators */
48 cls.def(
49 "__eq__", [](CppClass const &self, CppClass const &other) { return self == other; },
50 py::is_operator());
51 cls.def(
52 "__ne__", [](CppClass const &self, CppClass const &other) { return self != other; },
53 py::is_operator());
54 cpputils::python::addOutputOp(cls, "__str__");
55 cpputils::python::addOutputOp(cls, "__repr__");
57
58 /* Methods */
59 cls.def("getSysName", &CppClass::getSysName);
60}
61} // namespace
62
64 /* Module level */
65 wrappers.wrapType(py::class_<CameraSysPrefix>(wrappers.module, "CameraSysPrefix"),
66 [](auto &mod, auto &cls) {
67 declareCommonSysMethods<CameraSysPrefix>(cls);
68 cls.def(py::init<std::string const &>(), "sysName"_a);
69 });
70 wrappers.wrapType(py::class_<CameraSys>(wrappers.module, "CameraSys"), [](auto &mod, auto &cls) {
71 declareCommonSysMethods<CameraSys>(cls);
72 /* Constructors */
73 cls.def(py::init<std::string const &>(), "sysName"_a);
74 cls.def(py::init<std::string const &, std::string const &>(), "sysName"_a, "detectorName"_a = "");
75 cls.def(py::init<CameraSysPrefix const &, std::string const &>(), "sysPrefix"_a,
76 "detectorName"_a = "");
77 /* Members */
78 cls.def("getDetectorName", &CameraSys::getDetectorName);
79 cls.def("hasDetectorName", &CameraSys::hasDetectorName);
80 });
81
82 // The following must come after the associated pybind11 class is declared
83 // (e.g. FOCAL_PLANE is a CameraSys, so clsCameraSys must have been declared
84 wrappers.wrap([](auto &mod) {
85 mod.attr("FOCAL_PLANE") = py::cast(FOCAL_PLANE);
86 mod.attr("FIELD_ANGLE") = py::cast(FIELD_ANGLE);
87 mod.attr("PIXELS") = py::cast(PIXELS);
88 mod.attr("TAN_PIXELS") = py::cast(TAN_PIXELS);
89 mod.attr("ACTUAL_PIXELS") = py::cast(ACTUAL_PIXELS);
90 });
91}
92} // namespace cameraGeom
93} // namespace afw
94} // namespace lsst
A helper class for subdividing pybind11 module across multiple translation units (i....
Definition python.h:242
void wrap(WrapperCallback function)
Add a set of wrappers without defining a class.
Definition python.h:369
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...
Definition python.h:391
pybind11::module module
The module object passed to the PYBIND11_MODULE block that contains this WrapperCollection.
Definition python.h:448
CameraSys const FIELD_ANGLE
Field angle coordinates: Angle of a principal ray relative to the optical axis (x,...
Definition CameraSys.cc:32
CameraSysPrefix const TAN_PIXELS
Tangent-plane pixels on the detector (x, y unbinned pixels)
Definition CameraSys.cc:36
void wrapCameraSys(lsst::cpputils::python::WrapperCollection &)
Definition _cameraSys.cc:63
CameraSys const FOCAL_PLANE
Focal plane coordinates: Position on a 2-d planar approximation to the focal plane (x,...
Definition CameraSys.cc:30
CameraSysPrefix const PIXELS
Pixel coordinates: Nominal position on the entry surface of a given detector (x, y unbinned pixels).
Definition CameraSys.cc:34
CameraSysPrefix const ACTUAL_PIXELS
The actual pixels where the photon lands and electrons are generated (x,y unbinned) This takes into a...
Definition CameraSys.cc:38
void addHash(PyClass &cls)
Add __hash__ method implemented by std::hash.
Definition python.h:104
void addOutputOp(PyClass &cls, std::string const &method)
Add __str__ or __repr__ method implemented by operator<<.
Definition python.h:87