23 #include <pybind11/pybind11.h>
24 #include <pybind11/stl.h>
25 #include <pybind11/operators.h>
29 namespace py = pybind11;
31 using namespace lsst::afw::coord;
36 py::module mod(
"_coord",
"Python wrapper for afw _coord library");
39 py::enum_<CoordSystem>(mod,
"CoordSystem")
50 py::class_<Coord, std::shared_ptr<Coord>> clsCoord(mod,
"Coord");
53 clsCoord.def(py::init<lsst::afw::geom::Point2D const, lsst::afw::geom::AngleUnit, double const>(),
55 clsCoord.def(py::init<lsst::afw::geom::Point3D const, double const, bool, lsst::afw::geom::Angle const>(),
56 py::arg(
"p2d"), py::arg(
"epoch") = 2000.0, py::arg(
"normalize") =
true,
58 clsCoord.def(py::init<lsst::afw::geom::Angle const, lsst::afw::geom::Angle const, double const>(),
59 py::arg(
"ra"), py::arg(
"dec"), py::arg(
"epoch") = 2000.0);
60 clsCoord.def(py::init<std::string const, std::string const, double const>(), py::arg(
"ra"),
61 py::arg(
"dec"), py::arg(
"epoch") = 2000.0);
62 clsCoord.def(py::init<>());
67 clsCoord.def(
"__getitem__", [](
const Coord &c,
size_t i) {
68 if (i >= 2)
throw py::index_error();
71 clsCoord.def(
"__eq__", [](
Coord &a,
const Coord &b) {
return a == b; });
72 clsCoord.def(
"__ne__", [](
Coord &a,
const Coord &b) {
return a != b; });
96 clsCoord.def(
"convert", &
Coord::convert, py::arg(
"system"), py::arg(
"epoch") = 2000);
98 clsCoord.def(
"toFk5", (
Fk5Coord (
Coord::*)()
const) & Coord::toFk5);
105 py::class_<IcrsCoord, std::shared_ptr<IcrsCoord>,
Coord> clsIcrsCoord(mod,
"IcrsCoord");
108 clsIcrsCoord.def(py::init<lsst::afw::geom::Point2D const &, lsst::afw::geom::AngleUnit>(), py::arg(
"p2d"),
110 clsIcrsCoord.def(py::init<lsst::afw::geom::Point3D const &, bool, lsst::afw::geom::Angle const>(),
111 py::arg(
"p3d"), py::arg(
"normalize") =
true,
113 clsIcrsCoord.def(py::init<lsst::afw::geom::Angle const, lsst::afw::geom::Angle const>(), py::arg(
"ra"),
115 clsIcrsCoord.def(py::init<std::string const, std::string const>(), py::arg(
"ra"), py::arg(
"dec"));
116 clsIcrsCoord.def(py::init<>());
122 clsIcrsCoord.def(
"reset",
136 py::class_<Fk5Coord, std::shared_ptr<Fk5Coord>,
Coord> clsFk5Coord(mod,
"Fk5Coord");
139 clsFk5Coord.def(py::init<lsst::afw::geom::Point2D const &, lsst::afw::geom::AngleUnit, double const>(),
142 py::init<lsst::afw::geom::Point3D const &, double const, bool, lsst::afw::geom::Angle const>(),
143 py::arg(
"p3d"), py::arg(
"epoch") = 2000.0, py::arg(
"normalize") =
true,
145 clsFk5Coord.def(py::init<lsst::afw::geom::Angle const, lsst::afw::geom::Angle const, double const>(),
146 py::arg(
"ra"), py::arg(
"dec"), py::arg(
"epoch") = 2000.0);
147 clsFk5Coord.def(py::init<std::string const, std::string const, double const>(), py::arg(
"ra"),
148 py::arg(
"dec"), py::arg(
"epoch") = 2000.0);
149 clsFk5Coord.def(py::init<>());
161 clsFk5Coord.def(
"toFk5", (
Fk5Coord (
Fk5Coord::*)()
const) & Fk5Coord::toFk5);
168 py::class_<GalacticCoord, std::shared_ptr<GalacticCoord>,
Coord> clsGalacticCoord(mod,
"GalacticCoord");
171 clsGalacticCoord.def(py::init<lsst::afw::geom::Point2D const &, lsst::afw::geom::AngleUnit>(),
173 clsGalacticCoord.def(py::init<lsst::afw::geom::Point3D const &, bool, lsst::afw::geom::Angle const>(),
174 py::arg(
"p3d"), py::arg(
"normalize") =
true,
176 clsGalacticCoord.def(py::init<lsst::afw::geom::Angle const, lsst::afw::geom::Angle const>(), py::arg(
"l"),
178 clsGalacticCoord.def(py::init<std::string const, std::string const>(), py::arg(
"l"), py::arg(
"b"));
179 clsGalacticCoord.def(py::init<>());
185 clsGalacticCoord.def(
190 GalacticCoord::reset);
200 py::class_<EclipticCoord, std::shared_ptr<EclipticCoord>,
Coord> clsEclipticCoord(mod,
"EclipticCoord");
203 clsEclipticCoord.def(
204 py::init<lsst::afw::geom::Point2D const &, lsst::afw::geom::AngleUnit, double const>(),
206 clsEclipticCoord.def(
207 py::init<lsst::afw::geom::Point3D const &, double const, bool, lsst::afw::geom::Angle const>(),
208 py::arg(
"p3d"), py::arg(
"epoch") = 2000.0, py::arg(
"normalize") =
true,
210 clsEclipticCoord.def(py::init<lsst::afw::geom::Angle const, lsst::afw::geom::Angle const, double const>(),
211 py::arg(
"lambda"), py::arg(
"beta"), py::arg(
"epoch") = 2000.0);
212 clsEclipticCoord.def(py::init<std::string const, std::string const, double const>(), py::arg(
"lambda"),
213 py::arg(
"beta"), py::arg(
"epoch") = 2000.0);
214 clsEclipticCoord.def(py::init<>());
227 clsGalacticCoord.def(
"toEcliptic",
229 clsGalacticCoord.def(
"toEcliptic",
233 py::class_<TopocentricCoord, std::shared_ptr<TopocentricCoord>,
Coord> clsTopocentricCoord(
234 mod,
"TopocentricCoord");
240 py::arg(
"observatory"));
243 py::arg(
"p3d"), py::arg(
"epoch") = 2000.0, py::arg(
"normalize"),
247 py::arg(
"az"), py::arg(
"alt"), py::arg(
"epoch"), py::arg(
"observatory"));
248 clsTopocentricCoord.def(
249 py::init<std::string const, std::string const, double const, Observatory const &>(),
250 py::arg(
"az"), py::arg(
"alt"), py::arg(
"epoch"), py::arg(
"observatory"));
262 clsTopocentricCoord.def(
"toFk5",
265 clsTopocentricCoord.def(
"toTopocentric",
267 Observatory const &, lsst::daf::base::DateTime
const &)
const) &
270 TopocentricCoord::toTopocentric);
276 (std::shared_ptr<Coord>(*)(
CoordSystem const, std::string
const, std::string
const))makeCoord);
282 py::arg(
"system"), py::arg(
"p3d"), py::arg(
"epoch"), py::arg(
"normalize") =
true,
284 mod.def(
"makeCoord", (std::shared_ptr<Coord>(*)(
CoordSystem const))makeCoord);
288 (std::shared_ptr<Coord>(*)(
CoordSystem const, std::string
const, std::string
const))makeCoord);
293 py::arg(
"system"), py::arg(
"p3d"), py::arg(
"normalize") =
true,
std::shared_ptr< Coord > makeCoord(CoordSystem const system, lsst::afw::geom::Angle const ra, lsst::afw::geom::Angle const dec, double const epoch)
Factory function to create a Coord of arbitrary type with decimal RA,Dec.
virtual std::string getClassName() const
virtual GalacticCoord toGalactic() const
Convert ourself to Galactic: l, b.
virtual std::shared_ptr< Coord > clone() const
virtual CoordSystem getCoordSystem() const
std::string getLongitudeStr(lsst::afw::geom::AngleUnit unit) const
Allow quick access to the longitudinal coordinate as a string.
virtual void reset(lsst::afw::geom::Angle const longitude, lsst::afw::geom::Angle const latitude)
special reset() overload to make sure no epoch can be set
virtual Fk5Coord toFk5() const
Convert outself from Topocentric to Fk5 (use current epoch)
lsst::afw::geom::Angle getL() const
A class to handle Galactic coordinates (inherits from Coord)
std::string getAltitudeStr() const
lsst::afw::geom::Angle getAltitude() const
lsst::afw::geom::Angle getAzimuth() const
virtual TopocentricCoord toTopocentric(Observatory const &obs, lsst::daf::base::DateTime const &obsDate) const
Convert ourself to Altitude/Azimuth: alt, az.
std::pair< lsst::afw::geom::Angle, lsst::afw::geom::Angle > getTangentPlaneOffset(Coord const &c) const
Get the offset on the tangent plane.
Hold the location of an observatory.
lsst::afw::geom::Point2D getPosition(lsst::afw::geom::AngleUnit unit=lsst::afw::geom::degrees) const
Return our contents in a Point2D object.
lsst::afw::geom::Angle getBeta() const
virtual Fk5Coord toFk5() const
Convert ourself from Ecliptic to Fk5 (use current epoch)
lsst::afw::geom::Angle getRa() const
lsst::afw::geom::Angle getLongitude() const
The main access method for the longitudinal coordinate.
lsst::afw::geom::Angle offset(lsst::afw::geom::Angle const phi, lsst::afw::geom::Angle const arcLen)
offset our current coords along a great circle defined by an angle wrt a declination parallel ...
virtual GalacticCoord toGalactic() const
Convert ourself to Galactic: l, b.
AngleUnit constexpr degrees
constant with units of degrees
virtual void reset(lsst::afw::geom::Angle const longitude, lsst::afw::geom::Angle const latitude)
special reset() overload to make sure no epoch can be set
virtual Fk5Coord toFk5() const
Convert ourself from galactic to Fk5 (no epoch specified)
virtual Fk5Coord toFk5() const
Convert ourself to Fk5 (ie.
virtual std::string toString() const
Get string representation.
virtual Fk5Coord toFk5() const
Convert ourself to Fk5: RA, Dec (use current epoch)
virtual IcrsCoord toIcrs() const
Convert ourself to ICRS: RA, Dec (basically J2000)
A class used to convert scalar POD types such as double to Angle.
std::shared_ptr< Coord > convert(CoordSystem system, double epoch=2000) const
Convert to a specified Coord type at a specified epoch.
std::string getBetaStr() const
std::string getRaStr(lsst::afw::geom::AngleUnit unit) const
EclipticCoord precess(double const epochTo) const
precess to new epoch
virtual TopocentricCoord toTopocentric() const
Convert ourself from Topocentric to Topocentric with no observatory or date arguments.
virtual std::string getClassName() const
PYBIND11_PLUGIN(_observatory)
virtual std::string getClassName() const
std::string getAzimuthStr(lsst::afw::geom::AngleUnit unit) const
virtual std::pair< std::string, std::string > getCoordNames() const
virtual std::string getClassName() const
A class representing an angle.
A class to handle topocentric (AltAz) coordinates (inherits from Coord)
void rotate(Coord const &axis, lsst::afw::geom::Angle const theta)
Rotate our current coords about a pole.
lsst::afw::geom::Angle angularSeparation(Coord const &c) const
compute the angular separation between two Coords
virtual std::shared_ptr< Coord > clone() const
std::string getRaStr(lsst::afw::geom::AngleUnit unit) const
virtual std::pair< std::string, std::string > getCoordNames() const
std::string getDecStr() const
PYBIND11_DECLARE_HOLDER_TYPE(MyCoordType, std::shared_ptr< MyCoordType >)
virtual GalacticCoord toGalactic() const
Convert ourself from Galactic to Galactic ...
std::string getBStr() const
virtual std::string getClassName() const
virtual std::shared_ptr< Coord > clone() const
virtual std::shared_ptr< Coord > clone() const
virtual CoordSystem getCoordSystem() const
lsst::afw::geom::Angle getB() const
lsst::afw::geom::Point3D getVector() const
Return our contents in a position vector.
Fk5Coord precess(double const epochTo) const
Precess ourselves from whence we are to a new epoch.
A class to handle Fk5 coordinates (inherits from Coord)
A class to handle Ecliptic coordinates (inherits from Coord)
Observatory getObservatory() const
virtual void reset(lsst::afw::geom::Angle const longitude, lsst::afw::geom::Angle const latitude)
virtual std::pair< std::string, std::string > getCoordNames() const
std::string getLatitudeStr() const
Allow quick access to the longitude coordinate as a string.
virtual IcrsCoord toIcrs() const
Convert ourself to ICRS: RA, Dec (basically J2000)
std::string getDecStr() const
std::shared_ptr< Coord > averageCoord(std::vector< std::shared_ptr< Coord const >> const coords, CoordSystem system=UNKNOWN)
Return average of a list of coordinates.
std::pair< lsst::afw::geom::Angle, lsst::afw::geom::Angle > getOffsetFrom(Coord const &c) const
Compute the offset from a coordinate.
lsst::afw::geom::Angle getDec() const
CoordSystem makeCoordEnum(std::string const system)
A utility function to get the enum value of a coordinate system from a string name.
virtual std::string getClassName() const
virtual TopocentricCoord toTopocentric(Observatory const &obs, lsst::daf::base::DateTime const &obsDate) const
Convert ourself to Altitude/Azimuth: alt, az.
virtual CoordSystem getCoordSystem() const
virtual CoordSystem getCoordSystem() const
virtual IcrsCoord toIcrs() const
Icrs converter for IcrsCoord.
lsst::afw::geom::Angle getLatitude() const
The main access method for the latitudinal coordinate.
lsst::afw::geom::Angle getLambda() const
virtual std::shared_ptr< Coord > clone() const
virtual EclipticCoord toEcliptic() const
Convert ourself to Ecliptic: lambda, beta (use current epoch)
virtual CoordSystem getCoordSystem() const
lsst::afw::geom::Angle getRa() const
This is the base class for spherical coordinates.
std::string getLStr(lsst::afw::geom::AngleUnit unit) const
virtual std::shared_ptr< Coord > clone() const
A class to handle Icrs coordinates (inherits from Coord)
virtual std::pair< std::string, std::string > getCoordNames() const
lsst::afw::geom::Angle getDec() const
virtual EclipticCoord toEcliptic() const
Convert ourself to Ecliptic: lambda, beta (use existing epoch)
std::string getLambdaStr(lsst::afw::geom::AngleUnit unit) const
virtual CoordSystem getCoordSystem() const
virtual Fk5Coord toFk5() const
Fk5 converter for IcrsCoord.