LSSTApplications  11.0-13-gbb96280,12.1.rc1,12.1.rc1+1,12.1.rc1+2,12.1.rc1+5,12.1.rc1+8,12.1.rc1-1-g06d7636+1,12.1.rc1-1-g253890b+5,12.1.rc1-1-g3d31b68+7,12.1.rc1-1-g3db6b75+1,12.1.rc1-1-g5c1385a+3,12.1.rc1-1-g83b2247,12.1.rc1-1-g90cb4cf+6,12.1.rc1-1-g91da24b+3,12.1.rc1-2-g3521f8a,12.1.rc1-2-g39433dd+4,12.1.rc1-2-g486411b+2,12.1.rc1-2-g4c2be76,12.1.rc1-2-gc9c0491,12.1.rc1-2-gda2cd4f+6,12.1.rc1-3-g3391c73+2,12.1.rc1-3-g8c1bd6c+1,12.1.rc1-3-gcf4b6cb+2,12.1.rc1-4-g057223e+1,12.1.rc1-4-g19ed13b+2,12.1.rc1-4-g30492a7
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 
81  explicit Exposure(
82  std::string const & fileName, geom::Box2I const& bbox=geom::Box2I(),
83  ImageOrigin origin=PARENT, bool conformMasks=false
84  );
85 
95  explicit Exposure(
96  fits::MemFileManager & manager, geom::Box2I const & bbox=geom::Box2I(),
97  ImageOrigin origin=PARENT, bool conformMasks=false
98  );
99 
109  explicit Exposure(
110  fits::Fits & fitsfile, geom::Box2I const & bbox=geom::Box2I(),
111  ImageOrigin origin=PARENT, bool conformMasks=false
112  );
113 
114  Exposure(
115  Exposure const &src,
116  bool const deep=false
117  );
118 
119  Exposure(
120  Exposure const &src,
121  lsst::afw::geom::Box2I const& bbox,
122  ImageOrigin const origin=PARENT,
123  bool const deep=false
124  );
125 
130  template<typename OtherPixelT>
132  const bool deep
133  ) :
134  lsst::daf::base::Citizen(typeid(this)),
135  _maskedImage(rhs.getMaskedImage(), deep),
136  _info(new ExposureInfo(*rhs.getInfo(), deep))
137  {
138  if (not deep) {
139  throw LSST_EXCEPT(lsst::pex::exceptions::InvalidParameterError,
140  "Exposure's converting copy constructor must make a deep copy");
141  }
142  }
143 
144  virtual ~Exposure();
145 
146  // Get Members
151 
152  CONST_PTR(Wcs) getWcs() const { return _info->getWcs(); }
153  PTR(Wcs) getWcs() { return _info->getWcs(); }
154 
156  CONST_PTR(lsst::afw::cameraGeom::Detector) getDetector() const { return _info->getDetector(); }
158  Filter getFilter() const { return _info->getFilter(); }
160  lsst::daf::base::PropertySet::Ptr getMetadata() const { return _info->getMetadata(); }
161  void setMetadata(lsst::daf::base::PropertySet::Ptr metadata) { _info->setMetadata(metadata); }
162 
164  int getWidth() const { return _maskedImage.getWidth(); }
166  int getHeight() const { return _maskedImage.getHeight(); }
169 
175  int getX0() const { return _maskedImage.getX0(); }
181  int getY0() const { return _maskedImage.getY0(); }
182 
190  geom::Point2I getXY0() const { return _maskedImage.getXY0(); }
191 
192  geom::Box2I getBBox(ImageOrigin const origin=PARENT) const {
193  return _maskedImage.getBBox(origin);
194  }
203  void setXY0(geom::Point2I const & origin);
204 
205  // Set Members
206  void setMaskedImage(MaskedImageT &maskedImage);
207  void setWcs(PTR(Wcs) wcs) { _info->setWcs(wcs); }
209  void setDetector(CONST_PTR(lsst::afw::cameraGeom::Detector) detector) { _info->setDetector(detector); }
211  void setFilter(Filter const& filter) { _info->setFilter(filter); }
213  void setCalib(PTR(Calib) calib) { _info->setCalib(calib); }
215  PTR(Calib) getCalib() { return _info->getCalib(); }
217  CONST_PTR(Calib) getCalib() const { return _info->getCalib(); }
219  void setPsf(CONST_PTR(lsst::afw::detection::Psf) psf) { _info->setPsf(psf); }
220 
222  PTR(lsst::afw::detection::Psf) getPsf() { return _info->getPsf(); }
224  CONST_PTR(lsst::afw::detection::Psf) getPsf() const { return _info->getPsf(); }
225 
227  bool hasPsf() const { return _info->hasPsf(); }
228 
230  bool hasWcs() const { return _info->hasWcs(); }
231 
233  PTR(ExposureInfo) getInfo() { return _info; }
234 
236  CONST_PTR(ExposureInfo) getInfo() const { return _info; }
237 
252  void writeFits(std::string const & fileName) const;
253 
261  void writeFits(fits::MemFileManager & manager) const;
262 
270  void writeFits(fits::Fits & fitsfile) const;
271 
277  static Exposure readFits(std::string const & filename) {
278  return Exposure<ImageT, MaskT, VarianceT>(filename);
279  }
280 
287  return Exposure<ImageT, MaskT, VarianceT>(manager);
288  }
289 
290 private:
292 
293  void _readFits(
294  fits::Fits & fitsfile, geom::Box2I const & bbox,
295  ImageOrigin origin, bool conformMasks
296  );
297 
300 };
301 
305 template <typename ImagePixelT, typename MaskPixelT, typename VariancePixelT>
306 typename Exposure<ImagePixelT, MaskPixelT, VariancePixelT>::Ptr makeExposure(
307  MaskedImage<ImagePixelT, MaskPixelT, VariancePixelT> & mimage,
308  CONST_PTR(Wcs) wcs = CONST_PTR(Wcs)()
309 ) {
312 }
313 
314 }}} // lsst::afw::image
315 
316 #endif // LSST_AFW_IMAGE_EXPOSURE_H
std::uint16_t MaskPixel
int getHeight() const
Return the Exposure&#39;s height.
Definition: Exposure.h:166
void setFilter(Filter const &filter)
Set the Exposure&#39;s filter.
Definition: Exposure.h:211
geom::Point2I getXY0() const
Definition: Exposure.h:190
geom::Box2I getBBox(ImageOrigin const origin=PARENT) const
Definition: Exposure.h:192
std::shared_ptr< PropertySet > Ptr
Definition: PropertySet.h:85
#define LSST_PERSIST_FORMATTER(formatter...)
Definition: Persistable.h:98
void setPsf(boost::shared_ptr< lsst::afw::detection::Psf const > psf)
Set the Exposure&#39;s Psf.
Definition: Exposure.h:219
void setCalib(boost::shared_ptr< Calib > calib)
Set the Exposure&#39;s Calib object.
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: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:230
boost::shared_ptr< Calib > getCalib()
Return the Exposure&#39;s Calib object.
Definition: Exposure.h:215
void setXY0(geom::Point2I const &origin)
Definition: Exposure.cc:225
bool hasPsf() const
Does this Exposure have a Psf?
Definition: Exposure.h:227
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:236
Implementation of the WCS standard for a any projection.
Definition: Wcs.h:107
std::shared_ptr< Exposure > Ptr
Definition: Exposure.h:50
std::shared_ptr< Exposure const > ConstPtr
Definition: Exposure.h:51
geom::Extent2I getDimensions() const
Return the Exposure&#39;s size.
Definition: Exposure.h:168
#define CONST_PTR(...)
Definition: base.h:47
A simple struct that combines the two arguments that must be passed to most cfitsio routines and cont...
Definition: fits.h:201
void _readFits(fits::Fits &fitsfile, geom::Box2I const &bbox, ImageOrigin origin, bool conformMasks)
Definition: Exposure.cc:199
MaskedImage< ImageT, MaskT, VarianceT > MaskedImageT
Definition: Exposure.h:49
MaskedImageT getMaskedImage() const
Return the MaskedImage.
Definition: Exposure.h:150
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:286
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:156
afw::table::PointKey< int > dimensions
Definition: GaussianPsf.cc:42
Class implementing persistence and retrieval for Exposures.
MaskedImageT getMaskedImage()
Return the MaskedImage.
Definition: Exposure.h:148
void setWcs(boost::shared_ptr< Wcs > wcs)
Definition: Exposure.h:207
lsst::daf::base::PropertySet::Ptr getMetadata() const
Return flexible metadata.
Definition: Exposure.h:160
Lifetime-management for memory that goes into FITS memory files.
Definition: fits.h:105
boost::shared_ptr< ExposureInfo > getInfo()
Get the ExposureInfo that aggregates all the non-image components. Never null.
Definition: Exposure.h:233
void setMaskedImage(MaskedImageT &maskedImage)
Set the MaskedImage of the Exposure.
Definition: Exposure.cc:220
Filter getFilter() const
Return the Exposure&#39;s filter.
Definition: Exposure.h:158
MaskedImageT _maskedImage
Definition: Exposure.h:298
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
boost::shared_ptr< Wcs const > getWcs() const
Definition: Exposure.h:152
boost::shared_ptr< lsst::afw::detection::Psf > getPsf()
Return the Exposure&#39;s Psf object.
Definition: Exposure.h:222
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
static Exposure readFits(std::string const &filename)
Read an Exposure from a regular FITS file.
Definition: Exposure.h:277
Exposure(Exposure< OtherPixelT, MaskT, VarianceT > const &rhs, const bool deep)
Definition: Exposure.h:131
Citizen(const std::type_info &)
Definition: Citizen.cc:174
boost::shared_ptr< ExposureInfo > _info
Definition: Exposure.h:299
int getWidth() const
Return the Exposure&#39;s width.
Definition: Exposure.h:164
geom::Point2I getXY0() const
Definition: MaskedImage.h:935
#define PTR(...)
Definition: base.h:41
int getWidth() const
Return the number of columns in the image.
Definition: MaskedImage.h:907
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:306
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:161
Citizen is a class that should be among all LSST classes base classes, and handles basic memory manag...
Definition: Citizen.h:53
A collection of all the things that make an Exposure different from a MaskedImage.
Definition: ExposureInfo.h:80
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
void setDetector(boost::shared_ptr< lsst::afw::cameraGeom::Detector const > detector)
Set the Exposure&#39;s Detector information.
Definition: Exposure.h:209