LSSTApplications
20.0.0
LSSTDataManagementBasePackage
|
Go to the documentation of this file.
55 wcsMetaData->set(
"CTYPE1" + wcsName,
"LINEAR",
"Type of projection");
56 wcsMetaData->set(
"CTYPE2" + wcsName,
"LINEAR",
"Type of projection");
57 wcsMetaData->set(
"CRPIX1" + wcsName,
static_cast<double>(1),
"Column Pixel Coordinate of Reference");
58 wcsMetaData->set(
"CRPIX2" + wcsName,
static_cast<double>(1),
"Row Pixel Coordinate of Reference");
59 wcsMetaData->set(
"CRVAL1" + wcsName,
static_cast<double>(xy0[0]),
"Column pixel of Reference Pixel");
60 wcsMetaData->set(
"CRVAL2" + wcsName,
static_cast<double>(xy0[1]),
"Row pixel of Reference Pixel");
61 wcsMetaData->set(
"CUNIT1" + wcsName,
"PIXEL",
"Column unit");
62 wcsMetaData->set(
"CUNIT2" + wcsName,
"PIXEL",
"Row unit");
69 "CTYPE2",
"CUNIT1",
"CUNIT2",
"CD1_1",
"CD1_2",
70 "CD2_1",
"CD2_2",
"WCSAXES"};
71 for (
auto const&
name : names) {
79 Eigen::Matrix2d matrix;
81 for (
int i = 0; i < 2; ++i) {
82 for (
int j = 0; j < 2; ++j) {
84 if (metadata.
exists(cardName)) {
103 if (metadata.
exists(
"CRPIX1" + wcsName) && metadata.
exists(
"CRPIX2" + wcsName) &&
104 metadata.
exists(
"CRVAL1" + wcsName) && metadata.
exists(
"CRVAL2" + wcsName) &&
105 (metadata.
getAsDouble(
"CRPIX1" + wcsName) == 1.0) &&
106 (metadata.
getAsDouble(
"CRPIX2" + wcsName) == 1.0)) {
118 if (!metadata.
exists(cardName)) {
120 "metadata does not contain SIP matrix " +
name +
": " + cardName +
" not found");
122 int order = metadata.
getAsInt(cardName);
127 Eigen::MatrixXd matrix(order + 1, order + 1);
128 auto const coeffName =
name +
"_";
129 for (
int i = 0; i <= order; ++i) {
130 for (
int j = 0; j <= order; ++j) {
131 std::string const cardName = getSipCoeffCardName(coeffName, i, j);
132 if (metadata.
exists(cardName)) {
144 if (!metadata.
exists(cardName)) {
147 return metadata.
getAsInt(cardName) >= 0;
152 if (matrix.rows() != matrix.cols() || matrix.rows() < 1) {
154 "Matrix must be square and at least 1 x 1; dimensions = " +
157 int const order = matrix.rows() - 1;
158 auto metadata = std::make_shared<daf::base::PropertyList>();
160 metadata->set(cardName, order);
161 auto const coeffName =
name +
"_";
162 for (
int i = 0; i <= order; ++i) {
163 for (
int j = 0; j <= order; ++j) {
164 if (matrix(i, j) != 0.0) {
165 metadata->set(getSipCoeffCardName(coeffName, i, j), matrix(i, j));
174 Eigen::Matrix2d
const& cdMatrix,
176 auto pl = std::make_shared<daf::base::PropertyList>();
177 pl->add(
"RADESYS",
"ICRS");
178 pl->add(
"CTYPE1",
"RA---" + projection);
179 pl->add(
"CTYPE2",
"DEC--" + projection);
180 pl->add(
"CRPIX1",
crpix[0] + 1);
181 pl->add(
"CRPIX2",
crpix[1] + 1);
182 pl->add(
"CRVAL1",
crval[0].asDegrees());
183 pl->add(
"CRVAL2",
crval[1].asDegrees());
184 pl->add(
"CUNIT1",
"deg");
185 pl->add(
"CUNIT2",
"deg");
186 for (
int i = 0; i < 2; ++i) {
187 for (
int j = 0; j < 2; ++j) {
188 if (cdMatrix(i, j) != 0.0) {
190 pl->add(
name, cdMatrix(i, j));
199 Eigen::Matrix2d
const& cdMatrix,
200 Eigen::MatrixXd
const& sipA,
201 Eigen::MatrixXd
const& sipB) {
210 Eigen::Matrix2d
const& cdMatrix, Eigen::MatrixXd
const& sipA, Eigen::MatrixXd
const& sipB,
211 Eigen::MatrixXd
const& sipAp, Eigen::MatrixXd
const& sipBp) {
void deleteBasicWcsMetadata(daf::base::PropertySet &metadata, std::string const &wcsName)
int getAsInt(std::string const &name) const
Get the last value for a bool/char/short/int property name (possibly hierarchical).
Eigen::MatrixXd getSipMatrixFromMetadata(daf::base::PropertySet const &metadata, std::string const &name)
bool hasSipMatrix(daf::base::PropertySet const &metadata, std::string const &name)
Class for storing ordered metadata with comments.
bool exists(std::string const &name) const
Determine if a name (possibly hierarchical) exists.
table::PointKey< double > crval
std::shared_ptr< daf::base::PropertyList > createTrivialWcsMetadata(std::string const &wcsName, lsst::geom::Point2I const &xy0)
table::PointKey< double > crpix
A base class for image defects.
virtual void remove(std::string const &name)
Remove all values for a property name (possibly hierarchical).
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
double getAsDouble(std::string const &name) const
Get the last value for any arithmetic property name (possibly hierarchical).
Class for storing generic metadata.
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.
lsst::geom::Point2I getImageXY0FromMetadata(daf::base::PropertySet &metadata, std::string const &wcsName, bool strip=false)
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).
Reports errors from accepting an object of an unexpected or inappropriate type.
Point in an unspecified spherical coordinate system.
Eigen::Matrix2d getCdMatrixFromMetadata(daf::base::PropertySet &metadata)
Read a CD matrix from FITS WCS metadata.
std::shared_ptr< daf::base::PropertyList > makeSipMatrixMetadata(Eigen::MatrixXd const &matrix, std::string const &name)