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
Namespaces | Classes | Typedefs | Enumerations | Functions | Variables
lsst::afw::image Namespace Reference

Namespaces

 basicUtils
 
 detail
 
 details
 
 pixel
 
 SdssFilters
 
 testUtils
 
 utils
 

Classes

class  imageIterator
 An ImageBase iterator. More...
 
class  imageLocator
 An ImageBase locator. More...
 
class  Image
 A class to represent a 2-dimensional array of pixels. More...
 
class  WcsFactory
 
class  ApCorrMap
 A thin wrapper around std::map to allow aperture corrections to be attached to Exposures. More...
 
class  Calib
 
class  CoaddInputs
 A simple Persistable struct containing ExposureCatalogs that record the inputs to a coadd. More...
 
class  Color
 
class  DefectBase
 Encapsulate information about a bad portion of a detector. More...
 
class  DistortedTanWcs
 Combination of a TAN WCS and a distortion model. More...
 
class  Exposure
 A class to contain the data, WCS, and other information needed to describe an image of the sky. More...
 
class  ExposureInfo
 A collection of all the things that make an Exposure different from a MaskedImage. More...
 
class  FilterProperty
 
class  Filter
 Holds an integer identifier for an LSST filter. More...
 
class  CheckIndices
 A class used to request that array accesses be checked. More...
 
struct  Reference
 metafunction to extract reference type from PixelT More...
 
struct  ConstReference
 metafunction to extract const reference type from PixelT More...
 
class  ImageBase
 The base class for all image classed (Image, Mask, MaskedImage, ...) More...
 
class  DecoratedImage
 A container for an Image and its associated metadata. More...
 
struct  pixelOp0
 
struct  pixelOp1
 
struct  pixelOp1XY
 
struct  pixelOp2
 
struct  pixelOp2XY
 
class  ImagePca
 
class  ImageSlice
 A class to specify a slice of an image. More...
 
class  Mask
 Represent a 2-dimensional array of bitmask pixels. More...
 
class  MaskedImage
 A class to manipulate images, masks, and variance as a single object. More...
 
struct  GetImage
 
class  TanWcs
 Implementation of the WCS standard for the special case of the Gnomonic (tangent plane) projection. More...
 
class  Wcs
 Implementation of the WCS standard for a any projection. More...
 
class  XYTransformFromWcsPair
 XYTransformFromWcsPair: An XYTransform obtained by putting two Wcs objects "back to back". More...
 

Typedefs

typedef std::uint16_t MaskPixel
 
typedef float VariancePixel
 ! default type for Masks and MaskedImage Masks More...
 

Enumerations

enum  ImageOrigin { PARENT, LOCAL }
 
enum  xOrY { X, Y }
 

Functions

template<typename Image1T , typename Image2T >
double innerProduct (Image1T const &lhs, Image2T const &rhs, int border)
 
template<typename PixelT >
void swap (Mask< PixelT > &a, Mask< PixelT > &b)
 
double abMagFromFlux (double flux)
 Compute AB magnitude from flux in Janskys. More...
 
double abMagErrFromFluxErr (double fluxErr, double flux)
 Compute AB magnitude error from flux and flux error in Janskys. More...
 
double fluxFromABMag (double mag)
 Compute flux in Janskys from AB magnitude. More...
 
double fluxErrFromABMagErr (double magErr, double mag)
 Compute flux error in Janskys from AB magnitude error and AB magnitude. More...
 
template<typename ImagePixelT , typename MaskPixelT , typename VariancePixelT >
Exposure< ImagePixelT,
MaskPixelT, VariancePixelT >
::Ptr 
makeExposure (MaskedImage< ImagePixelT, MaskPixelT, VariancePixelT > &mimage, boost::shared_ptr< Wcs const > wcs=boost::shared_ptr< Wcs const >())
 
template<typename PixelT >
void fits_read_array (fits::Fits &fitsfile, ndarray::Array< PixelT, 2, 2 > &array, geom::Point2I &xy0, lsst::daf::base::PropertySet &metadata, geom::Box2I bbox=geom::Box2I(), ImageOrigin origin=PARENT)
 
template<typename ImageT >
void fits_write_image (fits::Fits &fitsfile, const ImageT &image, boost::shared_ptr< daf::base::PropertySet const > metadata=boost::shared_ptr< daf::base::PropertySet const >())
 
template<typename supported_fits_types , typename ImageT >
void fits_read_image (fits::Fits &fitsfile, ImageT &img, lsst::daf::base::PropertySet &metadata, geom::Box2I const &bbox=geom::Box2I(), ImageOrigin const origin=PARENT)
 
template<typename supported_fits_types , typename ImageT >
void fits_read_image (fits::Fits &fitsfile, ImageT &img, boost::shared_ptr< lsst::daf::base::PropertySet > metadata=boost::shared_ptr< lsst::daf::base::PropertySet >(), geom::Box2I const &bbox=geom::Box2I(), ImageOrigin const origin=PARENT)
 
template<typename PixelT >
void swap (ImageBase< PixelT > &a, ImageBase< PixelT > &b)
 
template<typename LhsPixelT , typename RhsPixelT >
void operator+= (Image< LhsPixelT > &lhs, Image< RhsPixelT > const &rhs)
 
template<typename LhsPixelT , typename RhsPixelT >
void operator-= (Image< LhsPixelT > &lhs, Image< RhsPixelT > const &rhs)
 
template<typename LhsPixelT , typename RhsPixelT >
void operator*= (Image< LhsPixelT > &lhs, Image< RhsPixelT > const &rhs)
 
template<typename LhsPixelT , typename RhsPixelT >
void operator/= (Image< LhsPixelT > &lhs, Image< RhsPixelT > const &rhs)
 
template<typename PixelT >
void swap (Image< PixelT > &a, Image< PixelT > &b)
 
