lsst.afw  14.0-52-g19103d347
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 
105  explicit Exposure(lsst::afw::geom::Box2I const& bbox,
107 
113  explicit Exposure(MaskedImageT& maskedImage,
115 
123  explicit Exposure(MaskedImageT& maskedImage, std::shared_ptr<ExposureInfo> info);
124 
134  explicit Exposure(std::string const& fileName, geom::Box2I const& bbox = geom::Box2I(),
135  ImageOrigin origin = PARENT, bool conformMasks = false);
136 
146  explicit Exposure(fits::MemFileManager& manager, geom::Box2I const& bbox = geom::Box2I(),
147  ImageOrigin origin = PARENT, bool conformMasks = false);
148 
158  explicit Exposure(fits::Fits& fitsfile, geom::Box2I const& bbox = geom::Box2I(),
159  ImageOrigin origin = PARENT, bool conformMasks = false);
160 
166  Exposure(Exposure const& src, bool const deep = false);
167  Exposure(Exposure&& src);
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 
199  Exposure& operator=(Exposure const&);
200  Exposure& operator=(Exposure&&);
201 
204  virtual ~Exposure();
205 
206  // Get Members
208  MaskedImageT getMaskedImage() { return _maskedImage; }
210  MaskedImageT getMaskedImage() const { return _maskedImage; }
211 
212  std::shared_ptr<geom::SkyWcs const> getWcs() const { return _info->getWcs(); }
213 
216  return _info->getDetector();
217  }
219  Filter getFilter() const { return _info->getFilter(); }
221  std::shared_ptr<lsst::daf::base::PropertySet> getMetadata() const { return _info->getMetadata(); }
222  void setMetadata(std::shared_ptr<lsst::daf::base::PropertySet> metadata) { _info->setMetadata(metadata); }
223 
225  int getWidth() const { return _maskedImage.getWidth(); }
227  int getHeight() const { return _maskedImage.getHeight(); }
229  geom::Extent2I getDimensions() const { return _maskedImage.getDimensions(); }
230 
236  int getX0() const { return _maskedImage.getX0(); }
242  int getY0() const { return _maskedImage.getY0(); }
243 
251  geom::Point2I getXY0() const { return _maskedImage.getXY0(); }
252 
253  geom::Box2I getBBox(ImageOrigin const origin = PARENT) const { return _maskedImage.getBBox(origin); }
262  void setXY0(geom::Point2I const& origin);
263 
264  // Set Members
267  void setMaskedImage(MaskedImageT& maskedImage);
268  void setWcs(std::shared_ptr<geom::SkyWcs> wcs) { _info->setWcs(wcs); }
271  _info->setDetector(detector);
272  }
274  void setFilter(Filter const& filter) { _info->setFilter(filter); }
276  void setCalib(std::shared_ptr<Calib> calib) { _info->setCalib(calib); }
278  std::shared_ptr<Calib> getCalib() { return _info->getCalib(); }
280  std::shared_ptr<Calib const> getCalib() const { return _info->getCalib(); }
283 
287  std::shared_ptr<lsst::afw::detection::Psf const> getPsf() const { return _info->getPsf(); }
288 
290  bool hasPsf() const { return _info->hasPsf(); }
291 
293  bool hasWcs() const { return _info->hasWcs(); }
294 
297 
300 
302  void setInfo(std::shared_ptr<ExposureInfo> exposureInfo) { _info = exposureInfo; }
303 
318  void writeFits(std::string const& fileName) const;
319 
327  void writeFits(fits::MemFileManager& manager) const;
328 
336  void writeFits(fits::Fits& fitsfile) const;
337 
346  void writeFits(
347  std::string const& fileName,
348  fits::ImageWriteOptions const& imageOptions,
349  fits::ImageWriteOptions const& maskOptions,
350  fits::ImageWriteOptions const& varianceOptions
351  ) const;
352 
361  void writeFits(
362  fits::MemFileManager& manager,
363  fits::ImageWriteOptions const& imageOptions,
364  fits::ImageWriteOptions const& maskOptions,
365  fits::ImageWriteOptions const& varianceOptions
366  ) const;
367 
376  void writeFits(
377  fits::Fits& fitsfile,
378  fits::ImageWriteOptions const& imageOptions,
379  fits::ImageWriteOptions const& maskOptions,
380  fits::ImageWriteOptions const& varianceOptions
381  ) const;
382 
388  static Exposure readFits(std::string const& filename) {
389  return Exposure<ImageT, MaskT, VarianceT>(filename);
390  }
391 
398  return Exposure<ImageT, MaskT, VarianceT>(manager);
399  }
400 
401 private:
403 
404  void _readFits(fits::Fits& fitsfile, geom::Box2I const& bbox, ImageOrigin origin, bool conformMasks);
405 
406  MaskedImageT _maskedImage;
408 };
409 
413 template <typename ImagePixelT, typename MaskPixelT, typename VariancePixelT>
417  ) {
420 }
421 }
422 }
423 } // lsst::afw::image
424 
425 #endif // LSST_AFW_IMAGE_EXPOSURE_H
int getWidth() const
Return the Exposure&#39;s width.
Definition: Exposure.h:225
void setFilter(Filter const &filter)
Set the Exposure&#39;s filter.
Definition: Exposure.h:274
std::shared_ptr< Calib const > getCalib() const
Return the Exposure&#39;s Calib object.
Definition: Exposure.h:280
geom::Box2I getBBox(ImageOrigin const origin=PARENT) const
Definition: Exposure.h:253
void setInfo(std::shared_ptr< ExposureInfo > exposureInfo)
Set the ExposureInfo that aggregates all the non-image components.
Definition: Exposure.h:302
getInfo
int getHeight() const
Return the Exposure&#39;s height.
Definition: Exposure.h:227
int getY0() const
Return the Exposure&#39;s row-origin.
Definition: Exposure.h:242
void setCalib(std::shared_ptr< Calib > calib)
Set the Exposure&#39;s Calib object.
Definition: Exposure.h:276
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:220
void setWcs(std::shared_ptr< geom::SkyWcs > wcs)
Definition: Exposure.h:268
std::shared_ptr< ExposureInfo > getInfo()
Get the ExposureInfo that aggregates all the non-image components. Never null.
Definition: Exposure.h:296
void setMetadata(std::shared_ptr< lsst::daf::base::PropertySet > metadata)
Definition: Exposure.h:222
A simple struct that combines the two arguments that must be passed to most cfitsio routines and cont...
Definition: fits.h:298
MaskedImage< ImageT, MaskT, VarianceT > MaskedImageT
Definition: Exposure.h:78
bool hasWcs() const
Does this Exposure have a Wcs?
Definition: Exposure.h:293
std::shared_ptr< ExposureInfo const > getInfo() const
Get the ExposureInfo that aggregates all the non-image components. Never null.
Definition: Exposure.h:299
static Exposure readFits(fits::MemFileManager &manager)
Read an Exposure from a FITS RAM file.
Definition: Exposure.h:397
An integer coordinate rectangle.
Definition: Box.h:55
STL class.
std::shared_ptr< Exposure< ImagePixelT, MaskPixelT, VariancePixelT > > makeExposure(MaskedImage< ImagePixelT, MaskPixelT, VariancePixelT > &mimage, std::shared_ptr< geom::SkyWcs const > wcs=std::shared_ptr< geom::SkyWcs const >())
A function to return an Exposure of the correct type (cf.
Definition: Exposure.h:414
afw::table::PointKey< int > dimensions
Definition: GaussianPsf.cc:44
MaskedImageT getMaskedImage() const
Return the MaskedImage.
Definition: Exposure.h:210
Class implementing persistence and retrieval for Exposures.
A base class for image defects.
MaskedImageT getMaskedImage()
Return the MaskedImage.
Definition: Exposure.h:208
int getX0() const
Return the Exposure&#39;s column-origin.
Definition: Exposure.h:236
Lifetime-management for memory that goes into FITS memory files.
Definition: fits.h:120
std::shared_ptr< lsst::daf::base::PropertySet > getMetadata() const
Return flexible metadata.
Definition: Exposure.h:221
bool hasPsf() const
Does this Exposure have a Psf?
Definition: Exposure.h:290
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:251
std::shared_ptr< Calib > getCalib()
Return the Exposure&#39;s Calib object.
Definition: Exposure.h:278
#define LSST_EXCEPT(type,...)
static Exposure readFits(std::string const &filename)
Read an Exposure from a regular FITS file.
Definition: Exposure.h:388
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:219
std::shared_ptr< lsst::afw::detection::Psf > getPsf()
Return the Exposure&#39;s Psf object.
Definition: Exposure.h:285
void setDetector(std::shared_ptr< lsst::afw::cameraGeom::Detector const > detector)
Set the Exposure&#39;s Detector information.
Definition: Exposure.h:270
#define LSST_PERSIST_FORMATTER(formatter...)
std::shared_ptr< geom::SkyWcs const > getWcs() const
Definition: Exposure.h:212
table::Box2IKey bbox
std::shared_ptr< lsst::afw::detection::Psf const > getPsf() const
Return the Exposure&#39;s Psf object.
Definition: Exposure.h:287
geom::Extent2I getDimensions() const
Return the Exposure&#39;s size.
Definition: Exposure.h:229
void setPsf(std::shared_ptr< lsst::afw::detection::Psf const > psf)
Set the Exposure&#39;s Psf.
Definition: Exposure.h:282
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:215