LSSTApplications  19.0.0-14-gb0260a2+72efe9b372,20.0.0+7927753e06,20.0.0+8829bf0056,20.0.0+995114c5d2,20.0.0+b6f4b2abd1,20.0.0+bddc4f4cbe,20.0.0-1-g253301a+8829bf0056,20.0.0-1-g2b7511a+0d71a2d77f,20.0.0-1-g5b95a8c+7461dd0434,20.0.0-12-g321c96ea+23efe4bbff,20.0.0-16-gfab17e72e+fdf35455f6,20.0.0-2-g0070d88+ba3ffc8f0b,20.0.0-2-g4dae9ad+ee58a624b3,20.0.0-2-g61b8584+5d3db074ba,20.0.0-2-gb780d76+d529cf1a41,20.0.0-2-ged6426c+226a441f5f,20.0.0-2-gf072044+8829bf0056,20.0.0-2-gf1f7952+ee58a624b3,20.0.0-20-geae50cf+e37fec0aee,20.0.0-25-g3dcad98+544a109665,20.0.0-25-g5eafb0f+ee58a624b3,20.0.0-27-g64178ef+f1f297b00a,20.0.0-3-g4cc78c6+e0676b0dc8,20.0.0-3-g8f21e14+4fd2c12c9a,20.0.0-3-gbd60e8c+187b78b4b8,20.0.0-3-gbecbe05+48431fa087,20.0.0-38-ge4adf513+a12e1f8e37,20.0.0-4-g97dc21a+544a109665,20.0.0-4-gb4befbc+087873070b,20.0.0-4-gf910f65+5d3db074ba,20.0.0-5-gdfe0fee+199202a608,20.0.0-5-gfbfe500+d529cf1a41,20.0.0-6-g64f541c+d529cf1a41,20.0.0-6-g9a5b7a1+a1cd37312e,20.0.0-68-ga3f3dda+5fca18c6a4,20.0.0-9-g4aef684+e18322736b,w.2020.45
LSSTDataManagementBasePackage
Exposure.h
Go to the documentation of this file.
1 // -*- LSST-C++ -*- // fixed format comment for emacs
2 
3 /*
4  * LSST Data Management System
5  * Copyright 2008, 2009, 2010 LSST Corporation.
6  *
7  * This product includes software developed by the
8  * LSST Project (http://www.lsst.org/).
9  *
10  * This program is free software: you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation, either version 3 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the LSST License Statement and
21  * the GNU General Public License along with this program. If not,
22  * see <http://www.lsstcorp.org/LegalNotices/>.
23  */
24 
25 #ifndef LSST_AFW_IMAGE_EXPOSURE_H
26 #define LSST_AFW_IMAGE_EXPOSURE_H
27 
28 #include <memory>
29 
30 #include "lsst/base.h"
31 #include "lsst/daf/base.h"
34 #include "lsst/geom/Extent.h"
35 #include "lsst/geom/SpherePoint.h"
36 
37 namespace lsst {
38 namespace afw {
39 namespace image {
40 
70 template <typename ImageT, typename MaskT = lsst::afw::image::MaskPixel,
71  typename VarianceT = lsst::afw::image::VariancePixel>
72 class Exposure {
73 public:
75 
76  // Class Constructors and Destructor
84  explicit Exposure(unsigned int width, unsigned int height,
86 
95 
101  explicit Exposure(lsst::geom::Box2I const& bbox,
103 
109  explicit Exposure(MaskedImageT& maskedImage,
111 
120 
132  explicit Exposure(std::string const& fileName, lsst::geom::Box2I const& bbox = lsst::geom::Box2I(),
133  ImageOrigin origin = PARENT, bool conformMasks = false, bool allowUnsafe = false);
134 
147  ImageOrigin origin = PARENT, bool conformMasks = false, bool allowUnsafe = false);
148 
160  explicit Exposure(fits::Fits& fitsfile, lsst::geom::Box2I const& bbox = lsst::geom::Box2I(),
161  ImageOrigin origin = PARENT, bool conformMasks = false, bool allowUnsafe = false);
162 
168  Exposure(Exposure const& src, bool const deep = false);
169  Exposure(Exposure&& src);
170 
181  Exposure(Exposure const& src, lsst::geom::Box2I const& bbox, ImageOrigin const origin = PARENT,
182  bool const deep = false);
183 
188  template <typename OtherPixelT>
190  const bool deep
191  )
192  : _maskedImage(rhs.getMaskedImage(), deep), _info(new ExposureInfo(*rhs.getInfo(), deep)) {
193  if (not deep) {
195  "Exposure's converting copy constructor must make a deep copy");
196  }
197  }
198 
201 
216  return Exposure(*this, bbox, origin, false);
217  }
218 
221 
224  virtual ~Exposure();
225 
226  // Get Members
228  MaskedImageT getMaskedImage() { return _maskedImage; }
230  MaskedImageT getMaskedImage() const { return _maskedImage; }
231 
232  std::shared_ptr<geom::SkyWcs const> getWcs() const { return _info->getWcs(); }
233 
236  return _info->getDetector();
237  }
239  Filter getFilter() const { return _info->getFilter(); }
241  std::shared_ptr<lsst::daf::base::PropertySet> getMetadata() const { return _info->getMetadata(); }
242  void setMetadata(std::shared_ptr<lsst::daf::base::PropertySet> metadata) { _info->setMetadata(metadata); }
243 
245  int getWidth() const { return _maskedImage.getWidth(); }
247  int getHeight() const { return _maskedImage.getHeight(); }
249  lsst::geom::Extent2I getDimensions() const { return _maskedImage.getDimensions(); }
250 
256  int getX0() const { return _maskedImage.getX0(); }
262  int getY0() const { return _maskedImage.getY0(); }
263 
271  lsst::geom::Point2I getXY0() const { return _maskedImage.getXY0(); }
272 
273  lsst::geom::Box2I getBBox(ImageOrigin const origin = PARENT) const {
274  return _maskedImage.getBBox(origin);
275  }
284  void setXY0(lsst::geom::Point2I const& origin);
285 
286  // Set Members
289  void setMaskedImage(MaskedImageT& maskedImage);
290  void setWcs(std::shared_ptr<geom::SkyWcs> wcs) { _info->setWcs(wcs); }
293  _info->setDetector(detector);
294  }
296  void setFilter(Filter const& filter) { _info->setFilter(filter); }
297 
301  std::shared_ptr<PhotoCalib const> getPhotoCalib() const { return _info->getPhotoCalib(); }
302 
305 
307  std::shared_ptr<lsst::afw::detection::Psf const> getPsf() const { return _info->getPsf(); }
308 
310  bool hasPsf() const { return _info->hasPsf(); }
311 
313  bool hasWcs() const { return _info->hasWcs(); }
314 
317 
320 
322  void setInfo(std::shared_ptr<ExposureInfo> exposureInfo) { _info = exposureInfo; }
323 
338  void writeFits(std::string const& fileName) const;
339 
347  void writeFits(fits::MemFileManager& manager) const;
348 
356  void writeFits(fits::Fits& fitsfile) const;
357 
366  void writeFits(std::string const& fileName, fits::ImageWriteOptions const& imageOptions,
367  fits::ImageWriteOptions const& maskOptions,
368  fits::ImageWriteOptions const& varianceOptions) const;
369 
378  void writeFits(fits::MemFileManager& manager, fits::ImageWriteOptions const& imageOptions,
379  fits::ImageWriteOptions const& maskOptions,
380  fits::ImageWriteOptions const& varianceOptions) const;
381 
390  void writeFits(fits::Fits& fitsfile, fits::ImageWriteOptions const& imageOptions,
391  fits::ImageWriteOptions const& maskOptions,
392  fits::ImageWriteOptions const& varianceOptions) const;
393 
399  static Exposure readFits(std::string const& filename) {
400  return Exposure<ImageT, MaskT, VarianceT>(filename);
401  }
402 
409  return Exposure<ImageT, MaskT, VarianceT>(manager);
410  }
411 
428  Exposure getCutout(lsst::geom::SpherePoint const& center, lsst::geom::Extent2I const& size) const;
429 
430 private:
431  void _readFits(fits::Fits& fitsfile, lsst::geom::Box2I const& bbox, ImageOrigin origin,
432  bool conformMasks);
433 
434  MaskedImageT _maskedImage;
436 };
437 
441 template <typename ImagePixelT, typename MaskPixelT, typename VariancePixelT>
446 ) {
449 }
450 } // namespace image
451 } // namespace afw
452 } // namespace lsst
453 
454 #endif // LSST_AFW_IMAGE_EXPOSURE_H
lsst::afw::image
Backwards-compatibility support for depersisting the old Calib (FluxMag0/FluxMag0Err) objects.
Definition: imageAlgorithm.dox:1
lsst::afw::image::Exposure::getPsf
std::shared_ptr< lsst::afw::detection::Psf const > getPsf() const
Return the Exposure's Psf object.
Definition: Exposure.h:307
lsst::afw::image::Exposure::getHeight
int getHeight() const
Return the Exposure's height.
Definition: Exposure.h:247
lsst::log.log.logContinued.info
def info(fmt, *args)
Definition: logContinued.py:201
lsst::afw::image::Exposure::setPhotoCalib
void setPhotoCalib(std::shared_ptr< PhotoCalib const > photoCalib)
Set the Exposure's PhotoCalib object.
Definition: Exposure.h:299
std::string
STL class.
std::shared_ptr
STL class.
lsst::afw::image::Exposure::setXY0
void setXY0(lsst::geom::Point2I const &origin)
Set the Exposure's origin (including correcting the Wcs)
Definition: Exposure.cc:122
lsst.pipe.tasks.assembleCoadd.filter
filter
Definition: assembleCoadd.py:342
lsst::afw::image::Exposure::getPhotoCalib
std::shared_ptr< PhotoCalib const > getPhotoCalib() const
Return the Exposure's PhotoCalib object.
Definition: Exposure.h:301
lsst::afw::image::Exposure::readFits
static Exposure readFits(fits::MemFileManager &manager)
Read an Exposure from a FITS RAM file.
Definition: Exposure.h:408
lsst::afw::image::Exposure
A class to contain the data, WCS, and other information needed to describe an image of the sky.
Definition: Exposure.h:72
lsst::afw::image::Exposure::getFilter
Filter getFilter() const
Return the Exposure's filter.
Definition: Exposure.h:239
wcs
table::Key< table::Array< std::uint8_t > > wcs
Definition: SkyWcs.cc:71
lsst::afw::image::Exposure::operator[]
Exposure operator[](lsst::geom::Box2I const &bbox) const
Return a subimage corresponding to the given box (interpreted as PARENT coordinates).
Definition: Exposure.h:220
lsst::afw::fits::Fits
A simple struct that combines the two arguments that must be passed to most cfitsio routines and cont...
Definition: fits.h:297
MaskedImage.h
lsst::afw::image::Filter
Holds an integer identifier for an LSST filter.
Definition: Filter.h:141
psf
Key< int > psf
Definition: Exposure.cc:65
lsst::afw::image::Exposure::getDimensions
lsst::geom::Extent2I getDimensions() const
Return the Exposure's size.
Definition: Exposure.h:249
lsst::afw::image::makeExposure
std::shared_ptr< Exposure< ImagePixelT, MaskPixelT, VariancePixelT > > makeExposure(MaskedImage< ImagePixelT, MaskPixelT, VariancePixelT > &mimage, std::shared_ptr< geom::SkyWcs const > wcs=std::shared_ptr< geom::SkyWcs const >())
A function to return an Exposure of the correct type (cf.
Definition: Exposure.h:442
lsst::afw
Definition: imageAlgorithm.dox:1
lsst::afw::image::Exposure::getY0
int getY0() const
Return the Exposure's row-origin.
Definition: Exposure.h:262
lsst::afw::image::Exposure::hasPsf
bool hasPsf() const
Does this Exposure have a Psf?
Definition: Exposure.h:310
lsst::afw::image::MaskedImage::getBBox
lsst::geom::Box2I getBBox(ImageOrigin const origin=PARENT) const
Definition: MaskedImage.h:1086
lsst::afw::image::MaskedImage::getWidth
int getWidth() const
Return the number of columns in the image.
Definition: MaskedImage.h:1082
lsst::afw::fits::MemFileManager
Lifetime-management for memory that goes into FITS memory files.
Definition: fits.h:121
lsst::afw::image::Exposure::getInfo
std::shared_ptr< ExposureInfo > getInfo()
Get the ExposureInfo that aggregates all the non-image components. Never null.
Definition: Exposure.h:316
lsst::afw::image::MaskedImage::getHeight
int getHeight() const
Return the number of rows in the image.
Definition: MaskedImage.h:1084
lsst::afw::image::Exposure::getMaskedImage
MaskedImageT getMaskedImage()
Return the MaskedImage.
Definition: Exposure.h:228
lsst::afw::fits::ImageWriteOptions
Options for writing an image to FITS.
Definition: fits.h:219
lsst::afw::image::Exposure::writeFits
void writeFits(std::string const &fileName) const
Write an Exposure to a regular multi-extension FITS file.
Definition: Exposure.cc:140
src
std::shared_ptr< RecordT > src
Definition: Match.cc:48
lsst::afw::image::Exposure::getMaskedImage
MaskedImageT getMaskedImage() const
Return the MaskedImage.
Definition: Exposure.h:230
lsst::afw::image::MaskedImage::getY0
int getY0() const
Return the image's row-origin.
Definition: MaskedImage.h:1102
lsst::afw::image::MaskedImage::getXY0
lsst::geom::Point2I getXY0() const
Return the image's origin.
Definition: MaskedImage.h:1110
Extent.h
lsst::afw::image::MaskedImage
A class to manipulate images, masks, and variance as a single object.
Definition: MaskedImage.h:73
lsst::afw::image::Exposure::~Exposure
virtual ~Exposure()
Destructor.
base.h
base.h
lsst::afw::image::ExposureInfo
A collection of all the things that make an Exposure different from a MaskedImage.
Definition: ExposureInfo.h:86
lsst::afw::image::Exposure::getMetadata
std::shared_ptr< lsst::daf::base::PropertySet > getMetadata() const
Return flexible metadata.
Definition: Exposure.h:241
lsst::afw::image::VariancePixel
float VariancePixel
default type for MaskedImage variance images
Definition: LsstImageTypes.h:35
lsst::afw::image::Exposure::getBBox
lsst::geom::Box2I getBBox(ImageOrigin const origin=PARENT) const
Definition: Exposure.h:273
lsst::afw::image::Exposure::getInfo
std::shared_ptr< ExposureInfo const > getInfo() const
Get the ExposureInfo that aggregates all the non-image components. Never null.
Definition: Exposure.h:319
lsst::afw::image::Exposure::subset
Exposure subset(lsst::geom::Box2I const &bbox, ImageOrigin origin=PARENT) const
Return a subimage corresponding to the given box.
Definition: Exposure.h:215
lsst::afw::image::MaskedImage::getX0
int getX0() const
Return the image's column-origin.
Definition: MaskedImage.h:1094
dimensions
afw::table::PointKey< int > dimensions
Definition: GaussianPsf.cc:49
lsst::afw::image::MaskPixel
std::int32_t MaskPixel
default type for Masks and MaskedImage Masks
Definition: LsstImageTypes.h:34
lsst::afw::image::Exposure::operator=
Exposure & operator=(Exposure const &)
lsst::afw::image::Exposure::Exposure
Exposure(Exposure< OtherPixelT, MaskT, VarianceT > const &rhs, const bool deep)
generalised copy constructor; defined here in the header so that the compiler can instantiate N(N-1)/...
Definition: Exposure.h:189
lsst::afw::image::Exposure::getWidth
int getWidth() const
Return the Exposure's width.
Definition: Exposure.h:245
lsst
A base class for image defects.
Definition: imageAlgorithm.dox:1
LSST_EXCEPT
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition: Exception.h:48
lsst::afw::image::Exposure::getCutout
Exposure getCutout(lsst::geom::SpherePoint const &center, lsst::geom::Extent2I const &size) const
Return an Exposure that is a small cutout of the original.
Definition: Exposure.cc:210
photoCalib
Key< int > photoCalib
Definition: Exposure.cc:67
ExposureInfo.h
lsst::afw::image::Exposure::readFits
static Exposure readFits(std::string const &filename)
Read an Exposure from a regular FITS file.
Definition: Exposure.h:399
lsst::afw::image::Exposure::operator=
Exposure & operator=(Exposure &&)
lsst::afw::image::Exposure::hasWcs
bool hasWcs() const
Does this Exposure have a Wcs?
Definition: Exposure.h:313
lsst.pex::exceptions::InvalidParameterError
Reports invalid arguments.
Definition: Runtime.h:66
lsst::afw::image::Exposure::MaskedImageT
MaskedImage< ImageT, MaskT, VarianceT > MaskedImageT
Definition: Exposure.h:74
detector
table::Key< int > detector
Definition: DetectorCollection.cc:172
lsst::afw::image::Exposure::setMetadata
void setMetadata(std::shared_ptr< lsst::daf::base::PropertySet > metadata)
Definition: Exposure.h:242
lsst::geom::Point< int, 2 >
lsst::afw::image::Exposure::setPsf
void setPsf(std::shared_ptr< lsst::afw::detection::Psf const > psf)
Set the Exposure's Psf.
Definition: Exposure.h:304
lsst::afw::image::Exposure::getXY0
lsst::geom::Point2I getXY0() const
Return the Exposure's origin.
Definition: Exposure.h:271
lsst::geom::Box2I
An integer coordinate rectangle.
Definition: Box.h:55
lsst::afw::image::PARENT
@ PARENT
Definition: ImageBase.h:94
SpherePoint.h
lsst::afw::image::Exposure::setMaskedImage
void setMaskedImage(MaskedImageT &maskedImage)
Set the MaskedImage of the Exposure.
Definition: Exposure.cc:117
lsst::afw::image::ImageOrigin
ImageOrigin
Definition: ImageBase.h:94
lsst::geom::SpherePoint
Point in an unspecified spherical coordinate system.
Definition: SpherePoint.h:57
lsst::afw::image::Exposure::setInfo
void setInfo(std::shared_ptr< ExposureInfo > exposureInfo)
Set the ExposureInfo that aggregates all the non-image components.
Definition: Exposure.h:322
lsst::afw::image::Exposure::getDetector
std::shared_ptr< lsst::afw::cameraGeom::Detector const > getDetector() const
Return the Exposure's Detector information.
Definition: Exposure.h:235
lsst::afw::image::Exposure::getWcs
std::shared_ptr< geom::SkyWcs const > getWcs() const
Definition: Exposure.h:232
lsst::afw::image::Exposure::Exposure
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...
Definition: Exposure.cc:52
lsst::afw::image::Exposure::setDetector
void setDetector(std::shared_ptr< lsst::afw::cameraGeom::Detector const > detector)
Set the Exposure's Detector information.
Definition: Exposure.h:292
lsst::afw::image::Exposure::setWcs
void setWcs(std::shared_ptr< geom::SkyWcs > wcs)
Definition: Exposure.h:290
lsst::geom::Extent< int, 2 >
lsst::afw::image::Exposure::setFilter
void setFilter(Filter const &filter)
Set the Exposure's filter.
Definition: Exposure.h:296
lsst::afw::image::MaskedImage::getDimensions
lsst::geom::Extent2I getDimensions() const
Definition: MaskedImage.h:1085
bbox
AmpInfoBoxKey bbox
Definition: Amplifier.cc:117
lsst::afw::image::Exposure::getX0
int getX0() const
Return the Exposure's column-origin.
Definition: Exposure.h:256