LSSTApplications  10.0+286,10.0+36,10.0+46,10.0-2-g4f67435,10.1+152,10.1+37,11.0,11.0+1,11.0-1-g47edd16,11.0-1-g60db491,11.0-1-g7418c06,11.0-2-g04d2804,11.0-2-g68503cd,11.0-2-g818369d,11.0-2-gb8b8ce7
LSSTDataManagementBasePackage
Namespaces | Classes | Typedefs | Enumerations | Functions | Variables
lsst::afw::image Namespace Reference

Namespaces

 basicUtils
 
 detail
 
 details
 
 pixel
 
 SdssFilters
 
 testUtils
 
 utils
 

Classes

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  Image
 A class to represent a 2-dimensional array of pixels. 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...
 
class  imageIterator
 An ImageBase iterator. More...
 
class  imageLocator
 An ImageBase locator. More...
 
class  WcsFactory
 

Typedefs

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

Enumerations

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

Functions

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 Image1T , typename Image2T >
double innerProduct (Image1T const &lhs, Image2T const &rhs, int const border=0)
 
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 PixelT >
void swap (Mask< PixelT > &a, Mask< PixelT > &b)
 
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...
 
Wcs::Ptr makeWcs (boost::shared_ptr< lsst::daf::base::PropertySet > const &fitsMetadata, bool stripMetadata=false)
 
Wcs::Ptr 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) 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 boost::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:85
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();
56  if (nAxis == 2) {
57  shape = fitsfile.getImageShape<2>();
58  } else if (nAxis == 3) {
59  ndarray::Vector<int,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 }
geom::Point2I getImageXY0FromMetadata(std::string const &wcsName, lsst::daf::base::PropertySet *metadata)
Definition: Wcs.cc:1210
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: Point.h:283
Extent< int, 2 > Extent2I
Definition: Extent.h:355
A fixed-size 1D array class.
Definition: Vector.h:93
afw::table::PointKey< int > dimensions
Definition: GaussianPsf.cc:42
Vector< T, M > last() const
Create a new Vector from the last M elements of this.
Definition: Vector.h:166
int getMinY() const
Definition: Box.h:125
Vector< T, N > makeVector(T v1, T v2,..., T vN)
Variadic constructor for Vector.
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
detail::SimpleInitializer< N > allocate(Vector< int, N > const &shape)
Create an expression that allocates uninitialized memory for an array.
#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:91
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  {
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 }
A multidimensional strided array.
Definition: Array.h:47
#define LSST_FITS_EXCEPT(type, fitsObj,...)
Definition: fits.h:91
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:85
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 454 of file ImagePca.cc.

457  {
458  if (lhs.getWidth() <= 2*border || lhs.getHeight() <= 2*border) {
459  throw LSST_EXCEPT(lsst::pex::exceptions::LengthError,
460  (boost::format("All image pixels are in the border of width %d: %dx%d") %
461  border % lhs.getWidth() % lhs.getHeight()).str());
462  }
463 
464  double sum = 0.0;
465  //
466  // Handle I.I specially for efficiency, and to avoid advancing the iterator twice
467  //
468  if (imagesAreIdentical(lhs, rhs)) {
469  for (int y = border; y != lhs.getHeight() - border; ++y) {
470  for (typename Image1T::const_x_iterator lptr = lhs.row_begin(y) + border,
471  lend = lhs.row_end(y) - border; lptr != lend; ++lptr) {
472  typename Image1T::Pixel val = *lptr;
473  if (lsst::utils::isfinite(val)) {
474  sum += val*val;
475  }
476  }
477  }
478  } else {
479  if (lhs.getDimensions() != rhs.getDimensions()) {
480  throw LSST_EXCEPT(lsst::pex::exceptions::LengthError,
481  (boost::format("Dimension mismatch: %dx%d v. %dx%d") %
482  lhs.getWidth() % lhs.getHeight() % rhs.getWidth() % rhs.getHeight()).str());
483  }
484 
485  for (int y = border; y != lhs.getHeight() - border; ++y) {
486  typename Image2T::const_x_iterator rptr = rhs.row_begin(y) + border;
487  for (typename Image1T::const_x_iterator lptr = lhs.row_begin(y) + border,
488  lend = lhs.row_end(y) - border; lptr != lend; ++lptr, ++rptr) {
489  double const tmp = (*lptr)*(*rptr);
490  if (lsst::utils::isfinite(tmp)) {
491  sum += tmp;
492  }
493  }
494  }
495  }
496 
497  return sum;
498 }
int y
boost::enable_if< typename ExpressionTraits< Scalar >::IsScalar, Scalar >::type sum(Scalar const &scalar)
Definition: operators.h:1250
bool val
int isfinite(T t)
Definition: ieee.h:100
#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 308 of file Exposure.h.

311  {
312  return typename Exposure<ImagePixelT, MaskPixelT, VariancePixelT>::Ptr(
313  new Exposure<ImagePixelT, MaskPixelT, VariancePixelT>(mimage, wcs));
314 }
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 1067 of file MaskedImage.h.

