LSST Applications  21.0.0+04719a4bac,21.0.0-1-ga51b5d4+f5e6047307,21.0.0-11-g2b59f77+a9c1acf22d,21.0.0-11-ga42c5b2+86977b0b17,21.0.0-12-gf4ce030+76814010d2,21.0.0-13-g1721dae+760e7a6536,21.0.0-13-g3a573fe+768d78a30a,21.0.0-15-g5a7caf0+f21cbc5713,21.0.0-16-g0fb55c1+b60e2d390c,21.0.0-19-g4cded4ca+71a93a33c0,21.0.0-2-g103fe59+bb20972958,21.0.0-2-g45278ab+04719a4bac,21.0.0-2-g5242d73+3ad5d60fb1,21.0.0-2-g7f82c8f+8babb168e8,21.0.0-2-g8f08a60+06509c8b61,21.0.0-2-g8faa9b5+616205b9df,21.0.0-2-ga326454+8babb168e8,21.0.0-2-gde069b7+5e4aea9c2f,21.0.0-2-gecfae73+1d3a86e577,21.0.0-2-gfc62afb+3ad5d60fb1,21.0.0-25-g1d57be3cd+e73869a214,21.0.0-3-g357aad2+ed88757d29,21.0.0-3-g4a4ce7f+3ad5d60fb1,21.0.0-3-g4be5c26+3ad5d60fb1,21.0.0-3-g65f322c+e0b24896a3,21.0.0-3-g7d9da8d+616205b9df,21.0.0-3-ge02ed75+a9c1acf22d,21.0.0-4-g591bb35+a9c1acf22d,21.0.0-4-g65b4814+b60e2d390c,21.0.0-4-gccdca77+0de219a2bc,21.0.0-4-ge8a399c+6c55c39e83,21.0.0-5-gd00fb1e+05fce91b99,21.0.0-6-gc675373+3ad5d60fb1,21.0.0-64-g1122c245+4fb2b8f86e,21.0.0-7-g04766d7+cd19d05db2,21.0.0-7-gdf92d54+04719a4bac,21.0.0-8-g5674e7b+d1bd76f71f,master-gac4afde19b+a9c1acf22d,w.2021.13
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:49
std::shared_ptr< RecordT > src
Definition: Match.cc:48
table::Key< table::Array< std::uint8_t > > wcs
Definition: SkyWcs.cc:71
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:210
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:140
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:52
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
MaskedImage< ImageT, MaskT, VarianceT > MaskedImageT
Definition: Exposure.h:74
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:122
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:117
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:1094
lsst::geom::Box2I getBBox(ImageOrigin const origin=PARENT) const
Definition: MaskedImage.h:1086
int getHeight() const
Return the number of rows in the image.
Definition: MaskedImage.h:1084
int getY0() const
Return the image's row-origin.
Definition: MaskedImage.h:1102
lsst::geom::Extent2I getDimensions() const
Definition: MaskedImage.h:1085
lsst::geom::Point2I getXY0() const
Return the image's origin.
Definition: MaskedImage.h:1110
int getWidth() const
Return the number of columns in the image.
Definition: MaskedImage.h:1082
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.
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
std::int32_t MaskPixel
default type for Masks and MaskedImage Masks
float VariancePixel
default type for MaskedImage variance images
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