lsst.afw  16.0-10-gd1b3a1c94
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 
40 namespace formatters {
41 template <typename ImageT, typename MaskT, typename VarianceT>
42 class ExposureFormatter;
43 }
44 
45 namespace image {
46 
76 template <typename ImageT, typename MaskT = lsst::afw::image::MaskPixel,
77  typename VarianceT = lsst::afw::image::VariancePixel>
79 public:
81 
82  // Class Constructors and Destructor
90  explicit Exposure(unsigned int width, unsigned int height,
92 
101 
107  explicit Exposure(lsst::geom::Box2I const& bbox,
109 
115  explicit Exposure(MaskedImageT& maskedImage,
117 
125  explicit Exposure(MaskedImageT& maskedImage, std::shared_ptr<ExposureInfo> info);
126 
136  explicit Exposure(std::string const& fileName, lsst::geom::Box2I const& bbox = lsst::geom::Box2I(),
137  ImageOrigin origin = PARENT, bool conformMasks = false);
138 
148  explicit Exposure(fits::MemFileManager& manager, lsst::geom::Box2I const& bbox = lsst::geom::Box2I(),
149  ImageOrigin origin = PARENT, bool conformMasks = false);
150 
160  explicit Exposure(fits::Fits& fitsfile, lsst::geom::Box2I const& bbox = lsst::geom::Box2I(),
161  ImageOrigin origin = PARENT, bool conformMasks = 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&);
202  Exposure& operator=(Exposure&&);
203 
206  virtual ~Exposure();
207 
208  // Get Members
210  MaskedImageT getMaskedImage() { return _maskedImage; }
212  MaskedImageT getMaskedImage() const { return _maskedImage; }
213 
214  std::shared_ptr<geom::SkyWcs const> getWcs() const { return _info->getWcs(); }
215 
218  return _info->getDetector();
219  }
221  Filter getFilter() const { return _info->getFilter(); }
223  std::shared_ptr<lsst::daf::base::PropertySet> getMetadata() const { return _info->getMetadata(); }
224  void setMetadata(std::shared_ptr<lsst::daf::base::PropertySet> metadata) { _info->setMetadata(metadata); }
225 
227  int getWidth() const { return _maskedImage.getWidth(); }
229  int getHeight() const { return _maskedImage.getHeight(); }
231  lsst::geom::Extent2I getDimensions() const { return _maskedImage.getDimensions(); }
232 
238  int getX0() const { return _maskedImage.getX0(); }
244  int getY0() const { return _maskedImage.getY0(); }
245 
253  lsst::geom::Point2I getXY0() const { return _maskedImage.getXY0(); }
254 
255  lsst::geom::Box2I getBBox(ImageOrigin const origin = PARENT) const {
256  return _maskedImage.getBBox(origin);
257  }
266  void setXY0(lsst::geom::Point2I const& origin);
267 
268  // Set Members
271  void setMaskedImage(MaskedImageT& maskedImage);
272  void setWcs(std::shared_ptr<geom::SkyWcs> wcs) { _info->setWcs(wcs); }
275  _info->setDetector(detector);
276  }
278  void setFilter(Filter const& filter) { _info->setFilter(filter); }
280  void setCalib(std::shared_ptr<Calib> calib) { _info->setCalib(calib); }
282  std::shared_ptr<Calib> getCalib() { return _info->getCalib(); }
284  std::shared_ptr<Calib const> getCalib() const { return _info->getCalib(); }
287 
291  std::shared_ptr<lsst::afw::detection::Psf const> getPsf() const { return _info->getPsf(); }
292 
294  bool hasPsf() const { return _info->hasPsf(); }
295 
297  bool hasWcs() const { return _info->hasWcs(); }
298 
301 
304 
306  void setInfo(std::shared_ptr<ExposureInfo> exposureInfo) { _info = exposureInfo; }
307 
322  void writeFits(std::string const& fileName) const;
323 
331  void writeFits(fits::MemFileManager& manager) const;
332 
340  void writeFits(fits::Fits& fitsfile) const;
341 
350  void writeFits(std::string const& fileName, fits::ImageWriteOptions const& imageOptions,
351  fits::ImageWriteOptions const& maskOptions,
352  fits::ImageWriteOptions const& varianceOptions) const;
353 
362  void writeFits(fits::MemFileManager& manager, fits::ImageWriteOptions const& imageOptions,
363  fits::ImageWriteOptions const& maskOptions,
364  fits::ImageWriteOptions const& varianceOptions) const;
365 
374  void writeFits(fits::Fits& fitsfile, fits::ImageWriteOptions const& imageOptions,
375  fits::ImageWriteOptions const& maskOptions,
376  fits::ImageWriteOptions const& varianceOptions) const;
377 
383  static Exposure readFits(std::string const& filename) {
384  return Exposure<ImageT, MaskT, VarianceT>(filename);
385  }
386 
393  return Exposure<ImageT, MaskT, VarianceT>(manager);
394  }
395 
411  Exposure getCutout(lsst::geom::SpherePoint const& center, lsst::geom::Extent2I const& size) const;
412 
413 private:
415 
416  void _readFits(fits::Fits& fitsfile, lsst::geom::Box2I const& bbox, ImageOrigin origin,
417  bool conformMasks);
418 
419  MaskedImageT _maskedImage;
421 };
422 
426 template <typename ImagePixelT, typename MaskPixelT, typename VariancePixelT>
431 ) {
434 }
435 } // namespace image
436 } // namespace afw
437 } // namespace lsst
438 
439 #endif // LSST_AFW_IMAGE_EXPOSURE_H
int getWidth() const
Return the Exposure&#39;s width.
Definition: Exposure.h:227
void setFilter(Filter const &filter)
Set the Exposure&#39;s filter.
Definition: Exposure.h:278
std::shared_ptr< Calib const > getCalib() const
Return the Exposure&#39;s Calib object.
Definition: Exposure.h:284
void setInfo(std::shared_ptr< ExposureInfo > exposureInfo)
Set the ExposureInfo that aggregates all the non-image components.
Definition: Exposure.h:306
getInfo
int getHeight() const
Return the Exposure&#39;s height.
Definition: Exposure.h:229
int getY0() const
Return the Exposure&#39;s row-origin.
Definition: Exposure.h:244
void setCalib(std::shared_ptr< Calib > calib)
Set the Exposure&#39;s Calib object.
Definition: Exposure.h:280
A class to contain the data, WCS, and other information needed to describe an image of the sky...
Definition: Exposure.h:78
Options for writing an image to FITS.
Definition: fits.h:218
void setWcs(std::shared_ptr< geom::SkyWcs > wcs)
Definition: Exposure.h:272
std::shared_ptr< ExposureInfo > getInfo()
Get the ExposureInfo that aggregates all the non-image components. Never null.
Definition: Exposure.h:300
void setMetadata(std::shared_ptr< lsst::daf::base::PropertySet > metadata)
Definition: Exposure.h:224
lsst::geom::Point2I getXY0() const
Return the Exposure&#39;s origin.
Definition: Exposure.h:253
Key< int > psf
Definition: Exposure.cc:62
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:80
lsst::geom::Box2I getBBox(ImageOrigin const origin=PARENT) const
Definition: Exposure.h:255
bool hasWcs() const
Does this Exposure have a Wcs?
Definition: Exposure.h:297
std::shared_ptr< ExposureInfo const > getInfo() const
Get the ExposureInfo that aggregates all the non-image components. Never null.
Definition: Exposure.h:303
static Exposure readFits(fits::MemFileManager &manager)
Read an Exposure from a FITS RAM file.
Definition: Exposure.h:392
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:427
afw::table::PointKey< int > dimensions
Definition: GaussianPsf.cc:44
MaskedImageT getMaskedImage() const
Return the MaskedImage.
Definition: Exposure.h:212
Class implementing persistence and retrieval for Exposures.
table::Key< table::Array< std::uint8_t > > wcs
Definition: SkyWcs.cc:66
A base class for image defects.
MaskedImageT getMaskedImage()
Return the MaskedImage.
Definition: Exposure.h:210
int getX0() const
Return the Exposure&#39;s column-origin.
Definition: Exposure.h:238
std::shared_ptr< RecordT > src
Definition: Match.cc:48
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:223
bool hasPsf() const
Does this Exposure have a Psf?
Definition: Exposure.h:294
std::int32_t MaskPixel
default type for Masks and MaskedImage Masks
Holds an integer identifier for an LSST filter.
Definition: Filter.h:153
std::shared_ptr< Calib > getCalib()
Return the Exposure&#39;s Calib object.
Definition: Exposure.h:282
#define LSST_EXCEPT(type,...)
static Exposure readFits(std::string const &filename)
Read an Exposure from a regular FITS file.
Definition: Exposure.h:383
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:221
std::shared_ptr< lsst::afw::detection::Psf > getPsf()
Return the Exposure&#39;s Psf object.
Definition: Exposure.h:289
void setDetector(std::shared_ptr< lsst::afw::cameraGeom::Detector const > detector)
Set the Exposure&#39;s Detector information.
Definition: Exposure.h:274
#define LSST_PERSIST_FORMATTER(formatter...)
std::shared_ptr< geom::SkyWcs const > getWcs() const
Definition: Exposure.h:214
table::Box2IKey bbox
lsst::geom::Extent2I getDimensions() const
Return the Exposure&#39;s size.
Definition: Exposure.h:231
std::shared_ptr< lsst::afw::detection::Psf const > getPsf() const
Return the Exposure&#39;s Psf object.
Definition: Exposure.h:291
void setPsf(std::shared_ptr< lsst::afw::detection::Psf const > psf)
Set the Exposure&#39;s Psf.
Definition: Exposure.h:286
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
std::shared_ptr< lsst::afw::cameraGeom::Detector const > getDetector() const
Return the Exposure&#39;s Detector information.
Definition: Exposure.h:217