template<typename PixelT >
void swap (DecoratedImage< PixelT > &a, DecoratedImage< PixelT > &b)
 
template<typename LhsT >
void for_each_pixel (Image< LhsT > &lhs, pixelOp0< LhsT > const &func)
 
template<typename LhsT >
void for_each_pixel (Image< LhsT > &lhs, pixelOp1< LhsT > const &func)
 
template<typename LhsT >
void for_each_pixel (Image< LhsT > &lhs, pixelOp1XY< LhsT > const &func)
 
template<typename LhsT , typename RhsT >
void for_each_pixel (Image< LhsT > &lhs, Image< RhsT > const &rhs, pixelOp1< RhsT > const &func)
 
template<typename LhsT , typename RhsT >
void for_each_pixel (Image< LhsT > &lhs, Image< RhsT > const &rhs, pixelOp2< LhsT, RhsT > const &func)
 
template<typename LhsT , typename RhsT >
void for_each_pixel (Image< LhsT > &lhs, Image< RhsT > const &rhs, pixelOp2XY< LhsT, RhsT > const &func)
 
template<typename PixelT >
Image< PixelT >::Ptr operator+ (Image< PixelT > const &img, ImageSlice< PixelT > const &slc)
 
template<typename PixelT >
Image< PixelT >::Ptr operator+ (ImageSlice< PixelT > const &slc, Image< PixelT > const &img)
 
template<typename PixelT >
void operator+= (Image< PixelT > &img, ImageSlice< PixelT > const &slc)
 Overload operator+=() More...
 
template<typename PixelT >
Image< PixelT >::Ptr operator- (Image< PixelT > const &img, ImageSlice< PixelT > const &slc)
 
template<typename PixelT >
void operator-= (Image< PixelT > &img, ImageSlice< PixelT > const &slc)
 Overload operator-=() More...
 
template<typename PixelT >
Image< PixelT >::Ptr operator* (Image< PixelT > const &img, ImageSlice< PixelT > const &slc)
 
template<typename PixelT >
Image< PixelT >::Ptr operator* (ImageSlice< PixelT > const &slc, Image< PixelT > const &img)
 
template<typename PixelT >
void operator*= (Image< PixelT > &img, ImageSlice< PixelT > const &slc)
 Overload operator*=() More...
 
template<typename PixelT >
Image< PixelT >::Ptr operator/ (Image< PixelT > const &img, ImageSlice< PixelT > const &slc)
 
template<typename PixelT >
void operator/= (Image< PixelT > &img, ImageSlice< PixelT > const &slc)
 Overload operator/=() More...
 
double indexToPosition (double ind)
 Convert image index to image position. More...
 
int positionToIndex (double pos)
 Convert image position to nearest integer index. More...
 
int positionToIndex (double &residual, double pos)
 Convert image position to index (nearest integer and fractional parts) More...
 
std::pair< int, double > positionToIndex (double const pos, bool)
 Convert image position to index (nearest integer and fractional parts) More...
 
template<typename ImagePixelT , typename MaskPixelT , typename VariancePixelT >
MaskedImage< ImagePixelT,
MaskPixelT, VariancePixelT > * 
makeMaskedImage (typename Image< ImagePixelT >::Ptr image, typename Mask< MaskPixelT >::Ptr mask=typename Mask< MaskPixelT >::Ptr(), typename Image< VariancePixelT >::Ptr variance=typename Image< VariancePixelT >::Ptr())
 
boost::shared_ptr
< daf::base::PropertySet
readMetadata (std::string const &fileName, int hdu=0, bool strip=false)
 Return the metadata (header entries) from a FITS file. More...
 
boost::shared_ptr< WcsmakeWcs (boost::shared_ptr< lsst::daf::base::PropertySet > const &fitsMetadata, bool stripMetadata=false)
 
boost::shared_ptr< WcsmakeWcs (coord::Coord const &crval, geom::Point2D const &crpix, double CD11, double CD12, double CD21, double CD22)
 Create a Wcs object from crval, crpix, CD, using CD elements (useful from python) More...
 

Variables

