LSST Applications  21.0.0-147-g0e635eb1+1acddb5be5,22.0.0+052faf71bd,22.0.0+1ea9a8b2b2,22.0.0+6312710a6c,22.0.0+729191ecac,22.0.0+7589c3a021,22.0.0+9f079a9461,22.0.1-1-g7d6de66+b8044ec9de,22.0.1-1-g87000a6+536b1ee016,22.0.1-1-g8e32f31+6312710a6c,22.0.1-10-gd060f87+016f7cdc03,22.0.1-12-g9c3108e+df145f6f68,22.0.1-16-g314fa6d+c825727ab8,22.0.1-19-g93a5c75+d23f2fb6d8,22.0.1-19-gb93eaa13+aab3ef7709,22.0.1-2-g8ef0a89+b8044ec9de,22.0.1-2-g92698f7+9f079a9461,22.0.1-2-ga9b0f51+052faf71bd,22.0.1-2-gac51dbf+052faf71bd,22.0.1-2-gb66926d+6312710a6c,22.0.1-2-gcb770ba+09e3807989,22.0.1-20-g32debb5+b8044ec9de,22.0.1-23-gc2439a9a+fb0756638e,22.0.1-3-g496fd5d+09117f784f,22.0.1-3-g59f966b+1e6ba2c031,22.0.1-3-g849a1b8+f8b568069f,22.0.1-3-gaaec9c0+c5c846a8b1,22.0.1-32-g5ddfab5d3+60ce4897b0,22.0.1-4-g037fbe1+64e601228d,22.0.1-4-g8623105+b8044ec9de,22.0.1-5-g096abc9+d18c45d440,22.0.1-5-g15c806e+57f5c03693,22.0.1-7-gba73697+57f5c03693,master-g6e05de7fdc+c1283a92b8,master-g72cdda8301+729191ecac,w.2021.39
LSST Data Management Base Package
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  // TODO: remove in DM-27177
240  [[deprecated("Replaced with getFilterLabel. Will be removed after v22.")]] Filter getFilter() const {
241  return _info->getFilter();
242  }
244  // TODO: deprecate in DM-27177, remove in DM-27811
245  std::shared_ptr<FilterLabel const> getFilterLabel() const { return _info->getFilterLabel(); }
247  std::shared_ptr<lsst::daf::base::PropertySet> getMetadata() const { return _info->getMetadata(); }
248  void setMetadata(std::shared_ptr<lsst::daf::base::PropertySet> metadata) { _info->setMetadata(metadata); }
249 
251  int getWidth() const { return _maskedImage.getWidth(); }
253  int getHeight() const { return _maskedImage.getHeight(); }
255  lsst::geom::Extent2I getDimensions() const { return _maskedImage.getDimensions(); }
256 
262  int getX0() const { return _maskedImage.getX0(); }
268  int getY0() const { return _maskedImage.getY0(); }
269 
277  lsst::geom::Point2I getXY0() const { return _maskedImage.getXY0(); }
278 
279  lsst::geom::Box2I getBBox(ImageOrigin const origin = PARENT) const {
280  return _maskedImage.getBBox(origin);
281  }
290  void setXY0(lsst::geom::Point2I const& origin);
291 
292  // Set Members
295  void setMaskedImage(MaskedImageT& maskedImage);
296  void setWcs(std::shared_ptr<geom::SkyWcs> wcs) { _info->setWcs(wcs); }
299  _info->setDetector(detector);
300  }
307  // TODO: remove in DM-27177
308  [[deprecated("Replaced with setFilterLabel. Will be removed after v22.")]] void setFilter(
309  Filter const& filter) {
310  _info->setFilter(filter);
311  }
313  // TODO: deprecate in DM-27177, remove in DM-27811
315  _info->setFilterLabel(filterLabel);
316  }
317 
321  std::shared_ptr<PhotoCalib const> getPhotoCalib() const { return _info->getPhotoCalib(); }
322 
325 
327  std::shared_ptr<lsst::afw::detection::Psf const> getPsf() const { return _info->getPsf(); }
328 
330  bool hasPsf() const { return _info->hasPsf(); }
331 
333  bool hasWcs() const { return _info->hasWcs(); }
334 
337 
340 
342  void setInfo(std::shared_ptr<ExposureInfo> exposureInfo) { _info = exposureInfo; }
343 
358  void writeFits(std::string const& fileName) const;
359 
367  void writeFits(fits::MemFileManager& manager) const;
368 
376  void writeFits(fits::Fits& fitsfile) const;
377 
386  void writeFits(std::string const& fileName, fits::ImageWriteOptions const& imageOptions,
387  fits::ImageWriteOptions const& maskOptions,
388  fits::ImageWriteOptions const& varianceOptions) const;
389 
398  void writeFits(fits::MemFileManager& manager, fits::ImageWriteOptions const& imageOptions,
399  fits::ImageWriteOptions const& maskOptions,
400  fits::ImageWriteOptions const& varianceOptions) const;
401 
410  void writeFits(fits::Fits& fitsfile, fits::ImageWriteOptions const& imageOptions,
411  fits::ImageWriteOptions const& maskOptions,
412  fits::ImageWriteOptions const& varianceOptions) const;
413 
419  static Exposure readFits(std::string const& filename) {
420  return Exposure<ImageT, MaskT, VarianceT>(filename);
421  }
422 
429  return Exposure<ImageT, MaskT, VarianceT>(manager);
430  }
431 
448  Exposure getCutout(lsst::geom::SpherePoint const& center, lsst::geom::Extent2I const& size) const;
449 
450 private:
451  void _readFits(fits::Fits& fitsfile, lsst::geom::Box2I const& bbox, ImageOrigin origin,
452  bool conformMasks);
453 
454  MaskedImageT _maskedImage;
456 };
457 
461 template <typename ImagePixelT, typename MaskPixelT, typename VariancePixelT>
466 ) {
469 }
470 } // namespace image
471 } // namespace afw
472 } // namespace lsst
473 
474 #endif // LSST_AFW_IMAGE_EXPOSURE_H
AmpInfoBoxKey bbox
Definition: Amplifier.cc:117
table::Key< int > detector
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition: Exception.h:48
afw::table::PointKey< int > dimensions
Definition: GaussianPsf.cc:48
std::shared_ptr< RecordT > src
Definition: Match.cc:48
table::Key< table::Array< std::uint8_t > > wcs
Definition: SkyWcs.cc:66
Basic LSST definitions.
A simple struct that combines the two arguments that must be passed to most cfitsio routines and cont...
Definition: fits.h:297
Lifetime-management for memory that goes into FITS memory files.
Definition: fits.h:121
A class to contain the data, WCS, and other information needed to describe an image of the sky.
Definition: Exposure.h:72
MaskedImageT getMaskedImage()
Return the MaskedImage.
Definition: Exposure.h:228
void setFilterLabel(std::shared_ptr< FilterLabel const > filterLabel)
Set the Exposure's filter information.
Definition: Exposure.h:314
Filter getFilter() const
Return the Exposure's filter.
Definition: Exposure.h:240
void setPsf(std::shared_ptr< lsst::afw::detection::Psf const > psf)
Set the Exposure's Psf.
Definition: Exposure.h:324
bool hasWcs() const
Does this Exposure have a Wcs?
Definition: Exposure.h:333
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:204
int getHeight() const
Return the Exposure's height.
Definition: Exposure.h:253
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
void setDetector(std::shared_ptr< lsst::afw::cameraGeom::Detector const > detector)
Set the Exposure's Detector information.
Definition: Exposure.h:298
void writeFits(std::string const &fileName) const
Write an Exposure to a regular multi-extension FITS file.
Definition: Exposure.cc:134
void setFilter(Filter const &filter)
Set the Exposure's filter.
Definition: Exposure.h:308
virtual ~Exposure()
Destructor.
MaskedImageT getMaskedImage() const
Return the MaskedImage.
Definition: Exposure.h:230
void setPhotoCalib(std::shared_ptr< PhotoCalib const > photoCalib)
Set the Exposure's PhotoCalib object.
Definition: Exposure.h:319
int getWidth() const
Return the Exposure's width.
Definition: Exposure.h:251
int getY0() const
Return the Exposure's row-origin.
Definition: Exposure.h:268
Exposure subset(lsst::geom::Box2I const &bbox, ImageOrigin origin=PARENT) const
Return a subimage corresponding to the given box.
Definition: Exposure.h:215
void setInfo(std::shared_ptr< ExposureInfo > exposureInfo)
Set the ExposureInfo that aggregates all the non-image components.
Definition: Exposure.h:342
std::shared_ptr< geom::SkyWcs const > getWcs() const
Definition: Exposure.h:232
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:46
void setMetadata(std::shared_ptr< lsst::daf::base::PropertySet > metadata)
Definition: Exposure.h:248
int getX0() const
Return the Exposure's column-origin.
Definition: Exposure.h:262
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::geom::Extent2I getDimensions() const
Return the Exposure's size.
Definition: Exposure.h:255
bool hasPsf() const
Does this Exposure have a Psf?
Definition: Exposure.h:330
static Exposure readFits(fits::MemFileManager &manager)
Read an Exposure from a FITS RAM file.
Definition: Exposure.h:428
void setWcs(std::shared_ptr< geom::SkyWcs > wcs)
Definition: Exposure.h:296
std::shared_ptr< FilterLabel const > getFilterLabel() const
Return the Exposure's filter information.
Definition: Exposure.h:245
Exposure & operator=(Exposure &&)
Exposure & operator=(Exposure const &)
std::shared_ptr< ExposureInfo > getInfo()
Get the ExposureInfo that aggregates all the non-image components. Never null.
Definition: Exposure.h:336
std::shared_ptr< PhotoCalib const > getPhotoCalib() const
Return the Exposure's PhotoCalib object.
Definition: Exposure.h:321
lsst::geom::Point2I getXY0() const
Return the Exposure's origin.
Definition: Exposure.h:277
void setXY0(lsst::geom::Point2I const &origin)
Set the Exposure's origin (including correcting the Wcs)
Definition: Exposure.cc:116
std::shared_ptr< lsst::afw::cameraGeom::Detector const > getDetector() const
Return the Exposure's Detector information.
Definition: Exposure.h:235
static Exposure readFits(std::string const &filename)
Read an Exposure from a regular FITS file.
Definition: Exposure.h:419
void setMaskedImage(MaskedImageT &maskedImage)
Set the MaskedImage of the Exposure.
Definition: Exposure.cc:111
MaskedImage< ImageT, MaskT, VarianceT > MaskedImageT
Definition: Exposure.h:74
std::shared_ptr< ExposureInfo const > getInfo() const
Get the ExposureInfo that aggregates all the non-image components. Never null.
Definition: Exposure.h:339
std::shared_ptr< lsst::afw::detection::Psf const > getPsf() const
Return the Exposure's Psf object.
Definition: Exposure.h:327
std::shared_ptr< lsst::daf::base::PropertySet > getMetadata() const
Return flexible metadata.
Definition: Exposure.h:247
lsst::geom::Box2I getBBox(ImageOrigin const origin=PARENT) const
Definition: Exposure.h:279
A collection of all the things that make an Exposure different from a MaskedImage.
Definition: ExposureInfo.h:86
A class to manipulate images, masks, and variance as a single object.
Definition: MaskedImage.h:73
int getX0() const
Return the image's column-origin.
Definition: MaskedImage.h:1066
lsst::geom::Box2I getBBox(ImageOrigin const origin=PARENT) const
Definition: MaskedImage.h:1058
int getHeight() const
Return the number of rows in the image.
Definition: MaskedImage.h:1056
int getY0() const
Return the image's row-origin.
Definition: MaskedImage.h:1074
lsst::geom::Extent2I getDimensions() const
Definition: MaskedImage.h:1057
lsst::geom::Point2I getXY0() const
Return the image's origin.
Definition: MaskedImage.h:1082
int getWidth() const
Return the number of columns in the image.
Definition: MaskedImage.h:1054
An integer coordinate rectangle.
Definition: Box.h:55
Point in an unspecified spherical coordinate system.
Definition: SpherePoint.h:57
Reports invalid arguments.
Definition: Runtime.h:66
Backwards-compatibility support for depersisting the old Calib (FluxMag0/FluxMag0Err) objects.
float VariancePixel
default type for MaskedImage variance images
std::int32_t MaskPixel
default type for Masks and MaskedImage Masks
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:462
A base class for image defects.
Options for writing an image to FITS.
Definition: fits.h:219
Key< int > psf
Definition: Exposure.cc:65
Key< int > photoCalib
Definition: Exposure.cc:67