LSSTApplications  11.0-13-gbb96280,12.1+18,12.1+7,12.1-1-g14f38d3+72,12.1-1-g16c0db7+5,12.1-1-g5961e7a+84,12.1-1-ge22e12b+23,12.1-11-g06625e2+4,12.1-11-g0d7f63b+4,12.1-19-gd507bfc,12.1-2-g7dda0ab+38,12.1-2-gc0bc6ab+81,12.1-21-g6ffe579+2,12.1-21-gbdb6c2a+4,12.1-24-g941c398+5,12.1-3-g57f6835+7,12.1-3-gf0736f3,12.1-37-g3ddd237,12.1-4-gf46015e+5,12.1-5-g06c326c+20,12.1-5-g648ee80+3,12.1-5-gc2189d7+4,12.1-6-ga608fc0+1,12.1-7-g3349e2a+5,12.1-7-gfd75620+9,12.1-9-g577b946+5,12.1-9-gc4df26a+10
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 
35 namespace lsst { namespace afw {
36 
37 namespace formatters {
38  template<typename ImageT, typename MaskT, typename VarianceT> class ExposureFormatter;
39 }
40 
41 namespace image {
42 
44 template<typename ImageT, typename MaskT=lsst::afw::image::MaskPixel,
45  typename VarianceT=lsst::afw::image::VariancePixel>
48 public:
50  typedef std::shared_ptr<Exposure> Ptr;
51  typedef std::shared_ptr<Exposure const> ConstPtr;
52 
53  // Class Constructors and Destructor
54  explicit Exposure(
55  unsigned int width, unsigned int height,
57  );
58 
59  explicit Exposure(
62  );
63 
64  explicit Exposure(
65  lsst::afw::geom::Box2I const & bbox,
67  );
68 
69  explicit Exposure(MaskedImageT & maskedImage,
70  CONST_PTR(Wcs) wcs = CONST_PTR(Wcs)());
71 
72  explicit Exposure(
73  MaskedImageT & maskedImage,
75  );
76 
86  explicit Exposure(
87  std::string const & fileName, geom::Box2I const& bbox=geom::Box2I(),
88  ImageOrigin origin=PARENT, bool conformMasks=false
89  );
90 
100  explicit Exposure(
101  fits::MemFileManager & manager, geom::Box2I const & bbox=geom::Box2I(),
102  ImageOrigin origin=PARENT, bool conformMasks=false
103  );
104 
114  explicit Exposure(
115  fits::Fits & fitsfile, geom::Box2I const & bbox=geom::Box2I(),
116  ImageOrigin origin=PARENT, bool conformMasks=false
117  );
118 
119  Exposure(
120  Exposure const &src,
121  bool const deep=false
122  );
123 
124  Exposure(
125  Exposure const &src,
126  lsst::afw::geom::Box2I const& bbox,
127  ImageOrigin const origin=PARENT,
128  bool const deep=false
129  );
130 
135  template<typename OtherPixelT>
137  const bool deep
138  ) :
139  lsst::daf::base::Citizen(typeid(this)),
140  _maskedImage(rhs.getMaskedImage(), deep),
141  _info(new ExposureInfo(*rhs.getInfo(), deep))
142  {
143  if (not deep) {
144  throw LSST_EXCEPT(lsst::pex::exceptions::InvalidParameterError,
145  "Exposure's converting copy constructor must make a deep copy");
146  }
147  }
148 
149  virtual ~Exposure();
150 
151  // Get Members
156 
157  CONST_PTR(Wcs) getWcs() const { return _info->getWcs(); }
158  PTR(Wcs) getWcs() { return _info->getWcs(); }
159 
161  CONST_PTR(lsst::afw::cameraGeom::Detector) getDetector() const { return _info->getDetector(); }
163  Filter getFilter() const { return _info->getFilter(); }
165  lsst::daf::base::PropertySet::Ptr getMetadata() const { return _info->getMetadata(); }
166  void setMetadata(lsst::daf::base::PropertySet::Ptr metadata) { _info->setMetadata(metadata); }
167 
169  int getWidth() const { return _maskedImage.getWidth(); }
171  int getHeight() const { return _maskedImage.getHeight(); }
174 
180  int getX0() const { return _maskedImage.getX0(); }
186  int getY0() const { return _maskedImage.getY0(); }
187 
195  geom::Point2I getXY0() const { return _maskedImage.getXY0(); }
196 
197  geom::Box2I getBBox(ImageOrigin const origin=PARENT) const {
198  return _maskedImage.getBBox(origin);
199  }
208  void setXY0(geom::Point2I const & origin);
209 
210  // Set Members
211  void setMaskedImage(MaskedImageT &maskedImage);
212  void setWcs(PTR(Wcs) wcs) { _info->setWcs(wcs); }
214  void setDetector(CONST_PTR(lsst::afw::cameraGeom::Detector) detector) { _info->setDetector(detector); }
216  void setFilter(Filter const& filter) { _info->setFilter(filter); }
218  void setCalib(PTR(Calib) calib) { _info->setCalib(calib); }
220  PTR(Calib) getCalib() { return _info->getCalib(); }
222  CONST_PTR(Calib) getCalib() const { return _info->getCalib(); }
224  void setPsf(CONST_PTR(lsst::afw::detection::Psf) psf) { _info->setPsf(psf); }
225 
227  PTR(lsst::afw::detection::Psf) getPsf() { return _info->getPsf(); }
229  CONST_PTR(lsst::afw::detection::Psf) getPsf() const { return _info->getPsf(); }
230 
232  bool hasPsf() const { return _info->hasPsf(); }
233 
235  bool hasWcs() const { return _info->hasWcs(); }
236 
238  PTR(ExposureInfo) getInfo() { return _info; }
239 
241  CONST_PTR(ExposureInfo) getInfo() const { return _info; }
242 
244  void setInfo(PTR(ExposureInfo) exposureInfo) { _info = exposureInfo; }
245 
260  void writeFits(std::string const & fileName) const;
261 
269  void writeFits(fits::MemFileManager & manager) const;
270 
278  void writeFits(fits::Fits & fitsfile) const;
279 
285  static Exposure readFits(std::string const & filename) {
286  return Exposure<ImageT, MaskT, VarianceT>(filename);
287  }
288 
295  return Exposure<ImageT, MaskT, VarianceT>(manager);
296  }
297 
298 private:
300 
301  void _readFits(
302  fits::Fits & fitsfile, geom::Box2I const & bbox,
303  ImageOrigin origin, bool conformMasks
304  );
305 
308 };
309 
313 template <typename ImagePixelT, typename MaskPixelT, typename VariancePixelT>
314 typename Exposure<ImagePixelT, MaskPixelT, VariancePixelT>::Ptr makeExposure(
315  MaskedImage<ImagePixelT, MaskPixelT, VariancePixelT> & mimage,
316  CONST_PTR(Wcs) wcs = CONST_PTR(Wcs)()
317 ) {
320 }
321 
322 }}} // lsst::afw::image
323 
324 #endif // LSST_AFW_IMAGE_EXPOSURE_H
std::uint16_t MaskPixel
int getHeight() const
Return the Exposure&#39;s height.
Definition: Exposure.h:171
void setFilter(Filter const &filter)
Set the Exposure&#39;s filter.
Definition: Exposure.h:216
virtual ~Exposure()
Destructor.
Definition: Exposure.cc:226
geom::Point2I getXY0() const
Return the Exposure&#39;s origin.
Definition: Exposure.h:195
geom::Box2I getBBox(ImageOrigin const origin=PARENT) const
Definition: Exposure.h:197
#define LSST_PERSIST_FORMATTER(formatter...)
Macro used to connect the persistable class with the Formatter and boost::serialization.
Definition: Persistable.h:98
Citizen(const std::type_info &)
Definition: Citizen.cc:174
void setPsf(boost::shared_ptr< lsst::afw::detection::Psf const > psf)
Set the Exposure&#39;s Psf.
Definition: Exposure.h:224
def info
Definition: log.py:95
void setCalib(boost::shared_ptr< Calib > calib)
Set the Exposure&#39;s Calib object.
Definition: Exposure.h:218
A class to contain the data, WCS, and other information needed to describe an image of the sky...
Definition: Exposure.h:46
int getHeight() const
Return the number of rows in the image.
Definition: MaskedImage.h:909
bool hasWcs() const
Does this Exposure have a Wcs?
Definition: Exposure.h:235
boost::shared_ptr< Calib > getCalib()
Return the Exposure&#39;s Calib object.
Definition: Exposure.h:220
int getX0() const
Return the image&#39;s column-origin.
Definition: MaskedImage.h:919
void setXY0(geom::Point2I const &origin)
Set the Exposure&#39;s origin (including correcting the Wcs)
Definition: Exposure.cc:238
bool hasPsf() const
Does this Exposure have a Psf?
Definition: Exposure.h:232
geom::Box2I getBBox(ImageOrigin const origin=PARENT) const
Definition: MaskedImage.h:911
tbl::Key< int > wcs
void writeFits(std::string const &fileName) const
Write an Exposure to a regular multi-extension FITS file.
Definition: Exposure.cc:249
Implementation of the WCS standard for a any projection.
Definition: Wcs.h:107
std::shared_ptr< Exposure > Ptr
Definition: Exposure.h:50
int getX0() const
Return the Exposure&#39;s column-origin.
Definition: Exposure.h:180
std::shared_ptr< Exposure const > ConstPtr
Definition: Exposure.h:51
geom::Extent2I getDimensions() const
Return the Exposure&#39;s size.
Definition: Exposure.h:173
A simple struct that combines the two arguments that must be passed to most cfitsio routines and cont...
Definition: fits.h:202
void _readFits(fits::Fits &fitsfile, geom::Box2I const &bbox, ImageOrigin origin, bool conformMasks)
Definition: Exposure.cc:212
MaskedImage< ImageT, MaskT, VarianceT > MaskedImageT
Definition: Exposure.h:49
MaskedImageT getMaskedImage() const
Return the MaskedImage.
Definition: Exposure.h:155
geom::Extent2I getDimensions() const
Definition: MaskedImage.h:910
static Exposure readFits(fits::MemFileManager &manager)
Read an Exposure from a FITS RAM file.
Definition: Exposure.h:294
Describe an exposure&#39;s calibration.
Definition: Calib.h:82
An integer coordinate rectangle.
Definition: Box.h:53
table::Key< table::Array< Kernel::Pixel > > image
Definition: FixedKernel.cc:117
boost::shared_ptr< lsst::afw::cameraGeom::Detector const > getDetector() const
Return the Exposure&#39;s Detector information.
Definition: Exposure.h:161
afw::table::PointKey< int > dimensions
Definition: GaussianPsf.cc:42
Class implementing persistence and retrieval for Exposures.
void ImageT ImageT int float saturatedPixelValue int const width
Definition: saturated.cc:44
MaskedImageT getMaskedImage()
Return the MaskedImage.
Definition: Exposure.h:153
void setWcs(boost::shared_ptr< Wcs > wcs)
Definition: Exposure.h:212
lsst::daf::base::PropertySet::Ptr getMetadata() const
Return flexible metadata.
Definition: Exposure.h:165
Lifetime-management for memory that goes into FITS memory files.
Definition: fits.h:106
boost::shared_ptr< ExposureInfo > getInfo()
Get the ExposureInfo that aggregates all the non-image components. Never null.
Definition: Exposure.h:238
void setMaskedImage(MaskedImageT &maskedImage)
Set the MaskedImage of the Exposure.
Definition: Exposure.cc:233
Filter getFilter() const
Return the Exposure&#39;s filter.
Definition: Exposure.h:163
MaskedImageT _maskedImage
Definition: Exposure.h:306
Exposure(unsigned int width, unsigned int height, boost::shared_ptr< Wcs const > wcs=boost::shared_ptr< Wcs const >())
Exposure Class Implementation for LSST: a templated framework class for creating an Exposure from a M...
Definition: Exposure.cc:84
Holds an integer identifier for an LSST filter.
Definition: Filter.h:108
int getY0() const
Return the Exposure&#39;s row-origin.
Definition: Exposure.h:186
void ImageT ImageT int float saturatedPixelValue int const height
Definition: saturated.cc:44
boost::shared_ptr< Wcs const > getWcs() const
Definition: Exposure.h:157
boost::shared_ptr< lsst::afw::detection::Psf > getPsf()
Return the Exposure&#39;s Psf object.
Definition: Exposure.h:227
#define LSST_EXCEPT(type,...)
Create an exception with a given type and message and optionally other arguments (dependent on the ty...
Definition: Exception.h:46
Information about a CCD or other imaging detector.
Definition: Detector.h:65
static Exposure readFits(std::string const &filename)
Read an Exposure from a regular FITS file.
Definition: Exposure.h:285
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:136
boost::shared_ptr< ExposureInfo > _info
Definition: Exposure.h:307
#define PTR(...)
Definition: base.h:41
int getWidth() const
Return the Exposure&#39;s width.
Definition: Exposure.h:169
geom::Point2I getXY0() const
Return the image&#39;s origin.
Definition: MaskedImage.h:935
int getWidth() const
Return the number of columns in the image.
Definition: MaskedImage.h:907
int getY0() const
Return the image&#39;s row-origin.
Definition: MaskedImage.h:927
Exposure< ImagePixelT, MaskPixelT, VariancePixelT >::Ptr makeExposure(MaskedImage< ImagePixelT, MaskPixelT, VariancePixelT > &mimage, boost::shared_ptr< Wcs const > wcs=boost::shared_ptr< Wcs const >())
A function to return an Exposure of the correct type (cf.
Definition: Exposure.h:314
Base class for all persistable classes.
Definition: Persistable.h:74
Implementation of the Class MaskedImage.
void setMetadata(lsst::daf::base::PropertySet::Ptr metadata)
Definition: Exposure.h:166
Citizen is a class that should be among all LSST classes base classes, and handles basic memory manag...
Definition: Citizen.h:53
void setInfo(boost::shared_ptr< ExposureInfo > exposureInfo)
Set the ExposureInfo that aggregates all the non-image components.
Definition: Exposure.h:244
#define CONST_PTR(...)
A shared pointer to a const object.
Definition: base.h:47
std::shared_ptr< PropertySet > Ptr
Definition: PropertySet.h:85
A collection of all the things that make an Exposure different from a MaskedImage.
Definition: ExposureInfo.h:83
A polymorphic base class for representing an image&#39;s Point Spread Function.
Definition: Psf.h:68
float VariancePixel
! default type for Masks and MaskedImage Masks
Basic LSST definitions.
void setDetector(boost::shared_ptr< lsst::afw::cameraGeom::Detector const > detector)
Set the Exposure&#39;s Detector information.
Definition: Exposure.h:214