LSSTApplications  10.0-2-g4f67435,11.0.rc2+1,11.0.rc2+12,11.0.rc2+3,11.0.rc2+4,11.0.rc2+5,11.0.rc2+6,11.0.rc2+7,11.0.rc2+8
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 "boost/cstdint.hpp"
29 #include "boost/shared_ptr.hpp"
30 #include "boost/make_shared.hpp"
31 
32 #include "lsst/base.h"
33 #include "lsst/daf/base.h"
36 
37 namespace lsst { namespace afw {
38 
39 namespace formatters {
40  template<typename ImageT, typename MaskT, typename VarianceT> class ExposureFormatter;
41 }
42 
43 namespace image {
44 
46 template<typename ImageT, typename MaskT=lsst::afw::image::MaskPixel,
47  typename VarianceT=lsst::afw::image::VariancePixel>
50 public:
52  typedef boost::shared_ptr<Exposure> Ptr;
53  typedef boost::shared_ptr<Exposure const> ConstPtr;
54 
55  // Class Constructors and Destructor
56  explicit Exposure(
57  unsigned int width, unsigned int height,
59  );
60 
61  explicit Exposure(
64  );
65 
66  explicit Exposure(
67  lsst::afw::geom::Box2I const & bbox,
69  );
70 
71  explicit Exposure(MaskedImageT & maskedImage,
72  CONST_PTR(Wcs) wcs = CONST_PTR(Wcs)());
73 
83  explicit Exposure(
84  std::string const & fileName, geom::Box2I const& bbox=geom::Box2I(),
85  ImageOrigin origin=PARENT, bool conformMasks=false
86  );
87 
97  explicit Exposure(
98  fits::MemFileManager & manager, geom::Box2I const & bbox=geom::Box2I(),
99  ImageOrigin origin=PARENT, bool conformMasks=false
100  );
101 
111  explicit Exposure(
112  fits::Fits & fitsfile, geom::Box2I const & bbox=geom::Box2I(),
113  ImageOrigin origin=PARENT, bool conformMasks=false
114  );
115 
116  Exposure(
117  Exposure const &src,
118  bool const deep=false
119  );
120 
121  Exposure(
122  Exposure const &src,
123  lsst::afw::geom::Box2I const& bbox,
124  ImageOrigin const origin=PARENT,
125  bool const deep=false
126  );
127 
132  template<typename OtherPixelT>
134  const bool deep
135  ) :
136  lsst::daf::base::Citizen(typeid(this)),
137  _maskedImage(rhs.getMaskedImage(), deep),
138  _info(new ExposureInfo(*rhs.getInfo(), deep))
139  {
140  if (not deep) {
141  throw LSST_EXCEPT(lsst::pex::exceptions::InvalidParameterError,
142  "Exposure's converting copy constructor must make a deep copy");
143  }
144  }
145 
146  virtual ~Exposure();
147 
148  // Get Members
153 
154  CONST_PTR(Wcs) getWcs() const { return _info->getWcs(); }
155  PTR(Wcs) getWcs() { return _info->getWcs(); }
156 
158  CONST_PTR(lsst::afw::cameraGeom::Detector) getDetector() const { return _info->getDetector(); }
160  Filter getFilter() const { return _info->getFilter(); }
162  lsst::daf::base::PropertySet::Ptr getMetadata() const { return _info->getMetadata(); }
163  void setMetadata(lsst::daf::base::PropertySet::Ptr metadata) { _info->setMetadata(metadata); }
164 
166  int getWidth() const { return _maskedImage.getWidth(); }
168  int getHeight() const { return _maskedImage.getHeight(); }
171 
177  int getX0() const { return _maskedImage.getX0(); }
183  int getY0() const { return _maskedImage.getY0(); }
184 
192  geom::Point2I getXY0() const { return _maskedImage.getXY0(); }
193 
194  geom::Box2I getBBox(ImageOrigin const origin=PARENT) const {
195  return _maskedImage.getBBox(origin);
196  }
205  void setXY0(geom::Point2I const & origin);
206 
207  // Set Members
208  void setMaskedImage(MaskedImageT &maskedImage);
209  void setWcs(PTR(Wcs) wcs) { _info->setWcs(wcs); }
211  void setDetector(CONST_PTR(lsst::afw::cameraGeom::Detector) detector) { _info->setDetector(detector); }
213  void setFilter(Filter const& filter) { _info->setFilter(filter); }
215  void setCalib(PTR(Calib) calib) { _info->setCalib(calib); }
217  PTR(Calib) getCalib() { return _info->getCalib(); }
219  CONST_PTR(Calib) getCalib() const { return _info->getCalib(); }
221  void setPsf(CONST_PTR(lsst::afw::detection::Psf) psf) { _info->setPsf(psf); }
222 
224  PTR(lsst::afw::detection::Psf) getPsf() { return _info->getPsf(); }
226  CONST_PTR(lsst::afw::detection::Psf) getPsf() const { return _info->getPsf(); }
227 
229  bool hasPsf() const { return _info->hasPsf(); }
230 
232  bool hasWcs() const { return _info->hasWcs(); }
233 
235  PTR(ExposureInfo) getInfo() { return _info; }
236 
238  CONST_PTR(ExposureInfo) getInfo() const { return _info; }
239 
254  void writeFits(std::string const & fileName) const;
255 
263  void writeFits(fits::MemFileManager & manager) const;
264 
272  void writeFits(fits::Fits & fitsfile) const;
273 
279  static Exposure readFits(std::string const & filename) {
280  return Exposure<ImageT, MaskT, VarianceT>(filename);
281  }
282 
289  return Exposure<ImageT, MaskT, VarianceT>(manager);
290  }
291 
292 private:
294 
295  void _readFits(
296  fits::Fits & fitsfile, geom::Box2I const & bbox,
297  ImageOrigin origin, bool conformMasks
298  );
299 
302 };
303 
307 template <typename ImagePixelT, typename MaskPixelT, typename VariancePixelT>
308 typename Exposure<ImagePixelT, MaskPixelT, VariancePixelT>::Ptr makeExposure(
309  MaskedImage<ImagePixelT, MaskPixelT, VariancePixelT> & mimage,
310  CONST_PTR(Wcs) wcs = CONST_PTR(Wcs)()
311 ) {
314 }
315 
316 }}} // lsst::afw::image
317 
318 #endif // LSST_AFW_IMAGE_EXPOSURE_H
Filter getFilter() const
Return the Exposure&#39;s filter.
Definition: Exposure.h:160
boost::uint16_t MaskPixel
MaskedImageT getMaskedImage()
Return the MaskedImage.
Definition: Exposure.h:150
int getWidth() const
Return the number of columns in the image.
Definition: MaskedImage.h:901
boost::shared_ptr< lsst::afw::cameraGeom::Detector const > getDetector() const
Return the Exposure&#39;s Detector information.
Definition: Exposure.h:158
int getWidth() const
Return the Exposure&#39;s width.
Definition: Exposure.h:166
static Exposure readFits(fits::MemFileManager &manager)
Read an Exposure from a FITS RAM file.
Definition: Exposure.h:288
#define PTR(...)
Definition: base.h:41
boost::shared_ptr< Exposure > Ptr
Definition: Exposure.h:52
void setFilter(Filter const &filter)
Set the Exposure&#39;s filter.
Definition: Exposure.h:213
A class to contain the data, WCS, and other information needed to describe an image of the sky...
Definition: Exposure.h:48
void setCalib(boost::shared_ptr< Calib > calib)
Set the Exposure&#39;s Calib object.
Definition: Exposure.h:215
boost::shared_ptr< PropertySet > Ptr
Definition: PropertySet.h:90
#define CONST_PTR(...)
Definition: base.h:47
MaskedImageT _maskedImage
Definition: Exposure.h:300
int getY0() const
Definition: Exposure.h:183
tbl::Key< int > wcs
void _readFits(fits::Fits &fitsfile, geom::Box2I const &bbox, ImageOrigin origin, bool conformMasks)
Definition: Exposure.cc:200
Implementation of the WCS standard for a any projection.
Definition: Wcs.h:107
boost::shared_ptr< ExposureInfo > _info
Definition: Exposure.h:301
A simple struct that combines the two arguments that must be passed to most cfitsio routines and cont...
Definition: fits.h:194
An integer coordinate rectangle.
Definition: Box.h:53
table::Key< table::Array< Kernel::Pixel > > image
Definition: FixedKernel.cc:117
boost::shared_ptr< ExposureInfo > getInfo()
Get the ExposureInfo that aggregates all the non-image components. Never null.
Definition: Exposure.h:235
void setDetector(boost::shared_ptr< lsst::afw::cameraGeom::Detector const > detector)
Set the Exposure&#39;s Detector information.
Definition: Exposure.h:211
afw::table::PointKey< int > dimensions
boost::shared_ptr< Exposure const > ConstPtr
Definition: Exposure.h:53
void writeFits(std::string const &fileName) const
Write an Exposure to a regular multi-extension FITS file.
Definition: Exposure.cc:237
Class implementing persistence and retrieval for Exposures.
Lifetime-management for memory that goes into FITS memory files.
Definition: fits.h:106
geom::Box2I getBBox(ImageOrigin const origin=PARENT) const
Definition: MaskedImage.h:905
void setXY0(geom::Point2I const &origin)
Definition: Exposure.cc:226
int getHeight() const
Return the Exposure&#39;s height.
Definition: Exposure.h:168
float VariancePixel
! default type for Masks and MaskedImage Masks
geom::Point2I getXY0() const
Definition: MaskedImage.h:929
Holds an integer identifier for an LSST filter.
Definition: Filter.h:107
boost::shared_ptr< lsst::afw::detection::Psf > getPsf()
Return the Exposure&#39;s Psf object.
Definition: Exposure.h:224
bool hasWcs() const
Does this Exposure have a Wcs?
Definition: Exposure.h:232
lsst::daf::base::PropertySet::Ptr getMetadata() const
Return flexible metadata.
Definition: Exposure.h:162
#define LSST_PERSIST_FORMATTER(formatter...)
Definition: Persistable.h:98
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
int getX0() const
Definition: Exposure.h:177
Citizen(const std::type_info &)
Definition: Citizen.cc:173
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:85
MaskedImage< ImageT, MaskT, VarianceT > MaskedImageT
Definition: Exposure.h:51
geom::Box2I getBBox(ImageOrigin const origin=PARENT) const
Definition: Exposure.h:194
void setPsf(boost::shared_ptr< lsst::afw::detection::Psf const > psf)
Set the Exposure&#39;s Psf.
Definition: Exposure.h:221
Exposure(Exposure< OtherPixelT, MaskT, VarianceT > const &rhs, const bool deep)
Definition: Exposure.h:133
geom::Extent2I getDimensions() const
Return the Exposure&#39;s size.
Definition: Exposure.h:170
boost::shared_ptr< Calib > getCalib()
Return the Exposure&#39;s Calib object.
Definition: Exposure.h:217
Exposure< ImagePixelT, MaskPixelT, VariancePixelT >::Ptr makeExposure(MaskedImage< ImagePixelT, MaskPixelT, VariancePixelT > &mimage, boost::shared_ptr< Wcs const > wcs=boost::shared_ptr< Wcs const >())
Definition: Exposure.h:308
void setWcs(boost::shared_ptr< Wcs > wcs)
Definition: Exposure.h:209
bool hasPsf() const
Does this Exposure have a Psf?
Definition: Exposure.h:229
Base class for all persistable classes.
Definition: Persistable.h:74
Implementation of the Class MaskedImage.
Citizen is a class that should be among all LSST classes base classes, and handles basic memory manag...
Definition: Citizen.h:56
A collection of all the things that make an Exposure different from a MaskedImage.
Definition: ExposureInfo.h:80
boost::shared_ptr< Wcs const > getWcs() const
Definition: Exposure.h:154
A polymorphic base class for representing an image&#39;s Point Spread Function.
Definition: Psf.h:68
int getHeight() const
Return the number of rows in the image.
Definition: MaskedImage.h:903
geom::Extent2I getDimensions() const
Definition: MaskedImage.h:904
static Exposure readFits(std::string const &filename)
Read an Exposure from a regular FITS file.
Definition: Exposure.h:279
geom::Point2I getXY0() const
Definition: Exposure.h:192
void setMaskedImage(MaskedImageT &maskedImage)
Set the MaskedImage of the Exposure.
Definition: Exposure.cc:221
void setMetadata(lsst::daf::base::PropertySet::Ptr metadata)
Definition: Exposure.h:163
MaskedImageT getMaskedImage() const
Return the MaskedImage.
Definition: Exposure.h:152