LSST Applications 30.0.7,g0e76e35be5+e8e946ae08,g19811a7679+138f7293ba,g199a45376c+5e234f8357,g1fd858c14a+2f48dbc4c4,g262e1987ae+fb36cac54d,g29ae962dfc+d9108a0941,g2c21b0017a+4f59a27f16,g31e44d4a5c+b0138be388,g33ac35c1f1+28b9f72785,g35bb328faa+b0138be388,g40c9b15c53+823ad735c1,g47891489e3+bcc48a0b46,g53246c7159+b0138be388,g64539dfbff+e8e946ae08,g67b6fd64d1+bcc48a0b46,g74acd417e5+422380537a,g76965917b2+a5ca99c4d9,g786e29fd12+796b79145d,g7aefaa3e3d+dc0c200193,g86b635cae8+734fe384f0,g87389fa792+d8b5378923,g89139ef638+bcc48a0b46,g8bbb235e95+3f4f7f9447,g8ea07a8fe4+78a4c88802,g9290983e33+ffdc83c6f7,g92c671f44c+e8e946ae08,gaa753fd333+03f406da14,gbf99507273+b0138be388,gc49b57b85e+8df26ee1f0,gca7fc764a6+bcc48a0b46,gd7ef33dd92+bcc48a0b46,gdab6d2f7ff+422380537a,ge1c02a5578+b0138be388,ge410e46f29+bcc48a0b46,ge80df9fc40+e6db5413d1,geaed405ab2+1de65a85c6,gf5dcc679e7+35a0ce2edd,gf5f1c85443+e8e946ae08
LSST Data Management Base Package
Loading...
Searching...
No Matches
_SphereTransform.cc
Go to the documentation of this file.
1/*
2 * Developed for the LSST Data Management System.
3 * This product includes software developed by the LSST Project
4 * (https://www.lsst.org).
5 * See the COPYRIGHT file at the top-level directory of this distribution
6 * for details of code ownership.
7 *
8 * This program is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 */
21
22#include "pybind11/pybind11.h"
23#include "pybind11/eigen.h"
24#include "pybind11/numpy.h"
25
26#include "ndarray/pybind11.h"
27
29
31
32namespace py = pybind11;
33using namespace pybind11::literals;
34
35namespace lsst {
36namespace geom {
37
39 wrappers.wrapType(
40 py::class_<SphereTransform, std::shared_ptr<SphereTransform>>(wrappers.module, "SphereTransform"),
41 [](auto & mod, auto & cls) {
42
43 cls.def(py::init<>());
44 cls.def(py::init<SphereTransform::Matrix const &>(), "matrix"_a);
45 cls.def_static(
46 "fit_unit_vectors", &SphereTransform::fit_unit_vectors,
47 "from"_a, "to"_a, "weights"_a = py::none()
48 );
49 cls.def("__call__",
50 py::overload_cast<SpherePoint const &>(&SphereTransform::operator(), py::const_));
51 cls.def("__call__",
52 py::overload_cast<sphgeom::UnitVector3d const &>(&SphereTransform::operator(), py::const_));
53 cls.def("__call__",
54 [](py::object self, py::object x, py::object y, py::object z) {
55 return py::make_tuple(self.attr("applyX")(x, y, z),
56 self.attr("applyY")(x, y, z),
57 self.attr("applyZ")(x, y, z));
58 },
59 "x"_a, "y"_a, "z"_a);
60 cls.def("__mul__", &SphereTransform::operator*, py::is_operator());
61 cls.def("getMatrix", &SphereTransform::getMatrix, py::return_value_policy::reference_internal);
62 cls.def_property_readonly("matrix", &SphereTransform::getMatrix, py::return_value_policy::reference_internal);
63 cls.def("inverted", &SphereTransform::inverted);
64 cls.def("applyX", py::vectorize(&SphereTransform::applyX), "x"_a, "y"_a, "z"_a);
65 cls.def("applyY", py::vectorize(&SphereTransform::applyY), "x"_a, "y"_a, "z"_a);
66 cls.def("applyZ", py::vectorize(&SphereTransform::applyZ), "x"_a, "y"_a, "z"_a);
67
68 cls.def("__str__", [](SphereTransform const &self) {
69 return py::str(py::cast(self.getMatrix()));
70 });
71 cls.def("__repr__", [](SphereTransform const &self) {
72 return py::str("SphereTransform(\n{}\n)").format(py::cast(self.getMatrix()));
73 });
74 cls.def("__reduce__", [cls](SphereTransform const &self) {
75 return py::make_tuple(cls, py::make_tuple(py::cast(self.getMatrix())));
76 });
77 }
78 );
79}
80
81} // namespace geom
82} // namespace lsst
A helper class for subdividing pybind11 module across multiple translation units (i....
Definition python.h:242
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
A rigid 3-d transform on the sphere.
double applyY(double x, double y, double z) const noexcept
SphereTransform const inverted() const noexcept
Return the inverse transform.
Matrix const & getMatrix() const noexcept
Return the matrix representation of the transform.
double applyZ(double x, double y, double z) const noexcept
double applyX(double x, double y, double z) const noexcept
Transform a 3-d unit vector given and returned as separate double values.
void wrapSphereTransform(WrapperCollection &wrappers)