lsst.afw  14.0-35-g29d3a87a7
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 
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) {
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 
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); }
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(); }
281 
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 
295 
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 
344  void writeFits(
345  std::string const& fileName,
346  fits::ImageWriteOptions const& imageOptions,
347  fits::ImageWriteOptions const& maskOptions,
348  fits::ImageWriteOptions const& varianceOptions
349  ) const;
350 
359  void writeFits(
360  fits::MemFileManager& manager,
361  fits::ImageWriteOptions const& imageOptions,
362  fits::ImageWriteOptions const& maskOptions,
363  fits::ImageWriteOptions const& varianceOptions
364  ) const;
365 
374  void writeFits(
375  fits::Fits& fitsfile,
376  fits::ImageWriteOptions const& imageOptions,
377  fits::ImageWriteOptions const& maskOptions,
378  fits::ImageWriteOptions const& varianceOptions
379  ) const;
380 
386  static Exposure readFits(std::string const& filename) {
387  return Exposure<ImageT, MaskT, VarianceT>(filename);
388  }
389 
396  return Exposure<ImageT, MaskT, VarianceT>(manager);
397  }
398 
399 private:
401 
402  void _readFits(fits::Fits& fitsfile, geom::Box2I const& bbox, ImageOrigin origin, bool conformMasks);
403 
404  MaskedImageT _maskedImage;
406 };
407 
411 template <typename ImagePixelT, typename MaskPixelT, typename VariancePixelT>
415  ) {
418 }
419 }
420 }
421 } // lsst::afw::image
422 
423 #endif // LSST_AFW_IMAGE_EXPOSURE_H
int getWidth() const
Return the Exposure&#39;s width.
Definition: Exposure.h:223
void setFilter(Filter const &filter)
Set the Exposure&#39;s filter.
Definition: Exposure.h:272
std::shared_ptr< Calib const > getCalib() const
Return the Exposure&#39;s Calib object.
Definition: Exposure.h:278
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
getInfo
int getHeight() const
Return the Exposure&#39;s height.
Definition: Exposure.h:225
int getY0() const
Return the Exposure&#39;s row-origin.
Definition: Exposure.h:240
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
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:294
void setMetadata(std::shared_ptr< lsst::daf::base::PropertySet > metadata)
Definition: Exposure.h:220
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:291
std::shared_ptr< ExposureInfo const > getInfo() const
Get the ExposureInfo that aggregates all the non-image components. Never null.
Definition: Exposure.h:297
static Exposure readFits(fits::MemFileManager &manager)
Read an Exposure from a FITS RAM file.
Definition: Exposure.h:395
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:210
MaskedImageT getMaskedImage() const
Return the MaskedImage.
Definition: Exposure.h:207
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:412
MaskedImageT getMaskedImage()
Return the MaskedImage.
Definition: Exposure.h:205
int getX0() const
Return the Exposure&#39;s column-origin.
Definition: Exposure.h:234
Lifetime-management for memory that goes into FITS memory files.
Definition: fits.h:102
std::shared_ptr< Wcs const > getWcs() const
Definition: Exposure.h:209
std::shared_ptr< lsst::daf::base::PropertySet > getMetadata() const
Return flexible metadata.
Definition: Exposure.h:219
bool hasPsf() const
Does this Exposure have a Psf?
Definition: Exposure.h:288
std::int32_t MaskPixel
default type for Masks and MaskedImage Masks
Holds an integer identifier for an LSST filter.
Definition: Filter.h:134
geom::Point2I getXY0() const
Return the Exposure&#39;s origin.
Definition: Exposure.h:249
std::shared_ptr< Calib > getCalib()
Return the Exposure&#39;s Calib object.
Definition: Exposure.h:276
#define LSST_EXCEPT(type,...)
static Exposure readFits(std::string const &filename)
Read an Exposure from a regular FITS file.
Definition: Exposure.h:386
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
Filter getFilter() const
Return the Exposure&#39;s filter.
Definition: Exposure.h:217
std::shared_ptr< lsst::afw::detection::Psf > getPsf()
Return the Exposure&#39;s Psf object.
Definition: Exposure.h:283
void setDetector(std::shared_ptr< lsst::afw::cameraGeom::Detector const > detector)
Set the Exposure&#39;s Detector information.
Definition: Exposure.h:268
#define LSST_PERSIST_FORMATTER(formatter...)
std::shared_ptr< lsst::afw::detection::Psf const > getPsf() const
Return the Exposure&#39;s Psf object.
Definition: Exposure.h:285
geom::Extent2I getDimensions() const
Return the Exposure&#39;s size.
Definition: Exposure.h:227
void setPsf(std::shared_ptr< lsst::afw::detection::Psf const > psf)
Set the Exposure&#39;s Psf.
Definition: Exposure.h:280
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:213
void setWcs(std::shared_ptr< Wcs > wcs)
Definition: Exposure.h:266