369 std::list<Card> cards;
373 int bitpix = lsst::afw::fits::getBitPix<typename ImageT::Pixel>();
375 cards.push_back(Card(
"BZERO", 32768.0,
""));
376 cards.push_back(Card(
"BSCALE", 1.0,
""));
378 }
else if (bitpix == 0) {
379 throw LSST_EXCEPT(lsst::pex::exceptions::RuntimeError,
"Unsupported image type");
384 std::string wcsName =
"A";
385 cards.push_back(Card(str(
boost::format(
"CRVAL1%s") % wcsName),
386 data.getX0(),
"(output) Column pixel of Reference Pixel"));
387 cards.push_back(Card(str(
boost::format(
"CRVAL2%s") % wcsName),
388 data.getY0(),
"(output) Row pixel of Reference Pixel"));
389 cards.push_back(Card(str(
boost::format(
"CRPIX1%s") % wcsName), 1.0,
390 "Column Pixel Coordinate of Reference"));
391 cards.push_back(Card(str(
boost::format(
"CRPIX2%s") % wcsName), 1.0,
"Row Pixel Coordinate of Reference"));
392 cards.push_back(Card(str(
boost::format(
"CTYPE1%s") % wcsName),
"LINEAR",
"Type of projection"));
393 cards.push_back(Card(str(
boost::format(
"CTYPE1%s") % wcsName),
"LINEAR",
"Type of projection"));
394 cards.push_back(Card(str(
boost::format(
"CUNIT1%s") % wcsName),
"PIXEL",
"Column unit"));
395 cards.push_back(Card(str(
boost::format(
"CUNIT2%s") % wcsName),
"PIXEL",
"Row unit"));
400 cards.push_back(Card(str(
boost::format(
"CRVAL1%s") % wcsName), 0,
401 "(output) Column pixel of Reference Pixel"));
402 cards.push_back(Card(str(
boost::format(
"CRVAL2%s") % wcsName), 0,
403 "(output) Row pixel of Reference Pixel"));
404 cards.push_back(Card(str(
boost::format(
"CRPIX1%s") % wcsName), 1.0,
405 "Column Pixel Coordinate of Reference"));
406 cards.push_back(Card(str(
boost::format(
"CRPIX2%s") % wcsName), 1.0,
"Row Pixel Coordinate of Reference"));
407 cards.push_back(Card(str(
boost::format(
"CTYPE1%s") % wcsName),
"LINEAR",
"Type of projection"));
408 cards.push_back(Card(str(
boost::format(
"CTYPE1%s") % wcsName),
"LINEAR",
"Type of projection"));
409 cards.push_back(Card(str(
boost::format(
"CUNIT1%s") % wcsName),
"PIXEL",
"Column unit"));
410 cards.push_back(Card(str(
boost::format(
"CUNIT2%s") % wcsName),
"PIXEL",
"Row unit"));
413 cards.push_back(Card(
"OBJECT", title,
"Image being displayed"));
419 typedef std::vector<std::string> NameList;
422 newWcs->shiftReferencePixel(-data.getX0(), -data.getY0());
426 NameList paramNames = metadata->paramNames();
428 for (NameList::const_iterator i = paramNames.begin(), end = paramNames.end(); i != end; ++i) {
429 if (*i ==
"SIMPLE" ||
440 std::type_info
const &type = metadata->typeOf(*i);
441 if (type ==
typeid(
bool)) {
442 cards.push_back(Card(*i, metadata->get<
bool>(*i)));
443 }
else if (type ==
typeid(
int)) {
444 cards.push_back(Card(*i, metadata->get<
int>(*i)));
445 }
else if (type ==
typeid(
float)) {
446 cards.push_back(Card(*i, metadata->get<
float>(*i)));
447 }
else if (type ==
typeid(
double)) {
448 cards.push_back(Card(*i, metadata->get<
double>(*i)));
450 cards.push_back(Card(*i, metadata->get<std::string>(*i)));
459 naxes[0] = data.getWidth();
460 naxes[1] = data.getHeight();
462 write_fits_hdr(fd, bitpix, naxis, naxes, cards, 1);
463 for (
int y = 0;
y != data.getHeight(); ++
y) {
464 if (write_fits_data(fd, bitpix, (
char *)(data.row_begin(
y)), (
char *)(data.row_end(
y))) < 0){
465 throw LSST_EXCEPT(lsst::pex::exceptions::RuntimeError,
470 pad_to_fits_record(fd, data.getWidth()*data.getHeight(), bitpix);
boost::shared_ptr< Wcs > Ptr
boost::shared_ptr< PropertySet > Ptr
virtual Ptr clone(void) const
Implementation of the WCS standard for a any projection.
#define LSST_EXCEPT(type,...)