24 #ifndef LSST_AFW_IMAGE_fits_io_mpl_h_INCLUDED 25 #define LSST_AFW_IMAGE_fits_io_mpl_h_INCLUDED 27 #include "boost/mpl/for_each.hpp" 28 #include "boost/mpl/vector.hpp" 42 template <
typename ImageT,
typename ExceptionT>
43 class try_fits_read_array {
45 try_fits_read_array(fits::Fits& fitsfile, ndarray::Array<typename ImageT::Pixel, 2, 2>& array,
48 : _fitsfile(&fitsfile),
56 void operator()(
typename ImageT::Pixel) {
60 }
catch (fits::FitsTypeError
const&) {
65 template <
typename OtherPixel>
66 void operator()(OtherPixel) {
68 ndarray::Array<OtherPixel, 2, 2> array;
71 _array = ndarray::allocate(array.getShape());
72 _array.deep() = array;
74 }
catch (fits::FitsTypeError
const&) {
80 fits::Fits* _fitsfile;
81 ndarray::Array<typename ImageT::Pixel, 2, 2>& _array;
84 geom::Box2I
const& _bbox;
90 template <
typename supported_fits_types,
typename ImageT>
93 ndarray::Array<typename ImageT::Pixel, 2, 2> array;
97 try_fits_read_array<ImageT, found_type> reader{fitsfile, array, xy0, metadata, bbox, origin};
98 reader.operator()(
typename ImageT::Pixel());
99 boost::mpl::for_each<supported_fits_types>(reader);
100 }
catch (found_type&) {
101 img = ImageT(array,
false, xy0);
107 template <
typename supported_fits_types,
typename ImageT>
113 fits_read_image<supported_fits_types, ImageT>(fitsfile, img, (metadata ? *metadata : metadata_s), bbox,
119 #endif // !LSST_AFW_IMAGE_fits_io_mpl_h_INCLUDED
A simple struct that combines the two arguments that must be passed to most cfitsio routines and cont...
An integer coordinate rectangle.
lsst::daf::base::PropertySet PropertySet
An exception thrown when problems are found when reading or writing FITS files.
A base class for image defects.
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)
bool checkCompressedImagePhu()
Go to the first image header in the FITS file.
void fits_read_image(fits::Fits &fitsfile, ImageT &img, lsst::daf::base::PropertySet &metadata, geom::Box2I const &bbox=geom::Box2I(), ImageOrigin const origin=PARENT)
#define LSST_FITS_EXCEPT(type, fitsObj,...)
A FITS-related replacement for LSST_EXCEPT that takes an additional Fits object and uses makeErrorMes...