24#include "pybind11/pybind11.h"
26#include "pybind11/eigen.h"
32#include "pybind11/stl.h"
33#include "ndarray/pybind11.h"
42using namespace py::literals;
49void declareSkyWcs(lsst::utils::python::WrapperCollection &wrappers) {
50 wrappers.wrap([](
auto &mod) {
53 mod.def(
"makeFlippedWcs",
makeFlippedWcs,
"wcs"_a,
"flipLR"_a,
"flipTB"_a,
"center"_a);
54 mod.def(
"makeModifiedWcs",
makeModifiedWcs,
"pixelTransform"_a,
"wcs"_a,
"modifyActualPixels"_a);
58 "crpix"_a,
"crval"_a,
"cdMatrix"_a,
"projection"_a =
"TAN");
60 "metadata"_a,
"strip"_a =
false);
64 "pixelsToFieldAngle"_a,
"orientation"_a,
"flipX"_a,
"boresight"_a,
"projection"_a =
"TAN");
65 mod.def(
"makeTanSipWcs",
67 Eigen::Matrix2d
const &, Eigen::MatrixXd
const &,
69 "crpix"_a,
"crval"_a,
"cdMatrix"_a,
"sipA"_a,
"sipB"_a);
70 mod.def(
"makeTanSipWcs",
72 Eigen::Matrix2d
const &, Eigen::MatrixXd
const &,
73 Eigen::MatrixXd
const &, Eigen::MatrixXd
const &,
75 "crpix"_a,
"crval"_a,
"cdMatrix"_a,
"sipA"_a,
"sipB"_a,
"sipAp"_a,
"sipBp"_a);
84 [](
auto &mod,
auto &cls) {
85 cls.def(py::init<daf::base::PropertySet &, bool>(),
"metadata"_a,
"strip"_a = false);
86 cls.def(py::init<ast::FrameDict const &>(),
"frameDict"_a);
88 cls.def(
"__eq__", &SkyWcs::operator==, py::is_operator());
89 cls.def(
"__ne__", &SkyWcs::operator!=, py::is_operator());
91 table::io::python::addPersistableMethods<SkyWcs>(cls);
93 cls.def(
"copyAtShiftedPixelOrigin", &SkyWcs::copyAtShiftedPixelOrigin,
"shift"_a);
94 cls.def(
"getFitsMetadata", &SkyWcs::getFitsMetadata,
"precise"_a = false);
95 cls.def(
"getPixelScale",
96 (lsst::geom::Angle(SkyWcs::*)(lsst::geom::Point2D const &) const) &
97 SkyWcs::getPixelScale,
99 cls.def(
"getPixelScale", (lsst::geom::Angle(SkyWcs::*)() const) & SkyWcs::getPixelScale);
100 cls.def(
"getPixelOrigin", &SkyWcs::getPixelOrigin);
101 cls.def(
"getSkyOrigin", &SkyWcs::getSkyOrigin);
102 cls.def(
"getCdMatrix",
103 (Eigen::Matrix2d(SkyWcs::*)(lsst::geom::Point2D const &) const) & SkyWcs::getCdMatrix,
105 cls.def(
"getCdMatrix", (Eigen::Matrix2d(SkyWcs::*)() const) & SkyWcs::getCdMatrix);
106 cls.def(
"getTanWcs", &SkyWcs::getTanWcs,
"pixel"_a);
107 cls.def(
"getFrameDict", [](SkyWcs const &self) { return self.getFrameDict()->copy(); });
112 cls.def(
"linearizePixelToSky",
116 "coord"_a,
"skyUnit"_a);
117 cls.def(
"linearizePixelToSky",
121 "coord"_a,
"skyUnit"_a);
122 cls.def(
"linearizeSkyToPixel",
126 "coord"_a,
"skyUnit"_a);
127 cls.def(
"linearizeSkyToPixel",
131 "coord"_a,
"skyUnit"_a);
132 cls.def(
"pixelToSky",
136 cls.def(
"pixelToSky",
139 cls.def(
"pixelToSky",
144 cls.def(
"skyToPixel",
148 cls.def(
"skyToPixel",
165void wrapSkyWcs(lsst::utils::python::WrapperCollection &wrappers) {
166 wrappers.addInheritanceDependency(
"lsst.afw.table.io");
167 wrappers.addInheritanceDependency(
"lsst.afw.typehandling");
168 wrappers.addSignatureDependency(
"astshim");
169 declareSkyWcs(wrappers);
std::string writeString() const
Serialize this SkyWcs to a string, using the same format as writeStream.
lsst::geom::SpherePoint pixelToSky(lsst::geom::Point2D const &pixel) const
Compute sky position(s) from pixel position(s)
static std::shared_ptr< SkyWcs > readString(std::string &str)
Deserialize a SkyWcs from a string, using the same format as readStream.
lsst::geom::AffineTransform linearizePixelToSky(lsst::geom::SpherePoint const &coord, lsst::geom::AngleUnit const &skyUnit) const
Return the local linear approximation to pixelToSky at a point given in sky coordinates.
lsst::geom::AffineTransform linearizeSkyToPixel(lsst::geom::SpherePoint const &coord, lsst::geom::AngleUnit const &skyUnit) const
Return the local linear approximation to skyToPixel at a point given in sky coordinates.
std::shared_ptr< const TransformPoint2ToSpherePoint > getTransform() const
Get a TransformPoint2ToSpherePoint that transforms pixels to sky in the forward direction and sky to ...
lsst::geom::Point2D skyToPixel(lsst::geom::SpherePoint const &sky) const
Compute pixel position(s) from sky position(s)
bool isFlipped() const
Does the WCS follow the convention of North=Up, East=Left?
bool isFits() const
Return true getFitsMetadata(true) will succeed, false if not.
A class representing an angle.
A class used to convert scalar POD types such as double to Angle.
Point in an unspecified spherical coordinate system.
std::shared_ptr< SkyWcs > makeSkyWcs(daf::base::PropertySet &metadata, bool strip=false)
Construct a SkyWcs from FITS keywords.
std::shared_ptr< TransformPoint2ToPoint2 > getPixelToIntermediateWorldCoords(SkyWcs const &wcs, bool simplify=true)
Return a transform from pixel coordinates to intermediate world coordinates.
std::shared_ptr< SkyWcs > makeTanSipWcs(lsst::geom::Point2D const &crpix, lsst::geom::SpherePoint const &crval, Eigen::Matrix2d const &cdMatrix, Eigen::MatrixXd const &sipA, Eigen::MatrixXd const &sipB)
Construct a TAN-SIP SkyWcs with forward SIP distortion terms and an iterative inverse.
Eigen::Matrix2d makeCdMatrix(lsst::geom::Angle const &scale, lsst::geom::Angle const &orientation=0 *lsst::geom::degrees, bool flipX=false)
Make a WCS CD matrix.
std::shared_ptr< TransformPoint2ToSpherePoint > getIntermediateWorldCoordsToSky(SkyWcs const &wcs, bool simplify=true)
Return a transform from intermediate world coordinates to sky.
std::shared_ptr< SkyWcs > makeModifiedWcs(TransformPoint2ToPoint2 const &pixelTransform, SkyWcs const &wcs, bool modifyActualPixels)
Create a new SkyWcs whose pixels are transformed by pixelTransform, as described below.
void wrapSkyWcs(lsst::utils::python::WrapperCollection &)
std::shared_ptr< TransformPoint2ToPoint2 > makeWcsPairTransform(SkyWcs const &src, SkyWcs const &dst)
A Transform obtained by putting two SkyWcs objects "back to back".
Transform< Point2Endpoint, Point2Endpoint > TransformPoint2ToPoint2
std::shared_ptr< SkyWcs > makeFlippedWcs(SkyWcs const &wcs, bool flipLR, bool flipTB, lsst::geom::Point2D const ¢er)
Return a copy of a FITS-WCS with pixel positions flipped around a specified center.
void addOutputOp(PyClass &cls, std::string const &method)
Add __str__ or __repr__ method implemented by operator<<.
constexpr AngleUnit degrees
constant with units of degrees
A base class for image defects.