LSSTApplications  16.0-10-g0ee56ad+5,16.0-11-ga33d1f2+5,16.0-12-g3ef5c14+3,16.0-12-g71e5ef5+18,16.0-12-gbdf3636+3,16.0-13-g118c103+3,16.0-13-g8f68b0a+3,16.0-15-gbf5c1cb+4,16.0-16-gfd17674+3,16.0-17-g7c01f5c+3,16.0-18-g0a50484+1,16.0-20-ga20f992+8,16.0-21-g0e05fd4+6,16.0-21-g15e2d33+4,16.0-22-g62d8060+4,16.0-22-g847a80f+4,16.0-25-gf00d9b8+1,16.0-28-g3990c221+4,16.0-3-gf928089+3,16.0-32-g88a4f23+5,16.0-34-gd7987ad+3,16.0-37-gc7333cb+2,16.0-4-g10fc685+2,16.0-4-g18f3627+26,16.0-4-g5f3a788+26,16.0-5-gaf5c3d7+4,16.0-5-gcc1f4bb+1,16.0-6-g3b92700+4,16.0-6-g4412fcd+3,16.0-6-g7235603+4,16.0-69-g2562ce1b+2,16.0-8-g14ebd58+4,16.0-8-g2df868b+1,16.0-8-g4cec79c+6,16.0-8-gadf6c7a+1,16.0-8-gfc7ad86,16.0-82-g59ec2a54a+1,16.0-9-g5400cdc+2,16.0-9-ge6233d7+5,master-g2880f2d8cf+3,v17.0.rc1
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>
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 
119  explicit Exposure(MaskedImageT& maskedImage, std::shared_ptr<ExposureInfo> info);
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 
146  explicit Exposure(fits::MemFileManager& manager, lsst::geom::Box2I const& bbox = lsst::geom::Box2I(),
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  : lsst::daf::base::Citizen(typeid(this)),
193  _maskedImage(rhs.getMaskedImage(), deep),
194  _info(new ExposureInfo(*rhs.getInfo(), deep)) {
195  if (not deep) {
197  "Exposure's converting copy constructor must make a deep copy");
198  }
199  }
200 
201  Exposure& operator=(Exposure const&);
203 
217  Exposure subset(lsst::geom::Box2I const& bbox, ImageOrigin origin = PARENT) const {
218  return Exposure(*this, bbox, origin, false);
219  }
220 
222  Exposure operator[](lsst::geom::Box2I const& bbox) const { return subset(bbox); }
223 
226  virtual ~Exposure();
227 
228  // Get Members
230  MaskedImageT getMaskedImage() { return _maskedImage; }
232  MaskedImageT getMaskedImage() const { return _maskedImage; }
233 
234  std::shared_ptr<geom::SkyWcs const> getWcs() const { return _info->getWcs(); }
235 
238  return _info->getDetector();
239  }
241  Filter getFilter() const { return _info->getFilter(); }
243  std::shared_ptr<lsst::daf::base::PropertySet> getMetadata() const { return _info->getMetadata(); }
244  void setMetadata(std::shared_ptr<lsst::daf::base::PropertySet> metadata) { _info->setMetadata(metadata); }
245 
247  int getWidth() const { return _maskedImage.getWidth(); }
249  int getHeight() const { return _maskedImage.getHeight(); }
251  lsst::geom::Extent2I getDimensions() const { return _maskedImage.getDimensions(); }
252 
258  int getX0() const { return _maskedImage.getX0(); }
264  int getY0() const { return _maskedImage.getY0(); }
265 
273  lsst::geom::Point2I getXY0() const { return _maskedImage.getXY0(); }
274 
275  lsst::geom::Box2I getBBox(ImageOrigin const origin = PARENT) const {
276  return _maskedImage.getBBox(origin);
277  }
286  void setXY0(lsst::geom::Point2I const& origin);
287 
288  // Set Members
291  void setMaskedImage(MaskedImageT& maskedImage);
292  void setWcs(std::shared_ptr<geom::SkyWcs> wcs) { _info->setWcs(wcs); }
295  _info->setDetector(detector);
296  }
298  void setFilter(Filter const& filter) { _info->setFilter(filter); }
300  void setCalib(std::shared_ptr<Calib> calib) { _info->setCalib(calib); }
302  std::shared_ptr<Calib> getCalib() { return _info->getCalib(); }
304  std::shared_ptr<Calib const> getCalib() const { return _info->getCalib(); }
307 
311  std::shared_ptr<lsst::afw::detection::Psf const> getPsf() const { return _info->getPsf(); }
312 
314  bool hasPsf() const { return _info->hasPsf(); }
315 
317  bool hasWcs() const { return _info->hasWcs(); }
318 
321 
324 
326  void setInfo(std::shared_ptr<ExposureInfo> exposureInfo) { _info = exposureInfo; }
327 
342  void writeFits(std::string const& fileName) const;
343 
351  void writeFits(fits::MemFileManager& manager) const;
352 
360  void writeFits(fits::Fits& fitsfile) const;
361 
370  void writeFits(std::string const& fileName, fits::ImageWriteOptions const& imageOptions,
371  fits::ImageWriteOptions const& maskOptions,
372  fits::ImageWriteOptions const& varianceOptions) const;
373 
382  void writeFits(fits::MemFileManager& manager, fits::ImageWriteOptions const& imageOptions,
383  fits::ImageWriteOptions const& maskOptions,
384  fits::ImageWriteOptions const& varianceOptions) const;
385 
394  void writeFits(fits::Fits& fitsfile, fits::ImageWriteOptions const& imageOptions,
395  fits::ImageWriteOptions const& maskOptions,
396  fits::ImageWriteOptions const& varianceOptions) const;
397 
403  static Exposure readFits(std::string const& filename) {
404  return Exposure<ImageT, MaskT, VarianceT>(filename);
405  }
406 
413  return Exposure<ImageT, MaskT, VarianceT>(manager);
414  }
415 
432  Exposure getCutout(lsst::geom::SpherePoint const& center, lsst::geom::Extent2I const& size) const;
433 
434 private:
435  void _readFits(fits::Fits& fitsfile, lsst::geom::Box2I const& bbox, ImageOrigin origin,
436  bool conformMasks);
437 
438  MaskedImageT _maskedImage;
440 };
441 
445 template <typename ImagePixelT, typename MaskPixelT, typename VariancePixelT>
450 ) {
453 }
454 } // namespace image
455 } // namespace afw
456 } // namespace lsst
457 
458 #endif // LSST_AFW_IMAGE_EXPOSURE_H
int getWidth() const
Return the Exposure&#39;s width.
Definition: Exposure.h:247
void setFilter(Filter const &filter)
Set the Exposure&#39;s filter.
Definition: Exposure.h:298
afw::table::PointKey< int > dimensions
Definition: GaussianPsf.cc:49
virtual ~Exposure()
Destructor.
std::shared_ptr< Calib const > getCalib() const
Return the Exposure&#39;s Calib object.
Definition: Exposure.h:304
void setInfo(std::shared_ptr< ExposureInfo > exposureInfo)
Set the ExposureInfo that aggregates all the non-image components.
Definition: Exposure.h:326
int getHeight() const
Return the Exposure&#39;s height.
Definition: Exposure.h:249
int getY0() const
Return the Exposure&#39;s row-origin.
Definition: Exposure.h:264
void setCalib(std::shared_ptr< Calib > calib)
Set the Exposure&#39;s Calib object.
Definition: Exposure.h:300
void setXY0(lsst::geom::Point2I const &origin)
Set the Exposure&#39;s origin (including correcting the Wcs)
Definition: Exposure.cc:129
A class to contain the data, WCS, and other information needed to describe an image of the sky...
Definition: Exposure.h:72
Options for writing an image to FITS.
Definition: fits.h:218
Exposure operator[](lsst::geom::Box2I const &bbox) const
Return a subimage corresponding to the given box (interpreted as PARENT coordinates).
Definition: Exposure.h:222
void setWcs(std::shared_ptr< geom::SkyWcs > wcs)
Definition: Exposure.h:292
std::shared_ptr< ExposureInfo > getInfo()
Get the ExposureInfo that aggregates all the non-image components. Never null.
Definition: Exposure.h:320
void setMetadata(std::shared_ptr< lsst::daf::base::PropertySet > metadata)
Definition: Exposure.h:244
lsst::geom::Point2I getXY0() const
Return the Exposure&#39;s origin.
Definition: Exposure.h:273
A simple struct that combines the two arguments that must be passed to most cfitsio routines and cont...
Definition: fits.h:296
MaskedImage< ImageT, MaskT, VarianceT > MaskedImageT
Definition: Exposure.h:74
lsst::geom::Point2I getXY0() const
Return the image&#39;s origin.
Definition: MaskedImage.h:1122
lsst::geom::Box2I getBBox(ImageOrigin const origin=PARENT) const
Definition: Exposure.h:275
bool hasWcs() const
Does this Exposure have a Wcs?
Definition: Exposure.h:317
Exposure subset(lsst::geom::Box2I const &bbox, ImageOrigin origin=PARENT) const
Return a subimage corresponding to the given box.
Definition: Exposure.h:217
std::shared_ptr< ExposureInfo const > getInfo() const
Get the ExposureInfo that aggregates all the non-image components. Never null.
Definition: Exposure.h:323
static Exposure readFits(fits::MemFileManager &manager)
Read an Exposure from a FITS RAM file.
Definition: Exposure.h:412
table::Key< table::Array< std::uint8_t > > wcs
Definition: SkyWcs.cc:71
lsst::geom::Extent2I getDimensions() const
Definition: MaskedImage.h:1097
STL class.
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:446
int getHeight() const
Return the number of rows in the image.
Definition: MaskedImage.h:1096
MaskedImageT getMaskedImage() const
Return the MaskedImage.
Definition: Exposure.h:232
A base class for image defects.
MaskedImageT getMaskedImage()
Return the MaskedImage.
Definition: Exposure.h:230
int getX0() const
Return the Exposure&#39;s column-origin.
Definition: Exposure.h:258
int getX0() const
Return the image&#39;s column-origin.
Definition: MaskedImage.h:1106
Lifetime-management for memory that goes into FITS memory files.
Definition: fits.h:120
std::shared_ptr< lsst::daf::base::PropertySet > getMetadata() const
Return flexible metadata.
Definition: Exposure.h:243
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:217
void setMaskedImage(MaskedImageT &maskedImage)
Set the MaskedImage of the Exposure.
Definition: Exposure.cc:124
bool hasPsf() const
Does this Exposure have a Psf?
Definition: Exposure.h:314
table::Key< int > detector
table::Box2IKey bbox
Definition: Detector.cc:166
std::int32_t MaskPixel
default type for Masks and MaskedImage Masks
Holds an integer identifier for an LSST filter.
Definition: Filter.h:141
std::shared_ptr< RecordT > src
Definition: Match.cc:48
int getY0() const
Return the image&#39;s row-origin.
Definition: MaskedImage.h:1114
std::shared_ptr< Calib > getCalib()
Return the Exposure&#39;s Calib object.
Definition: Exposure.h:302
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition: Exception.h:48
static Exposure readFits(std::string const &filename)
Read an Exposure from a regular FITS file.
Definition: Exposure.h:403
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
Filter getFilter() const
Return the Exposure&#39;s filter.
Definition: Exposure.h:241
Point in an unspecified spherical coordinate system.
Definition: SpherePoint.h:57
Citizen(const std::type_info &)
Definition: Citizen.cc:163
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:53
std::shared_ptr< lsst::afw::detection::Psf > getPsf()
Return the Exposure&#39;s Psf object.
Definition: Exposure.h:309
void setDetector(std::shared_ptr< lsst::afw::cameraGeom::Detector const > detector)
Set the Exposure&#39;s Detector information.
Definition: Exposure.h:294
Reports invalid arguments.
Definition: Runtime.h:66
std::shared_ptr< geom::SkyWcs const > getWcs() const
Definition: Exposure.h:234
int getWidth() const
Return the number of columns in the image.
Definition: MaskedImage.h:1094
lsst::geom::Extent2I getDimensions() const
Return the Exposure&#39;s size.
Definition: Exposure.h:251
std::shared_ptr< lsst::afw::detection::Psf const > getPsf() const
Return the Exposure&#39;s Psf object.
Definition: Exposure.h:311
void writeFits(std::string const &fileName) const
Write an Exposure to a regular multi-extension FITS file.
Definition: Exposure.cc:147
Citizen is a class that should be among all LSST classes base classes, and handles basic memory manag...
Definition: Citizen.h:55
void setPsf(std::shared_ptr< lsst::afw::detection::Psf const > psf)
Set the Exposure&#39;s Psf.
Definition: Exposure.h:306
A collection of all the things that make an Exposure different from a MaskedImage.
Definition: ExposureInfo.h:87
float VariancePixel
default type for MaskedImage variance images
lsst::geom::Box2I getBBox(ImageOrigin const origin=PARENT) const
Definition: MaskedImage.h:1098
An integer coordinate rectangle.
Definition: Box.h:54
std::shared_ptr< lsst::afw::cameraGeom::Detector const > getDetector() const
Return the Exposure&#39;s Detector information.
Definition: Exposure.h:237
Exposure & operator=(Exposure const &)
Basic LSST definitions.