45template <
typename ImageT,
typename MaskT,
typename VarianceT>
48 : _maskedImage(width, height), _info(new
ExposureInfo(wcs)) {}
50template <
typename ImageT,
typename MaskT,
typename VarianceT>
53 : _maskedImage(dimensions), _info(new
ExposureInfo(wcs)) {}
55template <
typename ImageT,
typename MaskT,
typename VarianceT>
60template <
typename ImageT,
typename MaskT,
typename VarianceT>
63 : _maskedImage(maskedImage), _info(new
ExposureInfo(wcs)) {}
65template <
typename ImageT,
typename MaskT,
typename VarianceT>
67 : _maskedImage(maskedImage), _info(info ? info :
std::make_shared<
ExposureInfo>()) {}
69template <
typename ImageT,
typename MaskT,
typename VarianceT>
73template <
typename ImageT,
typename MaskT,
typename VarianceT>
76template <
typename ImageT,
typename MaskT,
typename VarianceT>
82template <
typename ImageT,
typename MaskT,
typename VarianceT>
84 ImageOrigin origin,
bool conformMasks,
bool allowUnsafe)
87 *
this = reader.
read<ImageT, MaskT, VarianceT>(bbox, origin, conformMasks, allowUnsafe);
90template <
typename ImageT,
typename MaskT,
typename VarianceT>
92 ImageOrigin origin,
bool conformMasks,
bool allowUnsafe)
95 *
this = reader.
read<ImageT, MaskT, VarianceT>(bbox, origin, conformMasks, allowUnsafe);
98template <
typename ImageT,
typename MaskT,
typename VarianceT>
100 ImageOrigin origin,
bool conformMasks,
bool allowUnsafe) {
102 *
this = reader.
read<ImageT, MaskT, VarianceT>(bbox, origin, conformMasks, allowUnsafe);
105template <
typename ImageT,
typename MaskT,
typename VarianceT>
110template <
typename ImageT,
typename MaskT,
typename VarianceT>
112 _maskedImage = maskedImage;
115template <
typename ImageT,
typename MaskT,
typename VarianceT>
118 if (_info->hasWcs()) {
120 auto newWcs = _info->getWcs()->copyAtShiftedPixelOrigin(shift);
121 _info->setWcs(newWcs);
123 _maskedImage.setXY0(origin);
126template <
typename ImageT,
typename MaskT,
typename VarianceT>
128template <
typename ImageT,
typename MaskT,
typename VarianceT>
133template <
typename ImageT,
typename MaskT,
typename VarianceT>
139 writeFits(fitsfile, imageOptions, maskOptions, varianceOptions);
142template <
typename ImageT,
typename MaskT,
typename VarianceT>
148 writeFits(fitsfile, imageOptions, maskOptions, varianceOptions);
151template <
typename ImageT,
typename MaskT,
typename VarianceT>
156 ExposureInfo::FitsWriteData data = _info->_startWriteFits(
getBBox());
157 _maskedImage.writeFits(fitsfile, imageOptions, maskOptions, varianceOptions, data.metadata,
158 data.imageMetadata, data.maskMetadata, data.varianceMetadata);
159 _info->_finishWriteFits(fitsfile, data);
171template <
class ExposureT>
172void _copyCommonPixels(ExposureT &destination, ExposureT
const &source) {
174 overlapBox.
clip(source.getBBox());
178 typename ExposureT::MaskedImageT overlapPixels(source.getMaskedImage(), overlapBox);
179 destination.getMaskedImage().assign(overlapPixels, overlapBox);
184template <
typename ImageT,
typename MaskT,
typename VarianceT>
195template <
typename ImageT,
typename MaskT,
typename VarianceT>
200 buffer <<
"Point " << center <<
" lies at pixel " << center <<
", which lies outside Exposure "
204 if (size[0] <= 0 || size[1] <= 0) {
206 buffer <<
"Cannot create bounding box with dimensions " << size;
218 _copyCommonPixels(cutout, *
this);
222template <
typename ImageT,
typename MaskT,
typename VarianceT>
#define LSST_EXCEPT(type,...)
A simple struct that combines the two arguments that must be passed to most cfitsio routines and cont...
Lifetime-management for memory that goes into FITS memory files.
A FITS reader class for Exposures and their components.
Exposure< ImagePixelT, MaskPixelT, VariancePixelT > read(lsst::geom::Box2I const &bbox=lsst::geom::Box2I(), ImageOrigin origin=PARENT, bool conformMasks=false, bool allowUnsafe=false)
Read the full Exposure.
A class to contain the data, WCS, and other information needed to describe an image of the sky.
MaskedImageT getMaskedImage()
Return the MaskedImage.
bool hasWcs() const
Does this Exposure have a Wcs?
Exposure getCutout(lsst::geom::SpherePoint const ¢er, lsst::geom::Extent2I const &size) const
Return an Exposure that is a small cutout of the original.
std::shared_ptr< ExposureInfo > getInfo()
Get the ExposureInfo that aggregates all the non-image components. Never null.
void writeFits(std::string const &fileName, fits::CompressionOptions const *imageOptions=nullptr, fits::CompressionOptions const *maskOptions=nullptr, fits::CompressionOptions const *varianceOptions=nullptr) const
Write an Exposure to a regular multi-extension FITS file.
Exposure(unsigned int width, unsigned int height, std::shared_ptr< geom::SkyWcs const > wcs=std::shared_ptr< geom::SkyWcs const >())
Construct an Exposure with a blank MaskedImage of specified size (default 0x0) and a SkyWcs (which ma...
std::shared_ptr< geom::SkyWcs const > getWcs() const
Exposure & operator=(Exposure const &)
void setXY0(lsst::geom::Point2I const &origin)
Set the Exposure's origin (including correcting the Wcs)
void setMaskedImage(MaskedImageT &maskedImage)
Set the MaskedImage of the Exposure.
MaskedImage< ImageT, MaskT, VarianceT > MaskedImageT
lsst::geom::Box2I getBBox(ImageOrigin const origin=PARENT) const
A collection of all the things that make an Exposure different from a MaskedImage.
void clip(Box2I const &other) noexcept
bool isEmpty() const noexcept
static Box2I makeCenteredBox(Point2D const ¢er, Extent const &size)
Extent2I const getDimensions() const noexcept
Point2D const getCenter() const noexcept
ImageT::SinglePixel edgePixel(lsst::afw::image::detail::Image_tag)
Return an off-the-edge pixel appropriate for a given Image type.
Extent< double, 2 > Extent2D
Point< double, 2 > Point2D
Extent< int, 2 > Extent2I
Options controlling image compression with FITS.
typename ImageT::image_category image_category