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" 40 struct found_type :
public std::exception {};
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;
96 boost::mpl::for_each<supported_fits_types>(
97 try_fits_read_array<ImageT, found_type>(fitsfile, array, xy0, metadata, bbox, origin));
98 }
catch (found_type&) {
99 img = ImageT(array,
false, xy0);
105 template <
typename supported_fits_types,
typename ImageT>
107 std::shared_ptr<lsst::daf::base::PropertySet> metadata =
108 std::shared_ptr<lsst::daf::base::PropertySet>(),
111 fits_read_image<supported_fits_types, ImageT>(fitsfile, img, (metadata ? *metadata : metadata_s), bbox,
117 #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.
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)
void fits_read_image(fits::Fits &fitsfile, ImageT &img, lsst::daf::base::PropertySet &metadata, geom::Box2I const &bbox=geom::Box2I(), ImageOrigin const origin=PARENT)
lsst::daf::base::PropertySet PropertySet
#define LSST_FITS_EXCEPT(type, fitsObj,...)
A FITS-related replacement for LSST_EXCEPT that takes an additional Fits object and uses makeErrorMes...