24 #ifndef LSST_AFW_IMAGE_fits_io_h_INCLUDED
25 #define LSST_AFW_IMAGE_fits_io_h_INCLUDED
29 #include "boost/format.hpp"
36 namespace lsst {
namespace afw {
namespace image {
38 template <
typename PixelT>
51 "Incorrect image type for FITS image"
58 }
else if (nAxis == 3) {
63 boost::str(
boost::format(
"3rd dimension %d is not 1") % shape3[0])
66 shape = shape3.
last<2>();
77 if (!bbox.isEmpty()) {
79 bbox.shift(-xyOffset);
83 if (bbox.getMinX() < 0 || bbox.getMinY() < 0 ||
84 bbox.getWidth() > dimensions.getX() || bbox.getHeight() > dimensions.getY()
87 lsst::pex::exceptions::LengthError,
88 (
boost::format(
"BBox (%d,%d) %dx%d doesn't fit in image %dx%d") %
89 bbox.getMinX() % bbox.getMinY() % bbox.getWidth() % bbox.getHeight() %
90 dimensions.getX() % dimensions.getY()).str()
93 dimensions = bbox.getDimensions();
103 template <
typename ImageT>
108 fitsfile.
createImage<
typename ImageT::Pixel>(image.getArray().getShape());
117 #endif // !LSST_AFW_IMAGE_fits_io_h_INCLUDED
geom::Point2I getImageXY0FromMetadata(std::string const &wcsName, lsst::daf::base::PropertySet *metadata)
An include file to include the header files for lsst::afw::geom.
void readMetadata(daf::base::PropertySet &metadata, bool strip=false)
Read a FITS header into a PropertySet or PropertyList.
A simple struct that combines the two arguments that must be passed to most cfitsio routines and cont...
void writeImage(ndarray::Array< T const, N, C > const &array)
Write an ndarray::Array to a FITS image HDU.
An integer coordinate rectangle.
table::Key< table::Array< Kernel::Pixel > > image
afw::table::PointKey< int > dimensions
A fixed-size 1D array class.
Vector< T, M > last() const
Create a new Vector from the last M elements of this.
Vector< T, N > makeVector(T v1, T v2,..., T vN)
Variadic constructor for Vector.
void fits_read_array(fits::Fits &fitsfile, ndarray::Array< PixelT, 2, 2 > &array, geom::Point2I &xy0, lsst::daf::base::PropertySet &metadata, geom::Box2I bbox=geom::Box2I(), ImageOrigin origin=PARENT)
int getImageDim()
Return the number of dimensions in the current HDU.
detail::SimpleInitializer< N > allocate(Vector< int, N > const &shape)
Create an expression that allocates uninitialized memory for an array.
#define LSST_EXCEPT(type,...)
A multidimensional strided array.
bool checkImageType()
Return true if the current HDU has the given pixel type..
ndarray::Vector< int, N > getImageShape()
Return the shape of the current (image) HDU.
Class for storing generic metadata.
void readImage(ndarray::Array< T, N, N > const &array, ndarray::Vector< int, N > const &offset)
Read an array from a FITS image.
#define LSST_FITS_EXCEPT(type, fitsObj,...)
Extent< int, 2 > Extent2I
void writeMetadata(daf::base::PropertySet const &metadata)
Read a FITS header into a PropertySet or PropertyList.
void fits_write_image(fits::Fits &fitsfile, const ImageT &image, boost::shared_ptr< daf::base::PropertySet const > metadata=boost::shared_ptr< daf::base::PropertySet const >())
std::string const wcsNameForXY0
void createImage(ndarray::Vector< int, N > const &shape)
Create an image with pixel type provided by the given explicit PixelT template parameter and shape de...
Include files required for standard LSST Exception handling.