52 wcsMetaData->set(
"CTYPE1" + wcsName,
"LINEAR",
"Type of projection");
53 wcsMetaData->set(
"CTYPE2" + wcsName,
"LINEAR",
"Type of projection");
54 wcsMetaData->set(
"CRPIX1" + wcsName,
static_cast<double>(1),
"Column Pixel Coordinate of Reference");
55 wcsMetaData->set(
"CRPIX2" + wcsName,
static_cast<double>(1),
"Row Pixel Coordinate of Reference");
56 wcsMetaData->set(
"CRVAL1" + wcsName,
static_cast<double>(xy0[0]),
"Column pixel of Reference Pixel");
57 wcsMetaData->set(
"CRVAL2" + wcsName,
static_cast<double>(xy0[1]),
"Row pixel of Reference Pixel");
58 wcsMetaData->set(
"CUNIT1" + wcsName,
"PIXEL",
"Column unit");
59 wcsMetaData->set(
"CUNIT2" + wcsName,
"PIXEL",
"Row unit");
66 "CTYPE2",
"CUNIT1",
"CUNIT2",
"CD1_1",
"CD1_2",
67 "CD2_1",
"CD2_2",
"WCSAXES"};
68 for (
auto const&
name : names) {
76 Eigen::Matrix2d matrix;
78 for (
int i = 0; i < 2; ++i) {
79 for (
int j = 0; j < 2; ++j) {
81 if (metadata.
exists(cardName)) {
100 if (metadata.
exists(
"CRPIX1" + wcsName) && metadata.
exists(
"CRPIX2" + wcsName) &&
101 metadata.
exists(
"CRVAL1" + wcsName) && metadata.
exists(
"CRVAL2" + wcsName) &&
102 (metadata.
getAsDouble(
"CRPIX1" + wcsName) == 1.0) &&
103 (metadata.
getAsDouble(
"CRPIX2" + wcsName) == 1.0)) {
115 if (!metadata.
exists(cardName)) {
117 "metadata does not contain SIP matrix " +
name +
": " + cardName +
" not found");
125 auto const coeffName =
name +
"_";
126 for (
int i = 0; i <=
order; ++i) {
127 for (
int j = 0; j <=
order; ++j) {
128 std::string const cardName = getSipCoeffCardName(coeffName, i, j);
129 if (metadata.
exists(cardName)) {
141 if (!metadata.
exists(cardName)) {
144 return metadata.
getAsInt(cardName) >= 0;
149 if (matrix.rows() != matrix.cols() || matrix.rows() < 1) {
151 "Matrix must be square and at least 1 x 1; dimensions = " +
154 int const order = matrix.rows() - 1;
155 auto metadata = std::make_shared<daf::base::PropertyList>();
157 metadata->set(cardName,
order);
158 auto const coeffName =
name +
"_";
159 for (
int i = 0; i <=
order; ++i) {
160 for (
int j = 0; j <=
order; ++j) {
161 if (matrix(i, j) != 0.0) {
162 metadata->set(getSipCoeffCardName(coeffName, i, j), matrix(i, j));
171 Eigen::Matrix2d
const& cdMatrix,
173 auto pl = std::make_shared<daf::base::PropertyList>();
174 pl->add(
"RADESYS",
"ICRS");
175 pl->add(
"CTYPE1",
"RA---" + projection);
176 pl->add(
"CTYPE2",
"DEC--" + projection);
177 pl->add(
"CRPIX1",
crpix[0] + 1);
178 pl->add(
"CRPIX2",
crpix[1] + 1);
179 pl->add(
"CRVAL1",
crval[0].asDegrees());
180 pl->add(
"CRVAL2",
crval[1].asDegrees());
181 pl->add(
"CUNIT1",
"deg");
182 pl->add(
"CUNIT2",
"deg");
183 for (
int i = 0; i < 2; ++i) {
184 for (
int j = 0; j < 2; ++j) {
185 if (cdMatrix(i, j) != 0.0) {
187 pl->add(
name, cdMatrix(i, j));
196 Eigen::Matrix2d
const& cdMatrix,
197 Eigen::MatrixXd
const& sipA,
198 Eigen::MatrixXd
const& sipB) {
207 Eigen::Matrix2d
const& cdMatrix, Eigen::MatrixXd
const& sipA, Eigen::MatrixXd
const& sipB,
208 Eigen::MatrixXd
const& sipAp, Eigen::MatrixXd
const& sipBp) {
table::Key< std::string > name
#define LSST_EXCEPT(type,...)
table::PointKey< double > crpix
table::PointKey< double > crval
int getAsInt(std::string const &name) const
virtual void remove(std::string const &name)
bool exists(std::string const &name) const
double getAsDouble(std::string const &name) const
std::shared_ptr< daf::base::PropertyList > makeSimpleWcsMetadata(lsst::geom::Point2D const &crpix, lsst::geom::SpherePoint const &crval, Eigen::Matrix2d const &cdMatrix, std::string const &projection="TAN")
Make FITS metadata for a simple FITS WCS (one with no distortion).
Eigen::MatrixXd getSipMatrixFromMetadata(daf::base::PropertySet const &metadata, std::string const &name)
bool hasSipMatrix(daf::base::PropertySet const &metadata, std::string const &name)
std::shared_ptr< daf::base::PropertyList > makeTanSipMetadata(lsst::geom::Point2D const &crpix, lsst::geom::SpherePoint const &crval, Eigen::Matrix2d const &cdMatrix, Eigen::MatrixXd const &sipA, Eigen::MatrixXd const &sipB)
Make metadata for a TAN-SIP WCS without inverse matrices.
Eigen::Matrix2d getCdMatrixFromMetadata(daf::base::PropertySet &metadata)
Read a CD matrix from FITS WCS metadata.
std::shared_ptr< daf::base::PropertyList > createTrivialWcsMetadata(std::string const &wcsName, lsst::geom::Point2I const &xy0)
std::shared_ptr< daf::base::PropertyList > makeSipMatrixMetadata(Eigen::MatrixXd const &matrix, std::string const &name)
lsst::geom::Point2I getImageXY0FromMetadata(daf::base::PropertySet &metadata, std::string const &wcsName, bool strip=false)
void deleteBasicWcsMetadata(daf::base::PropertySet &metadata, std::string const &wcsName)