lsst.afw  14.0-42-g99f9a3040+1
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>
77 public:
79 
80  // Class Constructors and Destructor
88  explicit Exposure(unsigned int width, unsigned int height,
90 
99 
106  explicit Exposure(lsst::afw::geom::Box2I const& bbox,
108 
114  explicit Exposure(MaskedImageT& maskedImage,
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  Exposure(Exposure&& src);
169 
180  Exposure(Exposure const& src, lsst::afw::geom::Box2I const& bbox, ImageOrigin const origin = PARENT,
181  bool const deep = false);
182 
187  template <typename OtherPixelT>
189  const bool deep
190  )
191  : lsst::daf::base::Citizen(typeid(this)),
192  _maskedImage(rhs.getMaskedImage(), deep),
193  _info(new ExposureInfo(*rhs.getInfo(), deep)) {
194  if (not deep) {
196  "Exposure's converting copy constructor must make a deep copy");
197  }
198  }
199 
200  Exposure& operator=(Exposure const&);
201  Exposure& operator=(Exposure&&);
202 
205  virtual ~Exposure();
206 
207  // Get Members
209  MaskedImageT getMaskedImage() { return _maskedImage; }
211  MaskedImageT getMaskedImage() const { return _maskedImage; }
212 
213  std::shared_ptr<Wcs const> getWcs() const { return _info->getWcs(); }
214  std::shared_ptr<Wcs> getWcs() { 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  geom::Extent2I getDimensions() const { return _maskedImage.getDimensions(); }
232 
238  int getX0() const { return _maskedImage.getX0(); }
244  int getY0() const { return _maskedImage.getY0(); }
245 
253  geom::Point2I getXY0() const { return _maskedImage.getXY0(); }
254 
255  geom::Box2I getBBox(ImageOrigin const origin = PARENT) const { return _maskedImage.getBBox(origin); }
264  void setXY0(geom::Point2I const& origin);
265 
266  // Set Members
269  void setMaskedImage(MaskedImageT& maskedImage);
270  void setWcs(std::shared_ptr<Wcs> wcs) { _info->setWcs(wcs); }
273  _info->setDetector(detector);
274  }
276  void setFilter(Filter const& filter) { _info->setFilter(filter); }
278  void setCalib(std::shared_ptr<Calib> calib) { _info->setCalib(calib); }
280  std::shared_ptr<Calib> getCalib() { return _info->getCalib(); }
282  std::shared_ptr<Calib const> getCalib() const { return _info->getCalib(); }
285 
289  std::shared_ptr<lsst::afw::detection::Psf const> getPsf() const { return _info->getPsf(); }
290 
292  bool hasPsf() const { return _info->hasPsf(); }
293 
295  bool hasWcs() const { return _info->hasWcs(); }
296 
299 
302 
304  void setInfo(std::shared_ptr<ExposureInfo> exposureInfo) { _info = exposureInfo; }
305 
320  void writeFits(std::string const& fileName) const;
321 
329  void writeFits(fits::MemFileManager& manager) const;
330 
338  void writeFits(fits::Fits& fitsfile) const;
339 
348  void writeFits(
349  std::string const& fileName,
350  fits::ImageWriteOptions const& imageOptions,
351  fits::ImageWriteOptions const& maskOptions,
352  fits::ImageWriteOptions const& varianceOptions
353  ) const;
354 
363  void writeFits(
364  fits::MemFileManager& manager,
365  fits::ImageWriteOptions const& imageOptions,
366  fits::ImageWriteOptions const& maskOptions,
367  fits::ImageWriteOptions const& varianceOptions
368  ) const;
369 
378  void writeFits(
379  fits::Fits& fitsfile,
380  fits::ImageWriteOptions const& imageOptions,
381  fits::ImageWriteOptions const& maskOptions,
382  fits::ImageWriteOptions const& varianceOptions
383  ) const;
384 
390  static Exposure readFits(std::string const& filename) {
391  return Exposure<ImageT, MaskT, VarianceT>(filename);
392  }
393 
400  return Exposure<ImageT, MaskT, VarianceT>(manager);
401  }
402 
403 private:
405 
406  void _readFits(fits::Fits& fitsfile, geom::Box2I const& bbox, ImageOrigin origin, bool conformMasks);
407 
408  MaskedImageT _maskedImage;
410 };
411 
415 template <typename ImagePixelT, typename MaskPixelT, typename VariancePixelT>
419  ) {
422 }
423 }
424 }
425 } // lsst::afw::image
426 
427 #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:276
std::shared_ptr< Calib const > getCalib() const
Return the Exposure&#39;s Calib object.
Definition: Exposure.h:282
geom::Box2I getBBox(ImageOrigin const origin=PARENT) const
Definition: Exposure.h:255
void setInfo(std::shared_ptr< ExposureInfo > exposureInfo)
Set the ExposureInfo that aggregates all the non-image components.
Definition: Exposure.h:304
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:278
A class to contain the data, WCS, and other information needed to describe an image of the sky...
Definition: Exposure.h:76
Options for writing an image to FITS.
Definition: fits.h:202
std::shared_ptr< ExposureInfo > getInfo()
Get the ExposureInfo that aggregates all the non-image components. Never null.
Definition: Exposure.h:298
void setMetadata(std::shared_ptr< lsst::daf::base::PropertySet > metadata)
Definition: Exposure.h:224
A simple struct that combines the two arguments that must be passed to most cfitsio routines and cont...
Definition: fits.h:280
MaskedImage< ImageT, MaskT, VarianceT > MaskedImageT
Definition: Exposure.h:78
bool hasWcs() const
Does this Exposure have a Wcs?
Definition: Exposure.h:295
std::shared_ptr< ExposureInfo const > getInfo() const
Get the ExposureInfo that aggregates all the non-image components. Never null.
Definition: Exposure.h:301
static Exposure readFits(fits::MemFileManager &manager)
Read an Exposure from a FITS RAM file.
Definition: Exposure.h:399
An integer coordinate rectangle.
Definition: Box.h:55
STL class.
afw::table::PointKey< int > dimensions
Definition: GaussianPsf.cc:44
std::shared_ptr< Wcs > getWcs()
Definition: Exposure.h:214
MaskedImageT getMaskedImage() const
Return the MaskedImage.
Definition: Exposure.h:211
Class implementing persistence and retrieval for Exposures.
A base class for image defects.
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:416
MaskedImageT getMaskedImage()
Return the MaskedImage.
Definition: Exposure.h:209
int getX0() const
Return the Exposure&#39;s column-origin.
Definition: Exposure.h:238
Lifetime-management for memory that goes into FITS memory files.
Definition: fits.h:102
std::shared_ptr< Wcs const > getWcs() const
Definition: Exposure.h:213
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:292
std::int32_t MaskPixel
default type for Masks and MaskedImage Masks
Holds an integer identifier for an LSST filter.
Definition: Filter.h:141
geom::Point2I getXY0() const
Return the Exposure&#39;s origin.
Definition: Exposure.h:253
std::shared_ptr< Calib > getCalib()
Return the Exposure&#39;s Calib object.
Definition: Exposure.h:280
#define LSST_EXCEPT(type,...)
static Exposure readFits(std::string const &filename)
Read an Exposure from a regular FITS file.
Definition: Exposure.h:390
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:188
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:287
void setDetector(std::shared_ptr< lsst::afw::cameraGeom::Detector const > detector)
Set the Exposure&#39;s Detector information.
Definition: Exposure.h:272
#define LSST_PERSIST_FORMATTER(formatter...)
table::Box2IKey bbox
std::shared_ptr< lsst::afw::detection::Psf const > getPsf() const
Return the Exposure&#39;s Psf object.
Definition: Exposure.h:289
geom::Extent2I getDimensions() const
Return the Exposure&#39;s size.
Definition: Exposure.h:231
void setPsf(std::shared_ptr< lsst::afw::detection::Psf const > psf)
Set the Exposure&#39;s Psf.
Definition: Exposure.h:284
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
void setWcs(std::shared_ptr< Wcs > wcs)
Definition: Exposure.h:270