27 #include "lsst/log/Log.h"
31 namespace except = lsst::pex::exceptions;
37 std::shared_ptr<Wcs>
makeWcs(std::shared_ptr<daf::base::PropertySet>
const&
_metadata,
bool stripMetadata) {
42 auto modifyable =
false;
45 if (metadata->exists(
"CTYPE1") && metadata->exists(
"CTYPE2")) {
46 ctype1 = metadata->getAsString(
"CTYPE1");
47 ctype2 = metadata->getAsString(
"CTYPE2");
49 return std::shared_ptr<Wcs>();
58 if (ctype1.substr(5, 3) ==
"TAN" && (metadata->exists(
"PV1_5") || metadata->exists(
"PV2_1"))) {
59 LOGL_INFO(
"makeWcs",
"Interpreting %s/%s + PVi_j as TPV", ctype1.c_str(), ctype2.c_str());
62 metadata = _metadata->deepCopy();
66 ctype1.replace(5, 3,
"TPV");
67 metadata->set<std::string>(
"CTYPE1",
ctype1);
69 ctype2.replace(5, 3,
"TPV");
70 metadata->set<std::string>(
"CTYPE2",
ctype2);
73 std::shared_ptr<Wcs> wcs;
74 if (ctype1.substr(5, 3) ==
"TAN") {
75 wcs = std::shared_ptr<Wcs>(
new TanWcs(metadata));
76 }
else if (ctype1.substr(5, 3) ==
"TPV") {
78 metadata = _metadata->deepCopy();
82 LOGL_WARN(
"makeWcs",
"Stripping PVi_j keys from projection %s/%s", ctype1.c_str(), ctype2.c_str());
84 metadata->set<std::string>(
"CTYPE1",
"RA---TAN");
85 metadata->set<std::string>(
"CTYPE2",
"DEC--TAN");
86 metadata->set<
bool>(
"TPV_WCS",
true);
93 for (
int i = 0; i != 2; ++i) {
94 for (
int j = 1; j <= 39; ++j) {
96 sprintf(pvName,
"PV%d_%d", i, j);
97 if (metadata->exists(pvName)) {
98 metadata->remove(pvName);
103 wcs = std::shared_ptr<Wcs>(
new TanWcs(metadata));
105 wcs = std::shared_ptr<Wcs>(
new Wcs(metadata));
110 std::string key =
"LTV1";
111 if (metadata->exists(key)) {
112 wcs->shiftReferencePixel(-metadata->getAsDouble(key), 0);
116 if (metadata->exists(key)) {
117 wcs->shiftReferencePixel(0, -metadata->getAsDouble(key));
128 double CD21,
double CD22) {
130 CD << CD11, CD12, CD21, CD22;
134 return std::shared_ptr<Wcs>(
new TanWcs(crvalTmp, crpix, CD));
table::Key< std::string > ctype2
lsst::afw::geom::Angle getLongitude() const
The main access method for the longitudinal coordinate.
Implementation of the WCS standard for a any projection.
Implementation of the WCS standard for the special case of the Gnomonic (tangent plane) projection...
int stripWcsKeywords(std::shared_ptr< lsst::daf::base::PropertySet > const &metadata, std::shared_ptr< Wcs const > const &wcs)
virtual IcrsCoord toIcrs() const
Convert ourself to ICRS: RA, Dec (basically J2000)
table::PointKey< double > crval
table::Key< std::string > ctype1
lsst::afw::geom::Angle getLatitude() const
The main access method for the latitudinal coordinate.
constexpr double asDegrees() const noexcept
Return an Angle's value in degrees.
This is the base class for spherical coordinates.
daf::base::PropertySet & _metadata
std::shared_ptr< Wcs > makeWcs(std::shared_ptr< lsst::daf::base::PropertySet > const &fitsMetadata, bool stripMetadata=false)
Create a Wcs object from a fits header.
table::PointKey< double > crpix