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) {
41 auto metadata = _metadata;
42 auto modifyable =
false;
45 if (metadata->exists(
"CTYPE1") && metadata->exists(
"CTYPE2")) {
46 ctype1 = metadata->getAsString(
"CTYPE1");
47 ctype2 = metadata->getAsString(
"CTYPE2");
49 LOGL_DEBUG(
"makeWcs",
"Unable to construct valid WCS due to missing CTYPE1 or CTYPE2");
50 return std::shared_ptr<Wcs>();
59 if (ctype1.substr(5, 3) ==
"TAN" && (metadata->exists(
"PV1_5") || metadata->exists(
"PV2_1"))) {
60 LOGL_INFO(
"makeWcs",
"Interpreting %s/%s + PVi_j as TPV", ctype1.c_str(), ctype2.c_str());
63 metadata = _metadata->deepCopy();
67 ctype1.replace(5, 3,
"TPV");
68 metadata->set<std::string>(
"CTYPE1",
ctype1);
70 ctype2.replace(5, 3,
"TPV");
71 metadata->set<std::string>(
"CTYPE2",
ctype2);
74 std::shared_ptr<Wcs> wcs;
75 if (ctype1.substr(5, 3) ==
"TAN") {
76 wcs = std::shared_ptr<Wcs>(
new TanWcs(metadata));
77 }
else if (ctype1.substr(5, 3) ==
"TPV") {
79 metadata = _metadata->deepCopy();
83 LOGL_WARN(
"makeWcs",
"Stripping PVi_j keys from projection %s/%s", ctype1.c_str(), ctype2.c_str());
85 metadata->set<std::string>(
"CTYPE1",
"RA---TAN");
86 metadata->set<std::string>(
"CTYPE2",
"DEC--TAN");
87 metadata->set<
bool>(
"TPV_WCS",
true);
94 for (
int i = 0; i != 2; ++i) {
95 for (
int j = 1; j <= 39; ++j) {
97 sprintf(pvName,
"PV%d_%d", i, j);
98 if (metadata->exists(pvName)) {
99 metadata->remove(pvName);
104 wcs = std::shared_ptr<Wcs>(
new TanWcs(metadata));
106 wcs = std::shared_ptr<Wcs>(
new Wcs(metadata));
111 std::string key =
"LTV1";
112 if (metadata->exists(key)) {
113 wcs->shiftReferencePixel(-metadata->getAsDouble(key), 0);
117 if (metadata->exists(key)) {
118 wcs->shiftReferencePixel(0, -metadata->getAsDouble(key));
129 double CD21,
double CD22) {
131 CD << CD11, CD12, CD21, CD22;
135 return std::shared_ptr<Wcs>(
new TanWcs(crvalTmp, crpix, CD));
lsst::afw::geom::Angle getLongitude() const
The main access method for the longitudinal coordinate.
int stripWcsKeywords(std::shared_ptr< lsst::daf::base::PropertySet > const &metadata, std::shared_ptr< Wcs const > const &wcs)
table::PointKey< double > crval
virtual IcrsCoord toIcrs() const
Convert ourself to ICRS: RA, Dec (basically J2000)
Implementation of the WCS standard for a any projection.
table::Key< std::string > ctype2
lsst::afw::geom::Angle getLatitude() const
The main access method for the latitudinal coordinate.
A base class for image defects.
Implementation of the WCS standard for the special case of the Gnomonic (tangent plane) projection...
constexpr double asDegrees() const noexcept
Return an Angle's value in degrees.
This is the base class for spherical coordinates.
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::Key< std::string > ctype1
table::PointKey< double > crpix