lsst.afw  13.0-92-g8ecf155+1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 
35 namespace lsst {
36 namespace afw {
37 
38 namespace formatters {
39 template <typename ImageT, typename MaskT, typename VarianceT>
40 class ExposureFormatter;
41 }
42 
43 namespace image {
44 
74 template <typename ImageT, typename MaskT = lsst::afw::image::MaskPixel,
75  typename VarianceT = lsst::afw::image::VariancePixel>
76 class Exposure : public lsst::daf::base::Persistable, public lsst::daf::base::Citizen {
77 public:
79 
80  // Class Constructors and Destructor
88  explicit Exposure(unsigned int width, unsigned int height,
89  std::shared_ptr<Wcs const> wcs = std::shared_ptr<Wcs const>());
90 
98  std::shared_ptr<Wcs const> wcs = std::shared_ptr<Wcs const>());
99 
106  explicit Exposure(lsst::afw::geom::Box2I const& bbox,
107  std::shared_ptr<Wcs const> wcs = std::shared_ptr<Wcs const>());
108 
114  explicit Exposure(MaskedImageT& maskedImage,
115  std::shared_ptr<Wcs const> wcs = std::shared_ptr<Wcs const>());
116 
124  explicit Exposure(MaskedImageT& maskedImage, std::shared_ptr<ExposureInfo> info);
125 
135  explicit Exposure(std::string const& fileName, geom::Box2I const& bbox = geom::Box2I(),
136  ImageOrigin origin = PARENT, bool conformMasks = false);
137 
147  explicit Exposure(fits::MemFileManager& manager, geom::Box2I const& bbox = geom::Box2I(),
148  ImageOrigin origin = PARENT, bool conformMasks = false);
149 
159  explicit Exposure(fits::Fits& fitsfile, geom::Box2I const& bbox = geom::Box2I(),
160  ImageOrigin origin = PARENT, bool conformMasks = false);
161 
167  Exposure(Exposure const& src, bool const deep = false);
168 
179  Exposure(Exposure const& src, lsst::afw::geom::Box2I const& bbox, ImageOrigin const origin = PARENT,
180  bool const deep = false);
181 
186  template <typename OtherPixelT>
188  const bool deep
189  )
190  : lsst::daf::base::Citizen(typeid(this)),
191  _maskedImage(rhs.getMaskedImage(), deep),
192  _info(new ExposureInfo(*rhs.getInfo(), deep)) {
193  if (not deep) {
194  throw LSST_EXCEPT(lsst::pex::exceptions::InvalidParameterError,
195  "Exposure's converting copy constructor must make a deep copy");
196  }
197  }
198 
201  virtual ~Exposure();
202 
203  // Get Members
205  MaskedImageT getMaskedImage() { return _maskedImage; }
207  MaskedImageT getMaskedImage() const { return _maskedImage; }
208 
209  std::shared_ptr<Wcs const> getWcs() const { return _info->getWcs(); }
210  std::shared_ptr<Wcs> getWcs() { return _info->getWcs(); }
211 
213  std::shared_ptr<lsst::afw::cameraGeom::Detector const> getDetector() const {
214  return _info->getDetector();
215  }
217  Filter getFilter() const { return _info->getFilter(); }
219  std::shared_ptr<lsst::daf::base::PropertySet> getMetadata() const { return _info->getMetadata(); }
220  void setMetadata(std::shared_ptr<lsst::daf::base::PropertySet> metadata) { _info->setMetadata(metadata); }
221 
223  int getWidth() const { return _maskedImage.getWidth(); }
225  int getHeight() const { return _maskedImage.getHeight(); }
227  geom::Extent2I getDimensions() const { return _maskedImage.getDimensions(); }
228 
234  int getX0() const { return _maskedImage.getX0(); }
240  int getY0() const { return _maskedImage.getY0(); }
241 
249  geom::Point2I getXY0() const { return _maskedImage.getXY0(); }
250 
251  geom::Box2I getBBox(ImageOrigin const origin = PARENT) const { return _maskedImage.getBBox(origin); }
260  void setXY0(geom::Point2I const& origin);
261 
262  // Set Members
265  void setMaskedImage(MaskedImageT& maskedImage);
266  void setWcs(std::shared_ptr<Wcs> wcs) { _info->setWcs(wcs); }
268  void setDetector(std::shared_ptr<lsst::afw::cameraGeom::Detector const> detector) {
269  _info->setDetector(detector);
270  }
272  void setFilter(Filter const& filter) { _info->setFilter(filter); }
274  void setCalib(std::shared_ptr<Calib> calib) { _info->setCalib(calib); }
276  std::shared_ptr<Calib> getCalib() { return _info->getCalib(); }
278  std::shared_ptr<Calib const> getCalib() const { return _info->getCalib(); }
280  void setPsf(std::shared_ptr<lsst::afw::detection::Psf const> psf) { _info->setPsf(psf); }
281 
283  std::shared_ptr<lsst::afw::detection::Psf> getPsf() { return _info->getPsf(); }
285  std::shared_ptr<lsst::afw::detection::Psf const> getPsf() const { return _info->getPsf(); }
286 
288  bool hasPsf() const { return _info->hasPsf(); }
289 
291  bool hasWcs() const { return _info->hasWcs(); }
292 
294  std::shared_ptr<ExposureInfo> getInfo() { return _info; }
295 
297  std::shared_ptr<ExposureInfo const> getInfo() const { return _info; }
298 
300  void setInfo(std::shared_ptr<ExposureInfo> exposureInfo) { _info = exposureInfo; }
301 
316  void writeFits(std::string const& fileName) const;
317 
325  void writeFits(fits::MemFileManager& manager) const;
326 
334  void writeFits(fits::Fits& fitsfile) const;
335 
341  static Exposure readFits(std::string const& filename) {
342  return Exposure<ImageT, MaskT, VarianceT>(filename);
343  }
344 
351  return Exposure<ImageT, MaskT, VarianceT>(manager);
352  }
353 
354 private:
356 
357  void _readFits(fits::Fits& fitsfile, geom::Box2I const& bbox, ImageOrigin origin, bool conformMasks);
358 
359  MaskedImageT _maskedImage;
360  std::shared_ptr<ExposureInfo> _info;
361 };
362 
366 template <typename ImagePixelT, typename MaskPixelT, typename VariancePixelT>
367 std::shared_ptr<Exposure<ImagePixelT, MaskPixelT, VariancePixelT>> makeExposure(
368  MaskedImage<ImagePixelT, MaskPixelT, VariancePixelT>& mimage,
369  std::shared_ptr<Wcs const> wcs = std::shared_ptr<Wcs const>()
370  ) {
371  return typename std::shared_ptr<Exposure<ImagePixelT, MaskPixelT, VariancePixelT>>(
373 }
374 }
375 }
376 } // lsst::afw::image
377 
378 #endif // LSST_AFW_IMAGE_EXPOSURE_H
int getHeight() const
Return the Exposure&#39;s height.
Definition: Exposure.h:225
void setFilter(Filter const &filter)
Set the Exposure&#39;s filter.
Definition: Exposure.h:272
afw::table::PointKey< int > dimensions
Definition: GaussianPsf.cc:44
virtual ~Exposure()
Destructor.
Definition: Exposure.cc:118
geom::Point2I getXY0() const
Return the Exposure&#39;s origin.
Definition: Exposure.h:249
geom::Box2I getBBox(ImageOrigin const origin=PARENT) const
Definition: Exposure.h:251
void setInfo(std::shared_ptr< ExposureInfo > exposureInfo)
Set the ExposureInfo that aggregates all the non-image components.
Definition: Exposure.h:300
std::shared_ptr< lsst::afw::detection::Psf const > getPsf() const
Return the Exposure&#39;s Psf object.
Definition: Exposure.h:285
void setCalib(std::shared_ptr< Calib > calib)
Set the Exposure&#39;s Calib object.
Definition: Exposure.h:274
A class to contain the data, WCS, and other information needed to describe an image of the sky...
Definition: Exposure.h:76
int getHeight() const
Return the number of rows in the image.
Definition: MaskedImage.h:998
bool hasWcs() const
Does this Exposure have a Wcs?
Definition: Exposure.h:291
int getX0() const
Return the image&#39;s column-origin.
Definition: MaskedImage.h:1008
std::shared_ptr< ExposureInfo > getInfo()
Get the ExposureInfo that aggregates all the non-image components. Never null.
Definition: Exposure.h:294
void setXY0(geom::Point2I const &origin)
Set the Exposure&#39;s origin (including correcting the Wcs)
Definition: Exposure.cc:128
bool hasPsf() const
Does this Exposure have a Psf?
Definition: Exposure.h:288
geom::Box2I getBBox(ImageOrigin const origin=PARENT) const
Definition: MaskedImage.h:1000
void setMetadata(std::shared_ptr< lsst::daf::base::PropertySet > metadata)
Definition: Exposure.h:220
void writeFits(std::string const &fileName) const
Write an Exposure to a regular multi-extension FITS file.
Definition: Exposure.cc:138
Exposure(unsigned int width, unsigned int height, std::shared_ptr< Wcs const > wcs=std::shared_ptr< Wcs const >())
Construct an Exposure with a blank MaskedImage of specified size (default 0x0) and a Wcs (which may b...
Definition: Exposure.cc:50
Implementation of the WCS standard for a any projection.
Definition: Wcs.h:104
int getX0() const
Return the Exposure&#39;s column-origin.
Definition: Exposure.h:234
std::shared_ptr< Exposure< ImagePixelT, MaskPixelT, VariancePixelT > > makeExposure(MaskedImage< ImagePixelT, MaskPixelT, VariancePixelT > &mimage, std::shared_ptr< Wcs const > wcs=std::shared_ptr< Wcs const >())
A function to return an Exposure of the correct type (cf.
Definition: Exposure.h:367
geom::Extent2I getDimensions() const
Return the Exposure&#39;s size.
Definition: Exposure.h:227
A simple struct that combines the two arguments that must be passed to most cfitsio routines and cont...
Definition: fits.h:199
MaskedImage< ImageT, MaskT, VarianceT > MaskedImageT
Definition: Exposure.h:78
MaskedImageT getMaskedImage() const
Return the MaskedImage.
Definition: Exposure.h:207
geom::Extent2I getDimensions() const
Definition: MaskedImage.h:999
static Exposure readFits(fits::MemFileManager &manager)
Read an Exposure from a FITS RAM file.
Definition: Exposure.h:350
An integer coordinate rectangle.
Definition: Box.h:55
std::shared_ptr< Wcs > getWcs()
Definition: Exposure.h:210
Class implementing persistence and retrieval for Exposures.
MaskedImageT getMaskedImage()
Return the MaskedImage.
Definition: Exposure.h:205
Lifetime-management for memory that goes into FITS memory files.
Definition: fits.h:100
std::shared_ptr< lsst::afw::cameraGeom::Detector const > getDetector() const
Return the Exposure&#39;s Detector information.
Definition: Exposure.h:213
void setMaskedImage(MaskedImageT &maskedImage)
Set the MaskedImage of the Exposure.
Definition: Exposure.cc:123
Filter getFilter() const
Return the Exposure&#39;s filter.
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:297
std::int32_t MaskPixel
default type for Masks and MaskedImage Masks
Holds an integer identifier for an LSST filter.
Definition: Filter.h:134
int getY0() const
Return the Exposure&#39;s row-origin.
Definition: Exposure.h:240
void setDetector(std::shared_ptr< lsst::afw::cameraGeom::Detector const > detector)
Set the Exposure&#39;s Detector information.
Definition: Exposure.h:268
std::shared_ptr< Calib const > getCalib() const
Return the Exposure&#39;s Calib object.
Definition: Exposure.h:278
std::shared_ptr< Calib > getCalib()
Return the Exposure&#39;s Calib object.
Definition: Exposure.h:276
static Exposure readFits(std::string const &filename)
Read an Exposure from a regular FITS file.
Definition: Exposure.h:341
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:187
std::shared_ptr< Wcs const > getWcs() const
Definition: Exposure.h:209
std::shared_ptr< lsst::afw::detection::Psf > getPsf()
Return the Exposure&#39;s Psf object.
Definition: Exposure.h:283
int getWidth() const
Return the Exposure&#39;s width.
Definition: Exposure.h:223
geom::Point2I getXY0() const
Return the image&#39;s origin.
Definition: MaskedImage.h:1024
void setPsf(std::shared_ptr< lsst::afw::detection::Psf const > psf)
Set the Exposure&#39;s Psf.
Definition: Exposure.h:280
afw::table::Key< afw::table::Array< ImagePixelT > > image
int getWidth() const
Return the number of columns in the image.
Definition: MaskedImage.h:996
int getY0() const
Return the image&#39;s row-origin.
Definition: MaskedImage.h:1016
A collection of all the things that make an Exposure different from a MaskedImage.
Definition: ExposureInfo.h:86
float VariancePixel
default type for MaskedImage variance images
std::shared_ptr< lsst::daf::base::PropertySet > getMetadata() const
Return flexible metadata.
Definition: Exposure.h:219
void setWcs(std::shared_ptr< Wcs > wcs)
Definition: Exposure.h:266