LSST Applications g0da5cf3356+25b44625d0,g17e5ecfddb+50a5ac4092,g1c76d35bf8+585f0f68a2,g295839609d+8ef6456700,g2e2c1a68ba+cc1f6f037e,g38293774b4+62d12e78cb,g3b44f30a73+2891c76795,g48ccf36440+885b902d19,g4b2f1765b6+0c565e8f25,g5320a0a9f6+bd4bf1dc76,g56364267ca+403c24672b,g56b687f8c9+585f0f68a2,g5c4744a4d9+78cd207961,g5ffd174ac0+bd4bf1dc76,g6075d09f38+3075de592a,g667d525e37+cacede5508,g6f3e93b5a3+da81c812ee,g71f27ac40c+cacede5508,g7212e027e3+eb621d73aa,g774830318a+18d2b9fa6c,g7985c39107+62d12e78cb,g79ca90bc5c+fa2cc03294,g881bdbfe6c+cacede5508,g91fc1fa0cf+82a115f028,g961520b1fb+2534687f64,g96f01af41f+f2060f23b6,g9ca82378b8+cacede5508,g9d27549199+78cd207961,gb065e2a02a+ad48cbcda4,gb1df4690d6+585f0f68a2,gb35d6563ee+62d12e78cb,gbc3249ced9+bd4bf1dc76,gbec6a3398f+bd4bf1dc76,gd01420fc67+bd4bf1dc76,gd59336e7c4+c7bb92e648,gf46e8334de+81c9a61069,gfed783d017+bd4bf1dc76,v25.0.1.rc3
LSST Data Management Base Package
Loading...
Searching...
No Matches
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
32namespace py = pybind11;
33using namespace pybind11::literals;
34
35namespace ast {
36namespace {
37
38void 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
47void 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
56void 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
66void 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
75PYBIND11_MODULE(frame, mod) {
76 py::module::import("astshim.mapping");
77
78 wrapDirectionPoint(mod);
79 wrapNReadValue(mod);
80 wrapResolvedPoint(mod);
81 wrapFrameMapping(mod);
82
83 py::class_<Frame, std::shared_ptr<Frame>, Mapping> cls(mod, "Frame");
84
85 cls.def(py::init<int, std::string const &>(), "naxes"_a, "options"_a = "");
86 cls.def(py::init<Frame const &>());
87
88 cls.def_property("activeUnit", &Frame::getActiveUnit, &Frame::setActiveUnit);
89 cls.def_property("alignSystem", &Frame::getAlignSystem, &Frame::setAlignSystem);
90 cls.def_property("domain", &Frame::getDomain, &Frame::setDomain);
91 cls.def_property("dut1", &Frame::getDut1, &Frame::setDut1);
92 cls.def_property("epoch", &Frame::getEpoch, py::overload_cast<double>(&Frame::setEpoch));
93 cls.def_property("matchEnd", &Frame::getMatchEnd, &Frame::setMatchEnd);
94 cls.def_property("maxAxes", &Frame::getMaxAxes, &Frame::setMaxAxes);
95 cls.def_property("minAxes", &Frame::getMinAxes, &Frame::setMinAxes);
96 cls.def_property_readonly("nAxes", &Frame::getNAxes);
97 cls.def_property("obsAlt", &Frame::getObsAlt, &Frame::setObsAlt);
98 cls.def_property("obsLat", &Frame::getObsLat, &Frame::setObsLat);
99 cls.def_property("obsLon", &Frame::getObsLon, &Frame::setObsLon);
100 cls.def_property("permute", &Frame::getPermute, &Frame::setPermute);
101 cls.def_property("preserveAxes", &Frame::getPreserveAxes, &Frame::setPreserveAxes);
102 cls.def_property("system", &Frame::getSystem, &Frame::setSystem);
103 cls.def_property("title", &Frame::getTitle, &Frame::setTitle);
104
105 cls.def("copy", &Frame::copy);
106 cls.def("angle", &Frame::angle, "a"_a, "b"_a, "c"_a);
107 cls.def("axAngle", &Frame::axAngle, "a"_a, "b"_a, "axis"_a);
108 cls.def("axDistance", &Frame::axDistance, "axis"_a, "v1"_a, "v2"_a);
109 cls.def("axOffset", &Frame::axOffset, "axis"_a, "v1"_a, "dist"_a);
110 cls.def("convert", &Frame::convert, "to"_a, "domainlist"_a = "");
111 cls.def("distance", &Frame::distance, "point1"_a, "point2"_a);
112 cls.def("findFrame", &Frame::findFrame, "template"_a, "domainlist"_a = "");
113 cls.def("format", &Frame::format, "axis"_a, "value"_a);
114 cls.def("getBottom", &Frame::getBottom, "axis"_a);
115 cls.def("getDigits", py::overload_cast<>(&Frame::getDigits, py::const_));
116 cls.def("getDigits", py::overload_cast<int>(&Frame::getDigits, py::const_), "axis"_a);
117 cls.def("getDirection", &Frame::getDirection, "axis"_a);
118 cls.def("getFormat", &Frame::getFormat, "axis"_a);
119 cls.def("getInternalUnit", &Frame::getInternalUnit);
120 cls.def("getLabel", &Frame::getLabel);
121 cls.def("getSymbol", &Frame::getSymbol, "axis"_a);
122 cls.def("getNormUnit", &Frame::getNormUnit, "axis"_a);
123 cls.def("getSymbol", &Frame::getSymbol, "axis"_a);
124 cls.def("getTop", &Frame::getTop, "axis"_a);
125 cls.def("getUnit", &Frame::getUnit, "axis"_a);
126 cls.def("intersect", &Frame::intersect, "a1"_a, "a2"_a, "b1"_a, "b2"_a);
127 cls.def("matchAxes", &Frame::matchAxes, "other"_a);
128 cls.def("under", &Frame::under, "next"_a);
129 cls.def("norm", &Frame::norm, "value"_a);
130 cls.def("offset", &Frame::offset, "point1"_a, "point2"_a, "offset"_a);
131 cls.def("offset2", &Frame::offset2, "point1"_a, "angle"_a, "offset"_a);
132 cls.def("permAxes", &Frame::permAxes, "perm"_a);
133 cls.def("pickAxes", &Frame::pickAxes, "axes"_a);
134 cls.def("resolve", &Frame::resolve, "point1"_a, "point2"_a, "point3"_a);
135 cls.def("setDigits", py::overload_cast<int>(&Frame::setDigits), "digits"_a);
136 cls.def("setDigits", py::overload_cast<int, int>(&Frame::setDigits), "axis"_a, "digits"_a);
137 cls.def("setDirection", &Frame::setDirection, "direction"_a, "axis"_a);
138 // keep setEpoch(string); use the epoch property to deal with it as a float
139 cls.def("setEpoch", py::overload_cast<std::string const &>(&Frame::setEpoch), "epoch"_a);
140 cls.def("setFormat", &Frame::setFormat, "axis"_a,
141 "format"_a
142 "format");
143 cls.def("setLabel", &Frame::setLabel, "axis"_a, "label"_a);
144 cls.def("setSymbol", &Frame::setSymbol, "axis"_a, "symbol"_a);
145 cls.def("setTop", &Frame::setTop, "axis"_a, "top"_a);
146 cls.def("setUnit", &Frame::setUnit, "axis"_a, "unit"_a);
147 cls.def("unformat", &Frame::unformat, "axis"_a, "str"_a);
148}
149
150} // namespace
151} // namespace ast
double direction
Direction, an angle in radians.
Definition: Frame.h:52
PointD point
Point.
Definition: Frame.h:53
void permAxes(std::vector< int > perm)
Permute the order in which a Frame's axes occur.
Definition: Frame.h:1138
NReadValue unformat(int axis, std::string const &str) const
Read a formatted coordinate value (given as a character string) for a Frame axis and return the numbe...
Definition: Frame.h:1502
double axDistance(int axis, double v1, double v2) const
Return a signed value representing the axis increment from axis value v1 to axis value v2.
Definition: Frame.h:247
std::string getFormat(int axis) const
Get Format for one axis: format specification for axis values.
Definition: Frame.h:842
int getMaxAxes() const
Get MaxAxes: the maximum axes a frame found by findFrame may have.
Definition: Frame.h:864
double getDut1() const
Get Dut1: difference between the UT1 and UTC timescale (sec)
Definition: Frame.h:832
void setSymbol(int axis, std::string const &symbol)
Set Symbol(axis) for one axis: axis symbol.
Definition: Frame.h:1313
void setActiveUnit(bool enable)
Set ActiveUnit: pay attention to units when one Frame is used to match another?
Definition: Frame.h:1295
std::string getObsLat() const
Get ObsLat: Geodetic latitude of observer.
Definition: Frame.h:892
int getMinAxes() const
Get MinAxes: the maximum axes a frame found by findFrame may have.
Definition: Frame.h:870
void setMaxAxes(int maxAxes)
Get MaxAxes: the maximum number of axes a frame found by findFrame may have.
Definition: Frame.h:1268
virtual void setDomain(std::string const &domain)
Set Domain: coordinate system domain.
Definition: Frame.h:1230
double axOffset(int axis, double v1, double dist) const
Return an axis value formed by adding a signed axis increment onto a supplied axis value.
Definition: Frame.h:263
std::string getSymbol(int axis) const
Get Symbol(axis) for one axis: axis symbol.
Definition: Frame.h:912
double axAngle(PointD const &a, PointD const &b, int axis) const
Find the angle, as seen from point A, between the positive direction of a specified axis,...
Definition: Frame.h:229
double getBottom(int axis) const
Get Bottom for one axis: the lowest axis value to display.
Definition: Frame.h:807
void setPermute(bool permute)
Set Permute: allow axis permutation when used as a template?
Definition: Frame.h:1303
bool getPermute() const
Get Permute: allow axis permutation when used as a template?
Definition: Frame.h:902
int getDigits() const
Get Digits: the default used if no specific value specified for an axis.
Definition: Frame.h:812
int getNAxes() const
Get NAxes: the number of axes in the frame (i.e.
Definition: Frame.h:876
std::string getAlignSystem() const
Get AlignSystem: the coordinate system used by convert and findFrame to align Frames.
Definition: Frame.h:802
double distance(PointD const &point1, PointD const &point2) const
Find the distance between two points whose Frame coordinates are given.
Definition: Frame.h:474
void setDigits(int digits)
Set Digits for all axes: number of digits of precision.
Definition: Frame.h:1213
std::string getDomain() const
Get Domain: coordinate system domain.
Definition: Frame.h:827
void setFormat(int axis, std::string const &format)
Set Format for one axis: format specification for axis values.
Definition: Frame.h:1250
std::string getSystem() const
Get System: coordinate system used to describe positions within the domain.
Definition: Frame.h:918
void setDirection(bool direction, int axis)
Set Direction for one axis: display axis in conventional direction?
Definition: Frame.h:1223
std::shared_ptr< FrameSet > findFrame(Frame const &tmplt, std::string const &domainlist="")
Find a coordinate system with specified characteristics.
Definition: Frame.cc:41
PointD offset(PointD point1, PointD point2, double offset) const
Find the point which is offset a specified distance along the geodesic curve between two other points...
Definition: Frame.h:1075
double angle(PointD const &a, PointD const &b, PointD const &c) const
Find the angle at point B between the line joining points A and B, and the line joining points C and ...
Definition: Frame.h:201
std::string getNormUnit(int axis) const
Get NormUnit(axis) read-only attribute for one frame: normalised physical units for formatted axis va...
Definition: Frame.h:882
std::shared_ptr< Frame > copy() const
Return a deep copy of this object.
Definition: Frame.h:182
double getObsAlt() const
Get ObsAlt: Geodetic altitude of observer (m).
Definition: Frame.h:887
std::string getInternalUnit(int axis) const
Get InternalUnit(axis) read-only attribute for one axis: physical units for unformated axis values.
Definition: Frame.h:848
void setPreserveAxes(bool preserve)
Set PreserveAxes: preserve axes?
Definition: Frame.h:1308
void setMatchEnd(bool match)
Set MatchEnd: match trailing axes?
Definition: Frame.h:1262
void setObsAlt(double alt)
Set ObsAlt: Geodetic altitude of observer (m).
Definition: Frame.h:1279
void setAlignSystem(std::string const &system)
Set AlignSystem: the coordinate system used by convert and findFrame to align Frames.
Definition: Frame.h:1203
std::vector< double > intersect(std::vector< double > const &a1, std::vector< double > const &a2, std::vector< double > const &b1, std::vector< double > const &b2) const
Find the point of intersection between two geodesic curves.
Definition: Frame.cc:51
std::vector< int > matchAxes(Frame const &other) const
Look for corresponding axes between this frame and another.
Definition: Frame.h:985
bool getPreserveAxes() const
Get PreserveAxes: preserve axes?
Definition: Frame.h:907
CmpFrame under(Frame const &next) const
Combine this frame with another to form a compound frame (CmpFrame), with the axes of this frame foll...
Definition: Frame.cc:66
void setTitle(std::string const &title)
Set Title: frame title.
Definition: Frame.h:1326
bool getMatchEnd() const
Get MatchEnd: match trailing axes?
Definition: Frame.h:858
void setObsLon(std::string const &lon)
Set ObsLon: Geodetic longitude of observer.
Definition: Frame.h:1289
void setTop(int axis, double top)
Set Top for one axis: the highest axis value to display.
Definition: Frame.h:1331
PointD norm(PointD value) const
Normalise a set of Frame coordinate values which might be unsuitable for display (e....
Definition: Frame.h:1045
std::string getObsLon() const
Get ObsLon: Geodetic longitude of observer.
Definition: Frame.h:897
void setDut1(double dut1)
Set Dut1: difference between the UT1 and UTC timescale (sec)
Definition: Frame.h:1235
std::string getUnit(int axis) const
Get Unit(axis) for one axis: physical units for formatted axis values.
Definition: Frame.h:933
double getTop(int axis) const
Get Top: the highest axis value to display.
Definition: Frame.h:928
bool getActiveUnit() const
Get ActiveUnit: pay attention to units when one Frame is used to match another?
Definition: Frame.h:792
bool getDirection(int axis) const
Get Direction for one axis: display axis in conventional direction?
Definition: Frame.h:822
void setUnit(int axis, std::string const &unit)
Set Unit(axis) for one axis: physical units for formatted axis values.
Definition: Frame.h:1336
void setObsLat(std::string const &lat)
Set ObsLat: frame title.
Definition: Frame.h:1284
DirectionPoint offset2(PointD const &point1, double angle, double offset) const
Find the point which is offset a specified distance along the geodesic curve at a given angle from a ...
Definition: Frame.h:1117
std::string getLabel(int axis) const
Get Label(axis) for one axis: axis label.
Definition: Frame.h:853
FrameMapping pickAxes(std::vector< int > const &axes) const
Create a new Frame whose axes are copied from an existing Frame along with other Frame attributes,...
Definition: Frame.cc:68
void setLabel(int axis, std::string const &label)
Set Label(axis) for one axis: axis label.
Definition: Frame.h:1257
void setSystem(std::string const &system)
Set System: coordinate system used to describe positions within the domain.
Definition: Frame.h:1321
std::string format(int axis, double value) const
Return a string containing the formatted (character) version of a coordinate value for a Frame axis.
Definition: Frame.h:782
void setEpoch(double epoch)
Set Epoch: Epoch of observation as a double (years)
Definition: Frame.h:1240
std::string getTitle() const
Get Title: frame title.
Definition: Frame.h:923
void setMinAxes(int minAxes)
Get MinAxes: the minimum number of axes a frame found by findFrame may have.
Definition: Frame.h:1274
ResolvedPoint resolve(std::vector< double > const &point1, std::vector< double > const &point2, std::vector< double > const &point3) const
Resolve a vector into two orthogonal components.
Definition: Frame.cc:84
double getEpoch() const
Get Epoch: Epoch of observation.
Definition: Frame.h:837
std::shared_ptr< FrameSet > convert(Frame const &to, std::string const &domainlist="")
Compute a frameset that describes the conversion between this frame and another frame.
Definition: Frame.cc:31
std::shared_ptr< Mapping > mapping
Mapping.
Definition: Frame.h:102
std::shared_ptr< Frame > frame
Frame.
Definition: Frame.h:101
double value
Value that was read.
Definition: Frame.h:69
int nread
Number of characters that was read.
Definition: Frame.h:68
std::vector< double > point
Point.
Definition: Frame.h:83
double d2
Resolved vector component 2.
Definition: Frame.h:85
double d1
Resolved vector component 1.
Definition: Frame.h:84
AST wrapper classes and functions.
PYBIND11_MODULE(_cameraGeom, mod)
Definition: _cameraGeom.cc:38