const double PixelZeroPos = 0.0
 FITS uses 1.0, SDSS uses 0.5, LSST uses 0.0 (http://dev.lsstcorp.org/trac/wiki/BottomLeftPixelProposalII%3A) More...
 

Typedef Documentation

typedef std::uint16_t lsst::afw::image::MaskPixel

Definition at line 33 of file LsstImageTypes.h.

! default type for Masks and MaskedImage Masks

Definition at line 34 of file LsstImageTypes.h.

Enumeration Type Documentation

Enumerator
PARENT 
LOCAL 

Definition at line 107 of file Image.h.

Enumerator
X 
Y 

Definition at line 40 of file ImageUtils.h.

Function Documentation

double lsst::afw::image::abMagErrFromFluxErr ( double  fluxErr,
double  flux 
)
inline

Compute AB magnitude error from flux and flux error in Janskys.

Definition at line 64 of file Calib.h.

64  {
65  return std::abs(fluxErr/(-0.4*flux*std::log(10)));
66 }
def log
Definition: log.py:83
double lsst::afw::image::abMagFromFlux ( double  flux)
inline

Compute AB magnitude from flux in Janskys.

Definition at line 59 of file Calib.h.

59  {
60  return -2.5*std::log10(flux/JanskysPerABFlux);
61 }
template<typename PixelT >
void lsst::afw::image::fits_read_array ( fits::Fits &  fitsfile,
ndarray::Array< PixelT, 2, 2 > &  array,
geom::Point2I xy0,
lsst::daf::base::PropertySet metadata,
geom::Box2I  bbox = geom::Box2I(),
ImageOrigin  origin = PARENT 
)
inline

Definition at line 39 of file fits_io.h.

46  {
47  if (!fitsfile.checkImageType<PixelT>()) {
48  throw LSST_FITS_EXCEPT(
49  fits::FitsTypeError,
50  fitsfile,
51  "Incorrect image type for FITS image"
52  );
53  }
54  int nAxis = fitsfile.getImageDim();
55  ndarray::Vector<ndarray::Size,2> shape;
56  if (nAxis == 2) {
57  shape = fitsfile.getImageShape<2>();
58  } else if (nAxis == 3) {
59  ndarray::Vector<ndarray::Size,3> shape3 = fitsfile.getImageShape<3>();
60  if (shape3[0] != 1) {
61  throw LSST_EXCEPT(
62  fits::FitsError,
63  boost::str(boost::format("3rd dimension %d is not 1") % shape3[0])
64  );
65  }
66  shape = shape3.last<2>();
67  }
68 
69  fitsfile.readMetadata(metadata, true);
70 
71  // Origin of part of image to read
72  xy0 = geom::Point2I();
73 
75  geom::Extent2I dimensions = geom::Extent2I(shape[1], shape[0]);
76 
77  if (!bbox.isEmpty()) {
78  if (origin == PARENT) {
79  bbox.shift(-xyOffset);
80  }
81  xy0 = bbox.getMin();
82 
83  if (bbox.getMinX() < 0 || bbox.getMinY() < 0 ||
84  bbox.getWidth() > dimensions.getX() || bbox.getHeight() > dimensions.getY()
85  ) {
86  throw LSST_EXCEPT(
87  lsst::pex::exceptions::LengthError,
88  (boost::format("BBox (%d,%d) %dx%d doesn't fit in image %dx%d") %
89  bbox.getMinX() % bbox.getMinY() % bbox.getWidth() % bbox.getHeight() %
90  dimensions.getX() % dimensions.getY()).str()
91  );
92  }
93  dimensions = bbox.getDimensions();
94  }
95 
96  array = ndarray::allocate(dimensions.getY(), dimensions.getX());
97 
98  fitsfile.readImage(array, ndarray::makeVector(xy0.getY(), xy0.getX()));
99 
100  xy0 += xyOffset;
101 }
Extent2I const getDimensions() const
Definition: Box.h:153
void shift(Extent2I const &offset)
Shift the position of the box by the given offset.
Point< int, 2 > Point2I
Definition: PSF.h:39
Extent< int, 2 > Extent2I
Definition: Extent.h:358
afw::table::PointKey< int > dimensions
Definition: GaussianPsf.cc:42
afwGeom::Point2I getImageXY0FromMetadata(std::string const &wcsName, lsst::daf::base::PropertySet *metadata)
Definition: Wcs.cc:1213
int getMinY() const
Definition: Box.h:125
int getMinX() const
Definition: Box.h:124
bool isEmpty() const
Return true if the box contains no points.
Definition: Box.h:166
int getWidth() const
Definition: Box.h:154
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
int getHeight() const
Definition: Box.h:155
Point2I const getMin() const
Definition: Box.h:123
#define LSST_FITS_EXCEPT(type, fitsObj,...)
Definition: fits.h:90
std::string const wcsNameForXY0
Definition: Image.h:82
template<typename supported_fits_types , typename ImageT >
void lsst::afw::image::fits_read_image ( fits::Fits &  fitsfile,
ImageT &  img,
lsst::daf::base::PropertySet metadata,
geom::Box2I const &  bbox = geom::Box2I(),
ImageOrigin const  origin = PARENT 
)

Definition at line 87 of file fits_io_mpl.h.

92  {
93  ndarray::Array<typename ImageT::Pixel,2,2> array;
94  geom::Point2I xy0;
95  try {
96  boost::mpl::for_each<supported_fits_types>(
97  try_fits_read_array<ImageT, found_type>(
98  fitsfile, array, xy0, metadata, bbox, origin
99  )
100  );
101  } catch (found_type &) {
102  img = ImageT(array, false, xy0);
103  return;
104  }
105  throw LSST_FITS_EXCEPT(
106  fits::FitsError,
107  fitsfile,
108  "FITS file does not have one of the expected types"
109  );
110 }
#define LSST_FITS_EXCEPT(type, fitsObj,...)
Definition: fits.h:90
template<typename supported_fits_types , typename ImageT >
void lsst::afw::image::fits_read_image ( fits::Fits &  fitsfile,
ImageT &  img,
boost::shared_ptr< lsst::daf::base::PropertySet metadata = boost::shared_ptr< lsst::daf::base::PropertySet >(),
geom::Box2I const &  bbox = geom::Box2I(),
ImageOrigin const  origin = PARENT 
)

Definition at line 113 of file fits_io_mpl.h.

118  {
119  lsst::daf::base::PropertySet metadata_s;
120  fits_read_image<supported_fits_types, ImageT>(fitsfile, img, (metadata ? *metadata : metadata_s),
121  bbox, origin);
122 }
Class for storing generic metadata.
Definition: PropertySet.h:82
template<typename ImageT >
void lsst::afw::image::fits_write_image ( fits::Fits &  fitsfile,
const ImageT &  image,
boost::shared_ptr< daf::base::PropertySet const >  metadata = boost::shared_ptr< daf::base::PropertySet const>() 
)
inline

Definition at line 104 of file fits_io.h.

107  {
108  fitsfile.createImage<typename ImageT::Pixel>(image.getArray().getShape());
109  if (metadata) {
110  fitsfile.writeMetadata(*metadata);
111  }
112  fitsfile.writeImage(image.getArray());
113 }
table::Key< table::Array< Kernel::Pixel > > image
Definition: FixedKernel.cc:117
double lsst::afw::image::fluxErrFromABMagErr ( double  magErr,
double  mag 
)
inline

Compute flux error in Janskys from AB magnitude error and AB magnitude.

Definition at line 74 of file Calib.h.

74  {
75  return std::abs(-0.4*magErr*fluxFromABMag(mag)*std::log(10.0));
76 }
double fluxFromABMag(double mag)
Compute flux in Janskys from AB magnitude.
Definition: Calib.h:69
def log
Definition: log.py:83
double lsst::afw::image::fluxFromABMag ( double  mag)
inline

Compute flux in Janskys from AB magnitude.

Definition at line 69 of file Calib.h.

69  {
70  return std::pow(10.0, -0.4*mag)*JanskysPerABFlux;
71 }
template<typename LhsT >
void lsst::afw::image::for_each_pixel ( Image< LhsT > &  lhs,
pixelOp0< LhsT > const &  func 
)

Set each pixel in an Image<LhsT> to func()

Parameters
lhsImage to set
funcfunctor to call
Examples:
forEachPixel.cc.

Definition at line 103 of file ImageAlgorithm.h.

106  {
107  for (int y = 0; y != lhs.getHeight(); ++y) {
108  for (typename Image<LhsT>::x_iterator lhsPtr = lhs.row_begin(y), lhsEnd = lhs.row_end(y);
109  lhsPtr != lhsEnd; ++lhsPtr) {
110  *lhsPtr = func();
111  }
112  }
113  }
int y
template<typename LhsT >
void lsst::afw::image::for_each_pixel ( Image< LhsT > &  lhs,
pixelOp1< LhsT > const &  func 
)

Set each pixel in an Image<LhsT> to func(lhs)

Parameters
lhsImage to set
funcfunctor to call

Definition at line 119 of file ImageAlgorithm.h.

122  {
123  for (int y = 0; y != lhs.getHeight(); ++y) {
124  for (typename Image<LhsT>::x_iterator lhsPtr = lhs.row_begin(y), lhsEnd = lhs.row_end(y);
125  lhsPtr != lhsEnd; ++lhsPtr) {
126  *lhsPtr = func(*lhsPtr);
127  }
128  }
129  }
int y
template<typename LhsT >
void lsst::afw::image::for_each_pixel ( Image< LhsT > &  lhs,
pixelOp1XY< LhsT > const &  func 
)

Set each pixel in an Image<LhsT> to func(x, y, lhs)

(x, y) allow for lhs.getXY0()

Parameters
lhsImage to set
funcfunctor to call

Definition at line 137 of file ImageAlgorithm.h.

140  {
141  for (int y = 0; y != lhs.getHeight(); ++y) {
142  int x = lhs.getX0();
143  for (typename Image<LhsT>::x_iterator lhsPtr = lhs.row_begin(y), lhsEnd = lhs.row_end(y);
144  lhsPtr != lhsEnd; ++lhsPtr, ++x) {
145  *lhsPtr = func(x, y + lhs.getY0(), *lhsPtr);
146  }
147  }
148  }
int y
double x
template<typename LhsT , typename RhsT >
void lsst::afw::image::for_each_pixel ( Image< LhsT > &  lhs,
Image< RhsT > const &  rhs,
pixelOp1< RhsT > const &  func 
)

Set each pixel in an Image<LhsT> to func(rhs), getting the rhs from an Image<RhsT>

Parameters
lhsImage to set
rhsother Image to pass to func
funcfunctor to call

Definition at line 154 of file ImageAlgorithm.h.

158  {
159  if (lhs.getDimensions() != rhs.getDimensions()) {
160  throw LSST_EXCEPT(lsst::pex::exceptions::LengthError,
161  (boost::format("Images are of different size, %dx%d v %dx%d") %
162  lhs.getWidth() % lhs.getHeight() % rhs.getWidth() % rhs.getHeight()).str());
163  }
164 
165  for (int y = 0; y != lhs.getHeight(); ++y) {
166  typename Image<RhsT>::const_x_iterator rhsPtr = rhs.row_begin(y);
167 
168  for (typename Image<LhsT>::x_iterator lhsPtr = lhs.row_begin(y), lhsEnd = lhs.row_end(y);
169  lhsPtr != lhsEnd; ++rhsPtr, ++lhsPtr) {
170  *lhsPtr = func(*rhsPtr);
171  }
172  }
173  }
int y
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
template<typename LhsT , typename RhsT >
void lsst::afw::image::for_each_pixel ( Image< LhsT > &  lhs,
Image< RhsT > const &  rhs,
pixelOp2< LhsT, RhsT > const &  func 
)

Set each pixel in an Image<LhsT> to func(lhs, rhs), getting the rhs from an Image<RhsT>

Parameters
lhsImage to set
rhsother Image to pass to func
funcfunctor to call

Definition at line 179 of file ImageAlgorithm.h.

183  {
184  if (lhs.getDimensions() != rhs.getDimensions()) {
185  throw LSST_EXCEPT(lsst::pex::exceptions::LengthError,
186  (boost::format("Images are of different size, %dx%d v %dx%d") %
187  lhs.getWidth() % lhs.getHeight() % rhs.getWidth() % rhs.getHeight()).str());
188  }
189 
190  for (int y = 0; y != lhs.getHeight(); ++y) {
191  typename Image<RhsT>::const_x_iterator rhsPtr = rhs.row_begin(y);
192 
193  for (typename Image<LhsT>::x_iterator lhsPtr = lhs.row_begin(y), lhsEnd = lhs.row_end(y);
194  lhsPtr != lhsEnd; ++rhsPtr, ++lhsPtr) {
195  *lhsPtr = func(*lhsPtr, *rhsPtr);
196  }
197  }
198  }
int y
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
template<typename LhsT , typename RhsT >
void lsst::afw::image::for_each_pixel ( Image< LhsT > &  lhs,
Image< RhsT > const &  rhs,
pixelOp2XY< LhsT, RhsT > const &  func 
)

Set each pixel in an Image<LhsT> to func(x, y, lhs, rhs), getting the rhs from an Image<RhsT>

(x, y) allow for lhs.getXY0()

Parameters
lhsImage to set
rhsother Image to pass to func
funcfunctor to call

Definition at line 205 of file ImageAlgorithm.h.

209  {
210  if (lhs.getDimensions() != rhs.getDimensions()) {
211  throw LSST_EXCEPT(lsst::pex::exceptions::LengthError,
212  (boost::format("Images are of different size, %dx%d v %dx%d") %
213  lhs.getWidth() % lhs.getHeight() % rhs.getWidth() % rhs.getHeight()).str());
214  }
215 
216  for (int y = 0; y != lhs.getHeight(); ++y) {
217  typename Image<RhsT>::const_x_iterator rhsPtr = rhs.row_begin(y);
218  int x = lhs.getX0();
219  for (typename Image<LhsT>::x_iterator lhsPtr = lhs.row_begin(y), lhsEnd = lhs.row_end(y);
220  lhsPtr != lhsEnd; ++rhsPtr, ++lhsPtr, ++x) {
221  *lhsPtr = func(x, y + lhs.getY0(), *lhsPtr, *rhsPtr);
222  }
223  }
224  }
int y
double x
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
double lsst::afw::image::indexToPosition ( double  ind)
inline

Convert image index to image position.

The LSST indexing convention is:

  • the index of the bottom left pixel is 0,0
  • the position of the center of the bottom left pixel is PixelZeroPos, PixelZeroPos
Returns
image position
Parameters
indimage index

Definition at line 54 of file ImageUtils.h.

56  {
57  return ind + PixelZeroPos;
58  }
const double PixelZeroPos
FITS uses 1.0, SDSS uses 0.5, LSST uses 0.0 (http://dev.lsstcorp.org/trac/wiki/BottomLeftPixelProposa...
Definition: ImageUtils.h:42
template<typename Image1T , typename Image2T >
double lsst::afw::image::innerProduct ( Image1T const &  lhs,
Image2T const &  rhs,
int  border 
)

Calculate the inner product of two images

Returns
The inner product
Exceptions
lsst::pex::exceptions::LengthErrorif all the images aren't the same size
Parameters
lhsfirst image
rhsOther image to dot with first
bordernumber of pixels to ignore around the edge

Definition at line 455 of file ImagePca.cc.

458  {
459  if (lhs.getWidth() <= 2*border || lhs.getHeight() <= 2*border) {
460  throw LSST_EXCEPT(lsst::pex::exceptions::LengthError,
461  (boost::format("All image pixels are in the border of width %d: %dx%d") %
462  border % lhs.getWidth() % lhs.getHeight()).str());
463  }
464 
465  double sum = 0.0;
466  //
467  // Handle I.I specially for efficiency, and to avoid advancing the iterator twice
468  //
469  if (imagesAreIdentical(lhs, rhs)) {
470  for (int y = border; y != lhs.getHeight() - border; ++y) {
471  for (typename Image1T::const_x_iterator lptr = lhs.row_begin(y) + border,
472  lend = lhs.row_end(y) - border; lptr != lend; ++lptr) {
473  typename Image1T::Pixel val = *lptr;
474  if (std::isfinite(val)) {
475  sum += val*val;
476  }
477  }
478  }
479  } else {
480  if (lhs.getDimensions() != rhs.getDimensions()) {
481  throw LSST_EXCEPT(lsst::pex::exceptions::LengthError,
482  (boost::format("Dimension mismatch: %dx%d v. %dx%d") %
483  lhs.getWidth() % lhs.getHeight() % rhs.getWidth() % rhs.getHeight()).str());
484  }
485 
486  for (int y = border; y != lhs.getHeight() - border; ++y) {
487  typename Image2T::const_x_iterator rptr = rhs.row_begin(y) + border;
488  for (typename Image1T::const_x_iterator lptr = lhs.row_begin(y) + border,
489  lend = lhs.row_end(y) - border; lptr != lend; ++lptr, ++rptr) {
490  double const tmp = (*lptr)*(*rptr);
491  if (std::isfinite(tmp)) {
492  sum += tmp;
493  }
494  }
495  }
496  }
497 
498  return sum;
499 }
int y
bool val
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
template<typename ImagePixelT , typename MaskPixelT , typename VariancePixelT >
Exposure<ImagePixelT, MaskPixelT, VariancePixelT>::Ptr lsst::afw::image::makeExposure ( MaskedImage< ImagePixelT, MaskPixelT, VariancePixelT > &  mimage,
boost::shared_ptr< Wcs const >  wcs = boost::shared_ptr< Wcs const>() 
)

A function to return an Exposure of the correct type (cf. std::make_pair)

Parameters
mimagethe Exposure's image
wcsthe Exposure's WCS

Definition at line 306 of file Exposure.h.

309  {
310  return typename Exposure<ImagePixelT, MaskPixelT, VariancePixelT>::Ptr(
311  new Exposure<ImagePixelT, MaskPixelT, VariancePixelT>(mimage, wcs));
312 }
tbl::Key< int > wcs
template<typename ImagePixelT , typename MaskPixelT , typename VariancePixelT >
MaskedImage<ImagePixelT, MaskPixelT, VariancePixelT>* lsst::afw::image::makeMaskedImage ( typename Image< ImagePixelT >::Ptr  image,
typename Mask< MaskPixelT >::Ptr  mask = typename Mask<MaskPixelT>::Ptr(),
typename Image< VariancePixelT >::Ptr  variance = typename Image<VariancePixelT>::Ptr() 
)

A function to return a MaskedImage of the correct type (cf. std::make_pair)

Parameters
imageimage
maskmask
variancevariance

Definition at line 1073 of file MaskedImage.h.

1077  {
1078  return new MaskedImage<ImagePixelT, MaskPixelT, VariancePixelT>(image, mask, variance);
1079 }
table::Key< table::Array< Kernel::Pixel > > image
Definition: FixedKernel.cc:117
afwImg::Wcs::Ptr lsst::afw::image::makeWcs ( boost::shared_ptr< lsst::daf::base::PropertySet > const &  _metadata,
bool  stripMetadata = false 
)

Set stripMetadata=true to remove processed keywords from the PropertySet.

Create a Wcs object from a fits header. It examines the header and determines the most suitable object to return, either a general Wcs object, or a more specific object specialised to a given coordinate system (e.g TanWcs)

Parameters
_metadatainput metadata
stripMetadataRemove FITS keywords from metadata?

Definition at line 40 of file makeWcs.cc.

44 {
45  //
46  // _metadata is not const (it is probably meant to be), but we don't want to modify it.
47  //
48  auto metadata = _metadata; // we'll make a copy and modify metadata if needs be
49  auto modifyable = false; // ... and set this variable to say that we did
50 
51  std::string ctype1, ctype2;
52  if (metadata->exists("CTYPE1") && metadata->exists("CTYPE2")) {
53  ctype1 = metadata->getAsString("CTYPE1");
54  ctype2 = metadata->getAsString("CTYPE2");
55  } else {
56  return PTR(Wcs)();
57  }
58  //
59  // SCAMP used to use PVi_j keys with a CTYPE of TAN to specify a "TPV" projection
60  // (cf. https://github.com/astropy/astropy/issues/299
61  // and the discussion from Dave Berry in https://jira.lsstcorp.org/browse/DM-2883)
62  //
63  // Follow Dave's AST and switch TAN to TPV
64  //
65  if (ctype1.substr(5, 3) == "TAN" &&
66  (metadata->exists("PV1_5") || metadata->exists("PV2_1"))) {
67  LOGL_INFO("makeWcs", "Interpreting %s/%s + PVi_j as TPV", ctype1.c_str(), ctype2.c_str());
68 
69  if (!modifyable) {
70  metadata = _metadata->deepCopy();
71  modifyable = true;
72  }
73 
74  ctype1.replace(5, 3, "TPV");
75  metadata->set<std::string>("CTYPE1", ctype1);
76 
77  ctype2.replace(5, 3, "TPV");
78  metadata->set<std::string>("CTYPE2", ctype2);
79  }
80 
81  afwImg::Wcs::Ptr wcs; // we can't use make_shared as ctor is private
82  if (ctype1.substr(5, 3) == "TAN") {
83  wcs = afwImg::Wcs::Ptr(new afwImg::TanWcs(metadata));
84  } else if (ctype1.substr(5, 3) == "TPV") { // unfortunately we don't support TPV
85  if (!modifyable) {
86  metadata = _metadata->deepCopy();
87  modifyable = true;
88  }
89 
90  LOGL_WARN("makeWcs", "Stripping PVi_j keys from projection %s/%s", ctype1.c_str(), ctype2.c_str());
91 
92  metadata->set<std::string>("CTYPE1", "RA---TAN");
93  metadata->set<std::string>("CTYPE2", "DEC--TAN");
94  metadata->set<bool>("TPV_WCS", true);
95  // PV1_[1-4] are in principle legal, although Swarp reuses them as part of the TPV parameterisation.
96  // It turns out that leaving PV1_[1-4] in the header breaks wcslib 4.14's ability to read
97  // DECam headers (DM-3196) so we'll delete them all for now.
98  //
99  // John Swinbank points out the maximum value of j in TVi_j is 39;
100  // http://fits.gsfc.nasa.gov/registry/tpvwcs/tpv.html
101  for (int i = 0; i != 2; ++i) {
102  for (int j = 1; j <= 39; ++j) { // 39's the max in the TPV standard
103  char pvName[8];
104  sprintf(pvName, "PV%d_%d", i, j);
105  if (metadata->exists(pvName)) {
106  metadata->remove(pvName);
107  }
108  }
109  }
110 
111  wcs = afwImg::Wcs::Ptr(new afwImg::TanWcs(metadata));
112  } else {
113  wcs = afwImg::Wcs::Ptr(new afwImg::Wcs(metadata));
114  }
115 
116  //If keywords LTV[1,2] are present, the image on disk is already a subimage, so
117  //we should shift the wcs to allow for this.
118  std::string key = "LTV1";
119  if (metadata->exists(key)) {
120  wcs->shiftReferencePixel(-metadata->getAsDouble(key), 0);
121  }
122 
123  key = "LTV2";
124  if (metadata->exists(key) ) {
125  wcs->shiftReferencePixel(0, -metadata->getAsDouble(key));
126  }
127 
128  if (stripMetadata) {
129  afwImg::detail::stripWcsKeywords(metadata, wcs);
130  }
131 
132  return wcs;
133 }
tbl::Key< int > wcs
Implementation of the WCS standard for a any projection.
Definition: Wcs.h:107
table::Key< std::string > ctype2
Definition: Wcs.cc:1034
std::shared_ptr< Wcs > Ptr
Definition: Wcs.h:113
Implementation of the WCS standard for the special case of the Gnomonic (tangent plane) projection...
Definition: TanWcs.h:68
#define LOGL_WARN(logger, message...)
Definition: Log.h:545
#define PTR(...)
Definition: base.h:41
int stripWcsKeywords(boost::shared_ptr< lsst::daf::base::PropertySet > const &metadata, boost::shared_ptr< Wcs const > const &wcs)
Definition: Wcs.cc:1256
daf::base::PropertySet & _metadata
Definition: fits_io_mpl.h:79
table::Key< std::string > ctype1
Definition: Wcs.cc:1033
#define LOGL_INFO(logger, message...)
Definition: Log.h:529
afwImg::Wcs::Ptr lsst::afw::image::makeWcs ( coord::Coord const &  crval,
geom::Point2D const &  crpix,
double  CD11,
double  CD12,
double  CD21,
double  CD22 
)

Create a Wcs object from crval, crpix, CD, using CD elements (useful from python)

Parameters
crvalCRVAL1,2 (ie. the sky origin)
crpixCRPIX1,2 (ie. the pixel origin) in pixels
CD11CD matrix element 1,1
CD12CD matrix element 1,2
CD21CD matrix element 2,1
CD22CD matrix element 2,2

Definition at line 138 of file makeWcs.cc.

145  {
146  Eigen::Matrix2d CD;
147  CD << CD11, CD12, CD21, CD22;
148  lsst::afw::geom::Point2D crvalTmp;
149  crvalTmp[0] = crval.toIcrs().getLongitude().asDegrees();
150  crvalTmp[1] = crval.toIcrs().getLatitude().asDegrees();
151  return afwImg::Wcs::Ptr(new lsst::afw::image::TanWcs(crvalTmp, crpix, CD));
152 }
table::PointKey< double > crval
Definition: Wcs.cc:1030
A coordinate class intended to represent absolute positions.
Definition: PSF.h:39
std::shared_ptr< Wcs > Ptr
Definition: Wcs.h:113
Implementation of the WCS standard for the special case of the Gnomonic (tangent plane) projection...
Definition: TanWcs.h:68
table::PointKey< double > crpix
Definition: Wcs.cc:1031
template<typename PixelT >
Image<PixelT>::Ptr lsst::afw::image::operator* ( Image< PixelT > const &  img,
ImageSlice< PixelT > const &  slc 
)
template<typename PixelT >
Image<PixelT>::Ptr lsst::afw::image::operator* ( ImageSlice< PixelT > const &  slc,
Image< PixelT > const &  img 
)
template<typename PixelT >
void lsst::afw::image::operator*= ( afwImage::Image< PixelT > &  img,
afwImage::ImageSlice< PixelT > const &  slc 
)

Overload operator*=()

Only 'image *= slice' is defined, as 'slice *= image' doesn't make sense.

Parameters
imgThe Image
slcThe ImageSlice

Definition at line 204 of file ImageSlice.cc.

207  {
208  details::operate<details::Mult<PixelT> >(img, slc, slc.getImageSliceType());
209 }
ImageSliceType getImageSliceType() const
Definition: ImageSlice.h:60
template<typename LhsPixelT , typename RhsPixelT >
void lsst::afw::image::operator*= ( image::Image< LhsPixelT > &  lhs,
image::Image< RhsPixelT > const &  rhs 
)

Multiply lhs by Image rhs (i.e. pixel-by-pixel multiplication) where types are different

Definition at line 878 of file Image.cc.

878  {
879  image::for_each_pixel(lhs, rhs, timesEq<LhsPixelT, RhsPixelT>());
880 }
void for_each_pixel(Image< LhsT > &lhs, pixelOp0< LhsT > const &func)
template<typename PixelT >
Image<PixelT>::Ptr lsst::afw::image::operator+ ( Image< PixelT > const &  img,
ImageSlice< PixelT > const &  slc 
)
template<typename PixelT >
Image<PixelT>::Ptr lsst::afw::image::operator+ ( ImageSlice< PixelT > const &  slc,
Image< PixelT > const &  img 
)
template<typename PixelT >
void lsst::afw::image::operator+= ( afwImage::Image< PixelT > &  img,
afwImage::ImageSlice< PixelT > const &  slc 
)

Overload operator+=()

We'll only allow 'image += slice'. It doesn't make sense to add an image to a slice.

Parameters
imgThe Image
slcThe ImageSlice

Definition at line 121 of file ImageSlice.cc.

124  {
125  afwImage::details::operate<afwImage::details::Plus<PixelT> >(img, slc, slc.getImageSliceType());
126 }
ImageSliceType getImageSliceType() const
Definition: ImageSlice.h:60
template<typename LhsPixelT , typename RhsPixelT >
void lsst::afw::image::operator+= ( image::Image< LhsPixelT > &  lhs,
image::Image< RhsPixelT > const &  rhs 
)

Add lhs to Image rhs (i.e. pixel-by-pixel addition) where types are different

Definition at line 864 of file Image.cc.

864  {
865  image::for_each_pixel(lhs, rhs, plusEq<LhsPixelT, RhsPixelT>());
866 }
void for_each_pixel(Image< LhsT > &lhs, pixelOp0< LhsT > const &func)
template<typename PixelT >
Image<PixelT>::Ptr lsst::afw::image::operator- ( Image< PixelT > const &  img,
ImageSlice< PixelT > const &  slc 
)
template<typename PixelT >
void lsst::afw::image::operator-= ( afwImage::Image< PixelT > &  img,
afwImage::ImageSlice< PixelT > const &  slc 
)

Overload operator-=()

Only 'image -= slice' is defined. 'slice -= image' wouldn't make sense.

Parameters
imgThe Image
slcThe ImageSlice

Definition at line 157 of file ImageSlice.cc.

160  {
161  details::operate<details::Minus<PixelT> >(img, slc, slc.getImageSliceType());
162 }
ImageSliceType getImageSliceType() const
Definition: ImageSlice.h:60
template<typename LhsPixelT , typename RhsPixelT >
void lsst::afw::image::operator-= ( image::Image< LhsPixelT > &  lhs,
image::Image< RhsPixelT > const &  rhs 
)

Subtract lhs from Image rhs (i.e. pixel-by-pixel subtraction) where types are different

Definition at line 871 of file Image.cc.

871  {
872  image::for_each_pixel(lhs, rhs, minusEq<LhsPixelT, RhsPixelT>());
873 }
void for_each_pixel(Image< LhsT > &lhs, pixelOp0< LhsT > const &func)
template<typename PixelT >
Image<PixelT>::Ptr lsst::afw::image::operator/ ( Image< PixelT > const &  img,
ImageSlice< PixelT > const &  slc 
)
template<typename PixelT >
void lsst::afw::image::operator/= ( afwImage::Image< PixelT > &  img,
afwImage::ImageSlice< PixelT > const &  slc 
)

Overload operator/=()

Only 'image /= slice' is defined, as 'slice /= image' doesn't make sense.

Parameters
imgThe Image
slcThe ImageSlice

Definition at line 240 of file ImageSlice.cc.

243  {
244  details::operate<details::Div<PixelT> >(img, slc, slc.getImageSliceType());
245 }
ImageSliceType getImageSliceType() const
Definition: ImageSlice.h:60
template<typename LhsPixelT , typename RhsPixelT >
void lsst::afw::image::operator/= ( image::Image< LhsPixelT > &  lhs,
image::Image< RhsPixelT > const &  rhs 
)

Divide lhs by Image rhs (i.e. pixel-by-pixel division) where types are different

Definition at line 885 of file Image.cc.

885  {
886  image::for_each_pixel(lhs, rhs, divideEq<LhsPixelT, RhsPixelT>());
887 }
void for_each_pixel(Image< LhsT > &lhs, pixelOp0< LhsT > const &func)
int lsst::afw::image::positionToIndex ( double  pos)
inline

Convert image position to nearest integer index.

The LSST indexing convention is:

  • the index of the bottom left pixel is 0,0
  • the position of the center of the bottom left pixel is PixelZeroPos, PixelZeroPos
Returns
nearest integer index
Parameters
posimage position

Definition at line 69 of file ImageUtils.h.

71  {
72  return static_cast<int>(std::floor(pos + 0.5 - PixelZeroPos));
73  }
Extent< int, N > floor(Extent< double, N > const &input)
const double PixelZeroPos
FITS uses 1.0, SDSS uses 0.5, LSST uses 0.0 (http://dev.lsstcorp.org/trac/wiki/BottomLeftPixelProposa...
Definition: ImageUtils.h:42
int lsst::afw::image::positionToIndex ( double &  residual,
double  pos 
)
inline

Convert image position to index (nearest integer and fractional parts)

The LSST indexing convention is:

  • the index of the bottom left pixel is 0,0
  • the position of the center of the bottom left pixel is PixelZeroPos, PixelZeroPos

Note: in python this is called positionToIndexAndResidual

Returns
nearest integer index
Parameters
residualfractional part of index
posimage position

Definition at line 86 of file ImageUtils.h.

89  {
90  double fullIndex = pos - PixelZeroPos;
91  double roundedIndex = std::floor(fullIndex + 0.5);
92  residual = fullIndex - roundedIndex;
93  return static_cast<int>(roundedIndex);
94  }
Extent< int, N > floor(Extent< double, N > const &input)
const double PixelZeroPos
FITS uses 1.0, SDSS uses 0.5, LSST uses 0.0 (http://dev.lsstcorp.org/trac/wiki/BottomLeftPixelProposa...
Definition: ImageUtils.h:42
std::pair<int, double> lsst::afw::image::positionToIndex ( double const  pos,
bool   
)
inline

Convert image position to index (nearest integer and fractional parts)

Returns
std::pair(nearest integer index, fractional part)
Parameters
posimage position

Definition at line 100 of file ImageUtils.h.

102  {
103  double residual; // fractional part of index
104  int const ind = positionToIndex(residual, pos); // integral part
105 
106  return std::pair<int, double>(ind, residual);
107  }
int positionToIndex(double pos)
Convert image position to nearest integer index.
Definition: ImageUtils.h:69
boost::shared_ptr< daf::base::PropertySet > lsst::afw::image::readMetadata ( std::string const &  fileName,
int  hdu = 0,
bool  strip = false 
)

Return the metadata (header entries) from a FITS file.

Parameters
[in]fileNameFile to read.
[in]hduHDU to read, 1-indexed. The special value of 0 will read the first non-empty HDU.
[in]stripIf true, ignore special header keys usually managed by cfitsio (e.g. NAXIS).
template<typename PixelT >
void lsst::afw::image::swap ( ImageBase< PixelT > &  a,
ImageBase< PixelT > &  b 
)

Definition at line 315 of file Image.cc.

315  {
316  a.swap(b);
317 }
afw::table::Key< double > b
template<typename PixelT >
void lsst::afw::image::swap ( Mask< PixelT > &  a,
Mask< PixelT > &  b 
)

Definition at line 524 of file Mask.cc.

524  {
525  a.swap(b);
526 }
afw::table::Key< double > b
template<typename PixelT >
void lsst::afw::image::swap ( Image< PixelT > &  a,
Image< PixelT > &  b 
)

Definition at line 637 of file Image.cc.

637  {
638  a.swap(b);
639 }
void swap(Image &rhs)
Definition: Image.cc:630
template<typename PixelT >
void lsst::afw::image::swap ( DecoratedImage< PixelT > &  a,
DecoratedImage< PixelT > &  b 
)

Definition at line 120 of file DecoratedImage.cc.

120  {
121  a.swap(b);
122 }
afw::table::Key< double > b

Variable Documentation

const double lsst::afw::image::PixelZeroPos = 0.0

FITS uses 1.0, SDSS uses 0.5, LSST uses 0.0 (http://dev.lsstcorp.org/trac/wiki/BottomLeftPixelProposalII%3A)

position of center of pixel 0

Definition at line 42 of file ImageUtils.h.