LSSTApplications  15.0+21,16.0+1,16.0+10,16.0+3,16.0+4,16.0-1-g2115a9e+4,16.0-1-g4515a79+8,16.0-1-g7bb14cc,16.0-1-g80120d7+6,16.0-1-g98efed3+6,16.0-1-gb7f560d+3,16.0-18-g7a076d417,16.0-2-g2ed7261+3,16.0-2-g311bfd2,16.0-2-g568a347+5,16.0-2-g7adb079,16.0-2-gd4c87cb+5,16.0-3-g099ede0,16.0-3-g150e024+5,16.0-3-g1f513a6+2,16.0-3-g958ce35,16.0-3-gc6a11d1,16.0-4-g84f75fb+7,16.0-4-gcfd1396+6,16.0-4-gde8cee2,16.0-5-g7bc0afb+5,16.0-5-g81851deb,16.0-5-g82b7855+1,16.0-5-gd32631f,16.0-5-gf14cb0b,16.0-6-g2dd73041+6,16.0-6-gcf12234+1,16.0-7-g95fb7bf+2,16.0-7-gc37dbc2+6,w.2018.28
LSSTDataManagementBasePackage
frame.cc
Go to the documentation of this file.
1 /*
2  * LSST Data Management System
3  *
4  * This product includes software developed by the
5  * LSST Project (http://www.lsst.org/).
6  * See the COPYRIGHT file
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 LSST License Statement and
19  * the GNU General Public License along with this program. If not,
20  * see <https://www.lsstcorp.org/LegalNotices/>.
21  */
22 #include <pybind11/pybind11.h>
23 #include <pybind11/stl.h>
24 
25 #include <vector>
26 
27 #include "astshim/CmpFrame.h"
28 #include "astshim/Frame.h"
29 #include "astshim/FrameSet.h"
30 #include "astshim/Mapping.h"
31 
32 namespace py = pybind11;
33 using namespace pybind11::literals;
34 
35 namespace ast {
36 namespace {
37 
38 void wrapDirectionPoint(py::module &mod) {
39  py::class_<DirectionPoint> cls(mod, "DirectionPoint");
40 
41  cls.def(py::init<double, PointD>(), "direction"_a, "point"_a);
42 
43  cls.def_readwrite("direction", &DirectionPoint::direction);
44  cls.def_readwrite("point", &DirectionPoint::point);
45 }
46 
47 void wrapNReadValue(py::module &mod) {
48  py::class_<NReadValue> cls(mod, "NReadValue");
49 
50  cls.def(py::init<int, double>(), "nread"_a, "value"_a);
51 
52  cls.def_readwrite("nread", &NReadValue::nread);
53  cls.def_readwrite("value", &NReadValue::value);
54 }
55 
56 void wrapResolvedPoint(py::module &mod) {
57  py::class_<ResolvedPoint> cls(mod, "ResolvedPoint");
58 
59  cls.def(py::init<int>(), "naxes"_a);
60 
61  cls.def_readwrite("point", &ResolvedPoint::point);
62  cls.def_readwrite("d1", &ResolvedPoint::d1);
63  cls.def_readwrite("d2", &ResolvedPoint::d2);
64 }
65 
66 void wrapFrameMapping(py::module &mod) {
67  py::class_<FrameMapping> cls(mod, "FrameMapping");
68 
69  cls.def(py::init<std::shared_ptr<Frame>, std::shared_ptr<Mapping>>(), "frame"_a, "mapping"_a);
70 
71  cls.def_readwrite("frame", &FrameMapping::frame);
72  cls.def_readwrite("mapping", &FrameMapping::mapping);
73 }
74 
76  py::module mod("frame", "Python wrapper for Frame");
77 
78  py::module::import("astshim.mapping");
79 
80  wrapDirectionPoint(mod);
81  wrapNReadValue(mod);
82  wrapResolvedPoint(mod);
83  wrapFrameMapping(mod);
84 
85  py::class_<Frame, std::shared_ptr<Frame>, Mapping> cls(mod, "Frame");
86 
87  cls.def(py::init<int, std::string const &>(), "naxes"_a, "options"_a = "");
88  cls.def(py::init<Frame const &>());
89 
90  cls.def_property("activeUnit", &Frame::getActiveUnit, &Frame::setActiveUnit);
91  cls.def_property("alignSystem", &Frame::getAlignSystem, &Frame::setAlignSystem);
92  cls.def_property("domain", &Frame::getDomain, &Frame::setDomain);
93  cls.def_property("dut1", &Frame::getDut1, &Frame::setDut1);
94  cls.def_property("epoch", &Frame::getEpoch, py::overload_cast<double>(&Frame::setEpoch));
95  cls.def_property("matchEnd", &Frame::getMatchEnd, &Frame::setMatchEnd);
96  cls.def_property("maxAxes", &Frame::getMaxAxes, &Frame::setMaxAxes);
97  cls.def_property("minAxes", &Frame::getMinAxes, &Frame::setMinAxes);
98  cls.def_property_readonly("nAxes", &Frame::getNAxes);
99  cls.def_property("obsAlt", &Frame::getObsAlt, &Frame::setObsAlt);
100  cls.def_property("obsLat", &Frame::getObsLat, &Frame::setObsLat);
101  cls.def_property("obsLon", &Frame::getObsLon, &Frame::setObsLon);
102  cls.def_property("permute", &Frame::getPermute, &Frame::setPermute);
103  cls.def_property("preserveAxes", &Frame::getPreserveAxes, &Frame::setPreserveAxes);
104  cls.def_property("system", &Frame::getSystem, &Frame::setSystem);
105  cls.def_property("title", &Frame::getTitle, &Frame::setTitle);
106 
107  cls.def("copy", &Frame::copy);
108  cls.def("angle", &Frame::angle, "a"_a, "b"_a, "c"_a);
109  cls.def("axAngle", &Frame::axAngle, "a"_a, "b"_a, "axis"_a);
110  cls.def("axDistance", &Frame::axDistance, "axis"_a, "v1"_a, "v2"_a);
111  cls.def("axOffset", &Frame::axOffset, "axis"_a, "v1"_a, "dist"_a);
112  cls.def("convert", &Frame::convert, "to"_a, "domainlist"_a = "");
113  cls.def("distance", &Frame::distance, "point1"_a, "point2"_a);
114  cls.def("findFrame", &Frame::findFrame, "template"_a, "domainlist"_a = "");
115  cls.def("format", &Frame::format, "axis"_a, "value"_a);
116  cls.def("getBottom", &Frame::getBottom, "axis"_a);
117  cls.def("getDigits", py::overload_cast<>(&Frame::getDigits, py::const_));
118  cls.def("getDigits", py::overload_cast<int>(&Frame::getDigits, py::const_), "axis"_a);
119  cls.def("getDirection", &Frame::getDirection, "axis"_a);
120  cls.def("getFormat", &Frame::getFormat, "axis"_a);
121  cls.def("getInternalUnit", &Frame::getInternalUnit);
122  cls.def("getLabel", &Frame::getLabel);
123  cls.def("getSymbol", &Frame::getSymbol, "axis"_a);
124  cls.def("getNormUnit", &Frame::getNormUnit, "axis"_a);
125  cls.def("getSymbol", &Frame::getSymbol, "axis"_a);
126  cls.def("getTop", &Frame::getTop, "axis"_a);
127  cls.def("getUnit", &Frame::getUnit, "axis"_a);
128  cls.def("intersect", &Frame::intersect, "a1"_a, "a2"_a, "b1"_a, "b2"_a);
129  cls.def("matchAxes", &Frame::matchAxes, "other"_a);
130  cls.def("under", &Frame::under, "next"_a);
131  cls.def("norm", &Frame::norm, "value"_a);
132  cls.def("offset", &Frame::offset, "point1"_a, "point2"_a, "offset"_a);
133  cls.def("offset2", &Frame::offset2, "point1"_a, "angle"_a, "offset"_a);
134  cls.def("permAxes", &Frame::permAxes, "perm"_a);
135  cls.def("pickAxes", &Frame::pickAxes, "axes"_a);
136  cls.def("resolve", &Frame::resolve, "point1"_a, "point2"_a, "point3"_a);
137  cls.def("setDigits", py::overload_cast<int>(&Frame::setDigits), "digits"_a);
138  cls.def("setDigits", py::overload_cast<int, int>(&Frame::setDigits), "axis"_a, "digits"_a);
139  cls.def("setDirection", &Frame::setDirection, "direction"_a, "axis"_a);
140  // keep setEpoch(string); use the epoch property to deal with it as a float
141  cls.def("setEpoch", py::overload_cast<std::string const &>(&Frame::setEpoch), "epoch"_a);
142  cls.def("setFormat", &Frame::setFormat, "axis"_a,
143  "format"_a
144  "format");
145  cls.def("setLabel", &Frame::setLabel, "axis"_a, "label"_a);
146  cls.def("setSymbol", &Frame::setSymbol, "axis"_a, "symbol"_a);
147  cls.def("setTop", &Frame::setTop, "axis"_a, "top"_a);
148  cls.def("setUnit", &Frame::setUnit, "axis"_a, "unit"_a);
149  cls.def("unformat", &Frame::unformat, "axis"_a, "str"_a);
150 
151  return mod.ptr();
152 }
153 
154 } // namespace
155 } // namespace ast
AST wrapper classes and functions.
def init()
Definition: tests.py:79
T norm(const T &x)
Definition: Integrate.h:194
table::Key< double > angle
PYBIND11_PLUGIN(cameraSys)
Definition: cameraSys.cc:62
def format(config, name=None, writeSourceLine=True, prefix="", verbose=False)
Definition: history.py:134