1071  {
1072  return new MaskedImage<ImagePixelT, MaskPixelT, VariancePixelT>(image, mask, variance);
1073 }
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  using pex::logging::Log;
66  auto log = Log(Log::getDefaultLog(), "makeWcs");
67 
68  if (ctype1.substr(5, 3) == "TAN" &&
69  (metadata->exists("PV1_5") || metadata->exists("PV2_1"))) {
70  log.log(Log::INFO, str(boost::format("Interpreting %s/%s + PVi_j as TPV") % ctype1 % ctype2));
71 
72  if (!modifyable) {
73  metadata = _metadata->deepCopy();
74  modifyable = true;
75  }
76 
77  ctype1.replace(5, 3, "TPV");
78  metadata->set<std::string>("CTYPE1", ctype1);
79 
80  ctype2.replace(5, 3, "TPV");
81  metadata->set<std::string>("CTYPE2", ctype2);
82  }
83 
84  afwImg::Wcs::Ptr wcs; // we can't use make_shared as ctor is private
85  if (ctype1.substr(5, 3) == "TAN") {
86  wcs = afwImg::Wcs::Ptr(new afwImg::TanWcs(metadata));
87  } else if (ctype1.substr(5, 3) == "TPV") { // unfortunately we don't support TPV
88  if (!modifyable) {
89  metadata = _metadata->deepCopy();
90  modifyable = true;
91  }
92 
93  log.log(Log::WARN, str(boost::format("Stripping PVi_j keys from projection %s/%s") % ctype1 % ctype2));
94 
95  metadata->set<std::string>("CTYPE1", "RA---TAN");
96  metadata->set<std::string>("CTYPE2", "DEC--TAN");
97  metadata->set<bool>("TPV_WCS", true);
98  // PV1_[1-4] are in principle legal, although Swarp reuses them as part of the TPV parameterisation.
99  // It turns out that leaving PV1_[1-4] in the header breaks wcslib 4.14's ability to read
100  // DECam headers (DM-3196) so we'll delete them all for now.
101  //
102  // John Swinbank points out the maximum value of j in TVi_j is 39;
103  // http://fits.gsfc.nasa.gov/registry/tpvwcs/tpv.html
104  for (int i = 0; i != 2; ++i) {
105  for (int j = 1; j <= 39; ++j) { // 39's the max in the TPV standard
106  char pvName[8];
107  sprintf(pvName, "PV%d_%d", i, j);
108  if (metadata->exists(pvName)) {
109  metadata->remove(pvName);
110  }
111  }
112  }
113 
114  wcs = afwImg::Wcs::Ptr(new afwImg::TanWcs(metadata));
115  } else {
116  wcs = afwImg::Wcs::Ptr(new afwImg::Wcs(metadata));
117  }
118 
119  //If keywords LTV[1,2] are present, the image on disk is already a subimage, so
120  //we should shift the wcs to allow for this.
121  std::string key = "LTV1";
122  if (metadata->exists(key)) {
123  wcs->shiftReferencePixel(-metadata->getAsDouble(key), 0);
124  }
125 
126  key = "LTV2";
127  if (metadata->exists(key) ) {
128  wcs->shiftReferencePixel(0, -metadata->getAsDouble(key));
129  }
130 
131  if (stripMetadata) {
132  afwImg::detail::stripWcsKeywords(metadata, wcs);
133  }
134 
135  return wcs;
136 }
#define PTR(...)
Definition: base.h:41
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:1039
def log
Definition: log.py:85
Implementation of the WCS standard for the special case of the Gnomonic (tangent plane) projection...
Definition: TanWcs.h:68
boost::shared_ptr< Wcs > Ptr
Definition: Wcs.h:113
int INFO
Definition: log.py:37
int WARN
Definition: log.py:38
int stripWcsKeywords(boost::shared_ptr< lsst::daf::base::PropertySet > const &metadata, boost::shared_ptr< Wcs const > const &wcs)
Definition: Wcs.cc:1253
daf::base::PropertySet & _metadata
Definition: fits_io_mpl.h:79
table::Key< std::string > ctype1
Definition: Wcs.cc:1038
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 141 of file makeWcs.cc.

148  {
149  Eigen::Matrix2d CD;
150  CD << CD11, CD12, CD21, CD22;
151  lsst::afw::geom::Point2D crvalTmp;
152  crvalTmp[0] = crval.toIcrs().getLongitude().asDegrees();
153  crvalTmp[1] = crval.toIcrs().getLatitude().asDegrees();
154  return afwImg::Wcs::Ptr(new lsst::afw::image::TanWcs(crvalTmp, crpix, CD));
155 }
table::PointKey< double > crval
Definition: Wcs.cc:1035
Implementation of the WCS standard for the special case of the Gnomonic (tangent plane) projection...
Definition: TanWcs.h:68
boost::shared_ptr< Wcs > Ptr
Definition: Wcs.h:113
table::PointKey< double > crpix
Definition: Wcs.cc:1036
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 861 of file Image.cc.

861  {
862  image::for_each_pixel(lhs, rhs, timesEq<LhsPixelT, RhsPixelT>());
863 }
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 847 of file Image.cc.

847  {
848  image::for_each_pixel(lhs, rhs, plusEq<LhsPixelT, RhsPixelT>());
849 }
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 854 of file Image.cc.

854  {
855  image::for_each_pixel(lhs, rhs, minusEq<LhsPixelT, RhsPixelT>());
856 }
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 868 of file Image.cc.

868  {
869  image::for_each_pixel(lhs, rhs, divideEq<LhsPixelT, RhsPixelT>());
870 }
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 ( Mask< PixelT > &  a,
Mask< PixelT > &  b 
)

Definition at line 525 of file Mask.cc.

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

Definition at line 291 of file Image.cc.

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

Definition at line 613 of file Image.cc.

613  {
614  a.swap(b);
615 }
afw::table::Key< double > b
template<typename PixelT >
void lsst::afw::image::swap ( DecoratedImage< PixelT > &  a,
DecoratedImage< PixelT > &  b 
)

Definition at line 119 of file DecoratedImage.cc.

119  {
120  a.swap(b);
121 }
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.