LSSTApplications  19.0.0-14-gb0260a2+72efe9b372,20.0.0+7927753e06,20.0.0+8829bf0056,20.0.0+995114c5d2,20.0.0+b6f4b2abd1,20.0.0+bddc4f4cbe,20.0.0-1-g253301a+8829bf0056,20.0.0-1-g2b7511a+0d71a2d77f,20.0.0-1-g5b95a8c+7461dd0434,20.0.0-12-g321c96ea+23efe4bbff,20.0.0-16-gfab17e72e+fdf35455f6,20.0.0-2-g0070d88+ba3ffc8f0b,20.0.0-2-g4dae9ad+ee58a624b3,20.0.0-2-g61b8584+5d3db074ba,20.0.0-2-gb780d76+d529cf1a41,20.0.0-2-ged6426c+226a441f5f,20.0.0-2-gf072044+8829bf0056,20.0.0-2-gf1f7952+ee58a624b3,20.0.0-20-geae50cf+e37fec0aee,20.0.0-25-g3dcad98+544a109665,20.0.0-25-g5eafb0f+ee58a624b3,20.0.0-27-g64178ef+f1f297b00a,20.0.0-3-g4cc78c6+e0676b0dc8,20.0.0-3-g8f21e14+4fd2c12c9a,20.0.0-3-gbd60e8c+187b78b4b8,20.0.0-3-gbecbe05+48431fa087,20.0.0-38-ge4adf513+a12e1f8e37,20.0.0-4-g97dc21a+544a109665,20.0.0-4-gb4befbc+087873070b,20.0.0-4-gf910f65+5d3db074ba,20.0.0-5-gdfe0fee+199202a608,20.0.0-5-gfbfe500+d529cf1a41,20.0.0-6-g64f541c+d529cf1a41,20.0.0-6-g9a5b7a1+a1cd37312e,20.0.0-68-ga3f3dda+5fca18c6a4,20.0.0-9-g4aef684+e18322736b,w.2020.45
LSSTDataManagementBasePackage
Namespaces | Classes | Typedefs | Enumerations | Functions | Variables
lsst::afw::math Namespace Reference

Namespaces

 background
 
 backgroundList
 
 chebyshevBoundedFieldConfig
 
 chebyshevBoundedFieldContinued
 
 convolveImage
 
 detail
 
 details
 
 kernel
 
 mathLib
 
 spatialCell
 
 warper
 

Classes

class  AnalyticKernel
 A kernel described by a function. More...
 
class  Approximate
 Approximate values for a MaskedImage. More...
 
class  ApproximateControl
 Control how to make an approximation. More...
 
class  Background
 A virtual base class to evaluate image background levels. More...
 
class  BackgroundControl
 Pass parameters to a Background object. More...
 
class  BackgroundMI
 A class to evaluate image background levels. More...
 
class  BasePolynomialFunction2
 Base class for 2-dimensional polynomials of the form: More...
 
class  BilinearWarpingKernel
 Bilinear warping: fast; good for undersampled data. More...
 
class  BoundedField
 An abstract base class for 2-d functions defined on an integer bounding boxes. More...
 
class  CandidateVisitor
 
class  Chebyshev1Function1
 1-dimensional weighted sum of Chebyshev polynomials of the first kind. More...
 
class  Chebyshev1Function2
 2-dimensional weighted sum of Chebyshev polynomials of the first kind. More...
 
class  ChebyshevBoundedField
 A BoundedField based on 2-d Chebyshev polynomials of the first kind. More...
 
class  ChebyshevBoundedFieldControl
 A control object used when fitting ChebyshevBoundedField to data (see ChebyshevBoundedField::fit) More...
 
class  ConvolutionControl
 Parameters to control convolution. More...
 
class  Covariogram
 The parent class of covariogram functions for use in Gaussian Process interpolation. More...
 
struct  deltafunction_kernel_tag
 Kernel has only one non-zero pixel. More...
 
class  DeltaFunctionKernel
 A kernel that has only one non-zero pixel (of value 1) More...
 
class  DoubleGaussianFunction2
 double Guassian (sum of two Gaussians) More...
 
struct  FitResults
 Results from minimizing a function. More...
 
class  FixedKernel
 A kernel created from an Image. More...
 
class  Function
 Basic Function class. More...
 
class  Function1
 A Function taking one argument. More...
 
class  Function2
 A Function taking two arguments. More...
 
class  GaussianFunction1
 1-dimensional Gaussian More...
 
class  GaussianFunction2
 2-dimensional Gaussian More...
 
class  GaussianProcess
 Stores values of a function sampled on an image and allows you to interpolate the function to unsampled points. More...
 
class  GaussianProcessTimer
 This is a structure for keeping track of how long the interpolation methods spend on different parts of the interpolation. More...
 
struct  generic_kernel_tag
 Tags carrying information about Kernels Kernel with no special properties. More...
 
class  ImageImposter
 A vector wrapper to provide a vector with the necessary methods and typedefs to be processed by Statistics as though it were an Image. More...
 
class  infinite_iterator
 This iterator will never increment. More...
 
class  IntegerDeltaFunction1
 1-dimensional integer delta function. More...
 
class  IntegerDeltaFunction2
 2-dimensional integer delta function. More...
 
class  Interpolate
 
class  InterpolateConstant
 
class  InterpolateGsl
 
struct  IntRegion
 
struct  is_analyticKernel
 traits class to determine if a Kernel is represented as an analytic function More...
 
struct  is_analyticKernel< AnalyticKernel >
 
struct  is_analyticKernel< KernelT * >
 
struct  is_analyticKernel< std::shared_ptr< KernelT > >
 
class  KdTree
 The data for GaussianProcess is stored in a KD tree to facilitate nearest-neighbor searches. More...
 
class  Kernel
 Kernels are used for convolution with MaskedImages and (eventually) Images. More...
 
struct  kernel_traits
 template trait class with information about Kernels More...
 
class  LanczosFunction1
 1-dimensional Lanczos function More...
 
class  LanczosFunction2
 2-dimensional separable Lanczos function More...
 
class  LanczosWarpingKernel
 Lanczos warping: accurate but slow and can introduce ringing artifacts. More...
 
class  LeastSquares
 Solver for linear least-squares problems. More...
 
class  LinearCombinationKernel
 A kernel that is a linear combination of fixed basis kernels. More...
 
class  MaskedVector
 
class  MaskImposter
 A Mask wrapper to provide an infinite_iterator for Mask::row_begin(). More...
 
class  NearestWarpingKernel
 Nearest neighbor warping: fast; good for undersampled data. More...
 
class  NeuralNetCovariogram
 a Covariogram that recreates a neural network with one hidden layer and infinite units in that layer More...
 
class  NullFunction1
 a class used in function calls to indicate that no Function1 is being provided More...
 
class  NullFunction2
 a class used in function calls to indicate that no Function2 is being provided More...
 
class  PixelAreaBoundedField
 A BoundedField that evaluate the pixel area of a SkyWcs in angular units. More...
 
class  PolynomialFunction1
 1-dimensional polynomial function. More...
 
class  PolynomialFunction2
 2-dimensional polynomial function with cross terms More...
 
class  ProductBoundedField
 A BoundedField that lazily multiplies a sequence of other BoundedFields. More...
 
class  Random
 A class that can be used to generate sequences of random numbers according to a number of different algorithms. More...
 
class  SeparableKernel
 A kernel described by a pair of functions: func(x, y) = colFunc(x) * rowFunc(y) More...
 
class  SpatialCell
 Class to ensure constraints for spatial modeling. More...
 
class  SpatialCellCandidate
 Base class for candidate objects in a SpatialCell. More...
 
class  SpatialCellCandidateIterator
 An iterator that only returns usable members of the SpatialCell. More...
 
class  SpatialCellImageCandidate
 Base class for candidate objects in a SpatialCell that are able to return an Image of some sort (e.g. More...
 
class  SpatialCellSet
 A collection of SpatialCells covering an entire image. More...
 
class  SquaredExpCovariogram
 SquaredExpCovariogram. More...
 
class  Statistics
 
class  StatisticsControl
 Pass parameters to a Statistics object. More...
 
class  TransformBoundedField
 A BoundedField based on geom::Transform<Poin2Endpoint, GenericEndpoint<1>>. More...
 
class  WarpingControl
 Parameters to control convolution. More...
 

Typedefs

typedef std::vector< std::shared_ptr< Kernel > > KernelList
 
typedef lsst::afw::image::VariancePixel WeightPixel
 

Enumerations

enum  UndersampleStyle { THROW_EXCEPTION, REDUCE_INTERP_ORDER, INCREASE_NXNYSAMPLE }
 
enum  Property {
  NOTHING = 0x0, ERRORS = 0x1, NPOINT = 0x2, MEAN = 0x4,
  STDEV = 0x8, VARIANCE = 0x10, MEDIAN = 0x20, IQRANGE = 0x40,
  MEANCLIP = 0x80, STDEVCLIP = 0x100, VARIANCECLIP = 0x200, MIN = 0x400,
  MAX = 0x800, SUM = 0x1000, MEANSQUARE = 0x2000, ORMASK = 0x4000,
  NCLIPPED = 0x8000, NMASKED = 0x10000
}
 control what is calculated More...
 

Functions

template<typename PixelT >
std::shared_ptr< Approximate< PixelT > > makeApproximate (std::vector< double > const &x, std::vector< double > const &y, image::MaskedImage< PixelT > const &im, lsst::geom::Box2I const &bbox, ApproximateControl const &ctrl)
 Construct a new Approximate object, inferring the type from the type of the given MaskedImage. More...
 
UndersampleStyle stringToUndersampleStyle (std::string const &style)
 Conversion function to switch a string to an UndersampleStyle. More...
 
template<typename ImageT >
std::shared_ptr< BackgroundmakeBackground (ImageT const &img, BackgroundControl const &bgCtrl)
 A convenience function that uses function overloading to make the correct type of Background. More...
 
std::shared_ptr< BoundedFieldoperator* (double const scale, std::shared_ptr< BoundedField const > bf)
 
template<typename OutImageT , typename InImageT >
void scaledPlus (OutImageT &outImage, double c1, InImageT const &inImage1, double c2, InImageT const &inImage2)
 Compute the scaled sum of two images. More...
 
template<typename OutImageT , typename InImageT >
OutImageT::SinglePixel convolveAtAPoint (typename InImageT::const_xy_locator inImageLocator, image::Image< Kernel::Pixel >::const_xy_locator kernelLocator, int kWidth, int kHeight)
 Apply convolution kernel to an image at one point. More...
 
template<typename OutImageT , typename InImageT >
OutImageT::SinglePixel convolveAtAPoint (typename InImageT::const_xy_locator inImageLocator, std::vector< Kernel::Pixel > const &kernelXList, std::vector< Kernel::Pixel > const &kernelYList)
 Apply separable convolution kernel to an image at one point. More...
 
template<typename OutImageT , typename InImageT , typename KernelT >
void convolve (OutImageT &convolvedImage, InImageT const &inImage, KernelT const &kernel, ConvolutionControl const &convolutionControl=ConvolutionControl())
 Convolve an Image or MaskedImage with a Kernel, setting pixels of an existing output image. More...
 
template<typename ImageT >
ImageT::SinglePixel edgePixel (lsst::afw::image::detail::Image_tag)
 Return an off-the-edge pixel appropriate for a given Image type. More...
 
template<typename MaskedImageT >
MaskedImageT::SinglePixel edgePixel (lsst::afw::image::detail::MaskedImage_tag)
 Return an off-the-edge pixel appropriate for a given MaskedImage type. More...
 
template<class UF >
UF::result_type int1d (UF const &func, IntRegion< typename UF::result_type > &reg, typename UF::result_type const &abserr=DEFABSERR, typename UF::result_type const &relerr=DEFRELERR)
 Front end for the 1d integrator. More...
 
template<class BF , class YREG >
BF::result_type int2d (BF const &func, IntRegion< typename BF::result_type > &reg, YREG const &yreg, typename BF::result_type const &abserr=DEFABSERR, typename BF::result_type const &relerr=DEFRELERR)
 Front end for the 2d integrator. More...
 
template<class TF , class YREG , class ZREG >
TF::result_type int3d (TF const &func, IntRegion< typename TF::result_type > &reg, YREG const &yreg, ZREG const &zreg, typename TF::result_type const &abserr=DEFABSERR, typename TF::result_type const &relerr=DEFRELERR)
 Front end for the 3d integrator. More...
 
template<class BF >
BF::result_type int2d (BF const &func, IntRegion< typename BF::result_type > &reg, IntRegion< typename BF::result_type > &yreg, typename BF::result_type const &abserr=DEFABSERR, typename BF::result_type const &relerr=DEFRELERR)
 Front end for the 2d integrator. More...
 
template<class TF >
TF::result_type int3d (TF const &func, IntRegion< typename TF::result_type > &reg, IntRegion< typename TF::result_type > &yreg, IntRegion< typename TF::result_type > &zreg, typename TF::result_type const &abserr=DEFABSERR, typename TF::result_type const &relerr=DEFRELERR)
 Front end for the 3d integrator. More...
 
template<typename UnaryFunctionT >
UnaryFunctionT::result_type integrate (UnaryFunctionT func, typename UnaryFunctionT::argument_type const a, typename UnaryFunctionT::argument_type const b, double eps=1.0e-6)
 The 1D integrator. More...
 
template<typename BinaryFunctionT >
BinaryFunctionT::result_type integrate2d (BinaryFunctionT func, typename BinaryFunctionT::first_argument_type const x1, typename BinaryFunctionT::first_argument_type const x2, typename BinaryFunctionT::second_argument_type const y1, typename BinaryFunctionT::second_argument_type const y2, double eps=1.0e-6)
 The 2D integrator. More...
 
std::shared_ptr< InterpolatemakeInterpolate (std::vector< double > const &x, std::vector< double > const &y, Interpolate::Style const style=Interpolate::AKIMA_SPLINE)
 A factory function to make Interpolate objects. More...
 
std::shared_ptr< InterpolatemakeInterpolate (ndarray::Array< double const, 1 > const &x, ndarray::Array< double const, 1 > const &y, Interpolate::Style const style=Interpolate::AKIMA_SPLINE)
 
Interpolate::Style stringToInterpStyle (std::string const &style)
 Conversion function to switch a string to an Interpolate::Style. More...
 
Interpolate::Style lookupMaxInterpStyle (int const n)
 Get the highest order Interpolation::Style available for 'n' points. More...
 
int lookupMinInterpPoints (Interpolate::Style const style)
 Get the minimum number of points needed to use the requested interpolation style. More...
 
void printKernel (lsst::afw::math::Kernel const &kernel, bool doNormalize, double x=0, double y=0, std::string pixelFmt="%7.3f")
 Print the pixel values of a Kernel to std::cout. More...
 
template<typename ReturnT >
FitResults minimize (lsst::afw::math::Function1< ReturnT > const &function, std::vector< double > const &initialParameterList, std::vector< double > const &stepSizeList, std::vector< double > const &measurementList, std::vector< double > const &varianceList, std::vector< double > const &xPositionList, double errorDef)
 Find the minimum of a function(x) More...
 
template<typename ReturnT >
FitResults minimize (lsst::afw::math::Function2< ReturnT > const &function, std::vector< double > const &initialParameterList, std::vector< double > const &stepSizeList, std::vector< double > const &measurementList, std::vector< double > const &varianceList, std::vector< double > const &xPositionList, std::vector< double > const &yPositionList, double errorDef)
 Find the minimum of a function(x, y) More...
 
template<typename ImageT >
std::shared_ptr< ImageT > offsetImage (ImageT const &image, float dx, float dy, std::string const &algorithmName="lanczos5", unsigned int buffer=0)
 Return an image offset by (dx, dy) using the specified algorithm. More...
 
template<typename ImageT >
std::shared_ptr< ImageT > rotateImageBy90 (ImageT const &image, int nQuarter)
 Rotate an image by an integral number of quarter turns. More...
 
template<typename ImageT >
std::shared_ptr< ImageT > flipImage (ImageT const &inImage, bool flipLR, bool flipTB)
 Flip an image left–right and/or top–bottom. More...
 
template<typename ImageT >
std::shared_ptr< ImageT > binImage (ImageT const &inImage, int const binX, int const binY, lsst::afw::math::Property const flags=lsst::afw::math::MEAN)
 
template<typename ImageT >
std::shared_ptr< ImageT > binImage (ImageT const &inImage, int const binsize, lsst::afw::math::Property const flags=lsst::afw::math::MEAN)
 
template<typename ImageT >
void randomUniformImage (ImageT *image, Random &rand)
 Set image to random numbers uniformly distributed in the range [0, 1) More...
 
template<typename ImageT >
void randomUniformPosImage (ImageT *image, Random &rand)
 Set image to random numbers uniformly distributed in the range (0, 1) More...
 
template<typename ImageT >
void randomUniformIntImage (ImageT *image, Random &rand, unsigned long n)
 Set image to random integers uniformly distributed in the range 0 ... More...
 
template<typename ImageT >
void randomFlatImage (ImageT *image, Random &rand, double const a, double const b)
 Set image to random numbers uniformly distributed in the range [a, b) More...
 
template<typename ImageT >
void randomGaussianImage (ImageT *image, Random &rand)
 Set image to random numbers with a gaussian N(0, 1) distribution. More...
 
template<typename ImageT >
void randomChisqImage (ImageT *image, Random &rand, double const nu)
 Set image to random numbers with a chi^2_{nu} distribution. More...
 
template<typename ImageT >
void randomPoissonImage (ImageT *image, Random &rand, double const mu)
 Set image to random numbers with a Poisson distribution with mean mu (n.b. More...
 
template<typename PixelT >
std::shared_ptr< lsst::afw::image::Image< PixelT > > statisticsStack (std::vector< std::shared_ptr< lsst::afw::image::Image< PixelT >>> &images, Property flags, StatisticsControl const &sctrl=StatisticsControl(), std::vector< lsst::afw::image::VariancePixel > const &wvector=std::vector< lsst::afw::image::VariancePixel >(0))
 A function to compute some statistics of a stack of Images. More...
 
template<typename PixelT >
void statisticsStack (lsst::afw::image::Image< PixelT > &out, std::vector< std::shared_ptr< lsst::afw::image::Image< PixelT >>> &images, Property flags, StatisticsControl const &sctrl=StatisticsControl(), std::vector< lsst::afw::image::VariancePixel > const &wvector=std::vector< lsst::afw::image::VariancePixel >(0))
 @ brief compute statistical stack of Image. More...
 
template<typename PixelT >
std::shared_ptr< lsst::afw::image::MaskedImage< PixelT > > statisticsStack (std::vector< std::shared_ptr< lsst::afw::image::MaskedImage< PixelT >>> &images, Property flags, StatisticsControl const &sctrl, std::vector< lsst::afw::image::VariancePixel > const &wvector, image::MaskPixel clipped, std::vector< std::pair< image::MaskPixel, image::MaskPixel >> const &maskMap)
 A function to compute some statistics of a stack of Masked Images. More...
 
template<typename PixelT >
std::shared_ptr< lsst::afw::image::MaskedImage< PixelT > > statisticsStack (std::vector< std::shared_ptr< lsst::afw::image::MaskedImage< PixelT >>> &images, Property flags, StatisticsControl const &sctrl=StatisticsControl(), std::vector< lsst::afw::image::VariancePixel > const &wvector=std::vector< lsst::afw::image::VariancePixel >(0), image::MaskPixel clipped=0, image::MaskPixel excuse=0)
 A function to compute some statistics of a stack of Masked Images. More...
 
template<typename PixelT >
void statisticsStack (lsst::afw::image::MaskedImage< PixelT > &out, std::vector< std::shared_ptr< lsst::afw::image::MaskedImage< PixelT >>> &images, Property flags, StatisticsControl const &sctrl, std::vector< lsst::afw::image::VariancePixel > const &wvector, image::MaskPixel clipped, std::vector< std::pair< image::MaskPixel, image::MaskPixel >> const &maskMap)
 A function to compute some statistics of a stack of Masked Images. More...
 
template<typename PixelT >
void statisticsStack (lsst::afw::image::MaskedImage< PixelT > &out, std::vector< std::shared_ptr< lsst::afw::image::MaskedImage< PixelT >>> &images, Property flags, StatisticsControl const &sctrl=StatisticsControl(), std::vector< lsst::afw::image::VariancePixel > const &wvector=std::vector< lsst::afw::image::VariancePixel >(0), image::MaskPixel clipped=0, image::MaskPixel excuse=0)
 @ brief compute statistical stack of MaskedImage. More...
 
template<typename PixelT >
std::vector< PixelT > statisticsStack (std::vector< std::vector< PixelT >> &vectors, Property flags, StatisticsControl const &sctrl=StatisticsControl(), std::vector< lsst::afw::image::VariancePixel > const &wvector=std::vector< lsst::afw::image::VariancePixel >(0))
 A function to compute some statistics of a stack of std::vectors. More...
 
template<typename PixelT >
std::shared_ptr< lsst::afw::image::MaskedImage< PixelT > > statisticsStack (lsst::afw::image::Image< PixelT > const &image, Property flags, char dimension, StatisticsControl const &sctrl=StatisticsControl())
 A function to compute statistics on the rows or columns of an image. More...
 
template<typename PixelT >
std::shared_ptr< lsst::afw::image::MaskedImage< PixelT > > statisticsStack (lsst::afw::image::MaskedImage< PixelT > const &image, Property flags, char dimension, StatisticsControl const &sctrl=StatisticsControl())
 A function to compute statistics on the rows or columns of an image. More...
 
Property stringToStatisticsProperty (std::string const property)
 Conversion function to switch a string to a Property (see Statistics.h) More...
 
template<typename Pixel >
Statistics makeStatistics (lsst::afw::image::Image< Pixel > const &img, lsst::afw::image::Mask< image::MaskPixel > const &msk, int const flags, StatisticsControl const &sctrl=StatisticsControl())
 Handle a watered-down front-end to the constructor (no variance) More...
 
template<typename ImageT , typename MaskT , typename VarianceT >
Statistics makeStatistics (ImageT const &img, MaskT const &msk, VarianceT const &var, int const flags, StatisticsControl const &sctrl=StatisticsControl())
 Handle a straight front-end to the constructor. More...
 
template<typename Pixel >
Statistics makeStatistics (lsst::afw::image::MaskedImage< Pixel > const &mimg, int const flags, StatisticsControl const &sctrl=StatisticsControl())
 Handle MaskedImages, just pass the getImage() and getMask() values right on through. More...
 
template<typename Pixel >
Statistics makeStatistics (lsst::afw::image::MaskedImage< Pixel > const &mimg, lsst::afw::image::Image< WeightPixel > const &weights, int const flags, StatisticsControl const &sctrl=StatisticsControl())
 Handle MaskedImages, just pass the getImage() and getMask() values right on through. More...
 
Statistics makeStatistics (lsst::afw::image::Mask< lsst::afw::image::MaskPixel > const &msk, int const flags, StatisticsControl const &sctrl=StatisticsControl())
 Specialization to handle Masks. More...
 
template<typename Pixel >
Statistics makeStatistics (lsst::afw::image::Image< Pixel > const &img, int const flags, StatisticsControl const &sctrl=StatisticsControl())
 The makeStatistics() overload to handle regular (non-masked) Images. More...
 
template<typename EntryT >
Statistics makeStatistics (std::vector< EntryT > const &v, int const flags, StatisticsControl const &sctrl=StatisticsControl())
 The makeStatistics() overload to handle std::vector<> More...
 
template<typename EntryT >
Statistics makeStatistics (std::vector< EntryT > const &v, std::vector< WeightPixel > const &vweights, int const flags, StatisticsControl const &sctrl=StatisticsControl())
 The makeStatistics() overload to handle std::vector<> More...
 
template<typename EntryT >
Statistics makeStatistics (lsst::afw::math::MaskedVector< EntryT > const &mv, int const flags, StatisticsControl const &sctrl=StatisticsControl())
 The makeStatistics() overload to handle lsst::afw::math::MaskedVector<> More...
 
template<typename EntryT >
Statistics makeStatistics (lsst::afw::math::MaskedVector< EntryT > const &mv, std::vector< WeightPixel > const &vweights, int const flags, StatisticsControl const &sctrl=StatisticsControl())
 The makeStatistics() overload to handle lsst::afw::math::MaskedVector<> More...
 
std::shared_ptr< SeparableKernelmakeWarpingKernel (std::string name)
 Return a warping kernel given its name. More...
 
template<typename DestExposureT , typename SrcExposureT >
int warpExposure (DestExposureT &destExposure, SrcExposureT const &srcExposure, WarpingControl const &control, typename DestExposureT::MaskedImageT::SinglePixel padValue=lsst::afw::math::edgePixel< typename DestExposureT::MaskedImageT >(typename lsst::afw::image::detail::image_traits< typename DestExposureT::MaskedImageT >::image_category()))
 Warp (remap) one exposure to another. More...
 
template<typename DestImageT , typename SrcImageT >
int warpImage (DestImageT &destImage, geom::SkyWcs const &destWcs, SrcImageT const &srcImage, geom::SkyWcs const &srcWcs, WarpingControl const &control, typename DestImageT::SinglePixel padValue=lsst::afw::math::edgePixel< DestImageT >(typename lsst::afw::image::detail::image_traits< DestImageT >::image_category()))
 Warp an Image or MaskedImage to a new Wcs. More...
 
template<typename DestImageT , typename SrcImageT >
int warpImage (DestImageT &destImage, SrcImageT const &srcImage, geom::TransformPoint2ToPoint2 const &srcToDest, WarpingControl const &control, typename DestImageT::SinglePixel padValue=lsst::afw::math::edgePixel< DestImageT >(typename lsst::afw::image::detail::image_traits< DestImageT >::image_category()))
 A variant of warpImage that uses a Transform<Point2Endpoint, Point2Endpoint> instead of a pair of WCS to describe the transformation. More...
 
template<typename DestImageT , typename SrcImageT >
int warpCenteredImage (DestImageT &destImage, SrcImageT const &srcImage, lsst::geom::LinearTransform const &linearTransform, lsst::geom::Point2D const &centerPosition, WarpingControl const &control, typename DestImageT::SinglePixel padValue=lsst::afw::math::edgePixel< DestImageT >(typename lsst::afw::image::detail::image_traits< DestImageT >::image_category()))
 Warp an image with a LinearTranform about a specified point. More...
 
 PYBIND11_MODULE (approximate, mod)
 
 PYBIND11_MODULE (background, mod)
 
 PYBIND11_MODULE (convolveImage, mod)
 
 PYBIND11_MODULE (function, mod)
 
template<typename ReturnT >
void declarePolynomialFunctions (py::module &mod, const std::string &suffix)
 
template<typename ReturnT >
void declareChebyshevFunctions (py::module &mod, const std::string &suffix)
 
template<typename ReturnT >
void declareGaussianFunctions (py::module &mod, const std::string &suffix)
 
template<typename ReturnT >
void declareIntegerDeltaFunctions (py::module &mod, const std::string &suffix)
 
template<typename ReturnT >
void declareLanczosFunctions (py::module &mod, const std::string &suffix)
 
 PYBIND11_MODULE (functionLibrary, mod)
 
 PYBIND11_MODULE (offsetImage, mod)
 
void wrapTestClasses (py::module &mod)
 
 PYBIND11_MODULE (spatialCell, mod)
 
template<typename Pixel >
void declareStatistics (py::module &mod)
 
template<typename Pixel >
void declareStatisticsVectorOverloads (py::module &mod)
 
 PYBIND11_MODULE (statistics, mod)
 
 PYBIND11_MODULE (warpExposure, mod)
 
double integrateTn (int n)
 
template<typename OutImageT , typename InImageT , typename KernelT >
void convolve (OutImageT &convolvedImage, InImageT const &inImage, KernelT const &kernel, bool doNormalize, bool doCopyEdge)
 
template<typename PixelT >
std::shared_ptr< image::MaskedImage< PixelT > > statisticsStack (std::vector< std::shared_ptr< image::MaskedImage< PixelT >>> &images, Property flags, StatisticsControl const &sctrl, WeightVector const &wvector, image::MaskPixel clipped, image::MaskPixel excuse)
 
template<typename PixelT >
std::shared_ptr< image::MaskedImage< PixelT > > statisticsStack (std::vector< std::shared_ptr< image::MaskedImage< PixelT >>> &images, Property flags, StatisticsControl const &sctrl, WeightVector const &wvector, image::MaskPixel clipped, std::vector< std::pair< image::MaskPixel, image::MaskPixel >> const &maskMap)
 
template<typename PixelT >
void statisticsStack (image::MaskedImage< PixelT > &out, std::vector< std::shared_ptr< image::MaskedImage< PixelT >>> &images, Property flags, StatisticsControl const &sctrl, WeightVector const &wvector, image::MaskPixel clipped, image::MaskPixel excuse)
 
template<typename PixelT >
void statisticsStack (image::MaskedImage< PixelT > &out, std::vector< std::shared_ptr< image::MaskedImage< PixelT >>> &images, Property flags, StatisticsControl const &sctrl, WeightVector const &wvector, image::MaskPixel clipped, std::vector< std::pair< image::MaskPixel, image::MaskPixel >> const &maskMap)
 
template<typename PixelT >
std::shared_ptr< image::Image< PixelT > > statisticsStack (std::vector< std::shared_ptr< image::Image< PixelT >>> &images, Property flags, StatisticsControl const &sctrl, WeightVector const &wvector)
 
template<typename PixelT >
void statisticsStack (image::Image< PixelT > &out, std::vector< std::shared_ptr< image::Image< PixelT >>> &images, Property flags, StatisticsControl const &sctrl, WeightVector const &wvector)
 
template<typename PixelT >
std::vector< PixelT > statisticsStack (std::vector< std::vector< PixelT >> &vectors, Property flags, StatisticsControl const &sctrl, WeightVector const &wvector)
 
template<typename PixelT >
std::shared_ptr< image::MaskedImage< PixelT > > statisticsStack (image::Image< PixelT > const &image, Property flags, char dimension, StatisticsControl const &sctrl)
 A function to compute statistics on the rows or columns of an image. More...
 
template<typename PixelT >
std::shared_ptr< image::MaskedImage< PixelT > > statisticsStack (image::MaskedImage< PixelT > const &image, Property flags, char dimension, StatisticsControl const &sctrl)
 A function to compute statistics on the rows or columns of an image. More...
 

Variables

template<typename T >
constexpr bool IS_NOTHROW_INIT = noexcept(static_cast<T>(1.0))
 Test that a Function's return value is nothrow-castable to T. More...
 
double const MOCK_INF = 1.e10
 
double const DEFABSERR = 1.e-15
 
double const DEFRELERR = 1.e-6
 
generic_kernel_tag generic_kernel_tag_
 Used as default value in argument lists. More...
 
deltafunction_kernel_tag deltafunction_kernel_tag_
 Used as default value in argument lists. More...
 

Typedef Documentation

◆ KernelList

Definition at line 463 of file Kernel.h.

◆ WeightPixel

Definition at line 58 of file Statistics.h.

Enumeration Type Documentation

◆ Property

control what is calculated

Enumerator
NOTHING 

We don't want anything.

ERRORS 

Include errors of requested quantities.

NPOINT 

number of sample points

MEAN 

estimate sample mean

STDEV 

estimate sample standard deviation

VARIANCE 

estimate sample variance

MEDIAN 

estimate sample median

IQRANGE 

estimate sample inter-quartile range

MEANCLIP 

estimate sample N-sigma clipped mean (N set in StatisticsControl, default=3)

STDEVCLIP 

estimate sample N-sigma clipped stdev (N set in StatisticsControl, default=3)

VARIANCECLIP 

estimate sample N-sigma clipped variance (N set in StatisticsControl, default=3)

MIN 

estimate sample minimum

MAX 

estimate sample maximum

SUM 

find sum of pixels in the image

MEANSQUARE 

find mean value of square of pixel values

ORMASK 

get the or-mask of all pixels used.

NCLIPPED 

number of clipped points

NMASKED 

number of masked points

Definition at line 63 of file Statistics.h.

63  {
64  NOTHING = 0x0,
65  ERRORS = 0x1,
66  NPOINT = 0x2,
67  MEAN = 0x4,
68  STDEV = 0x8,
69  VARIANCE = 0x10,
70  MEDIAN = 0x20,
71  IQRANGE = 0x40,
72  MEANCLIP = 0x80,
73  STDEVCLIP = 0x100,
74  VARIANCECLIP = 0x200,
75  MIN = 0x400,
77  MAX = 0x800,
78  SUM = 0x1000,
79  MEANSQUARE = 0x2000,
80  ORMASK = 0x4000,
81  NCLIPPED = 0x8000,
82  NMASKED = 0x10000
83 };

◆ UndersampleStyle

Enumerator
THROW_EXCEPTION 
REDUCE_INTERP_ORDER 
INCREASE_NXNYSAMPLE 

Definition at line 47 of file Background.h.

Function Documentation

◆ binImage() [1/2]

template<typename ImageT >
std::shared_ptr< ImageT > lsst::afw::math::binImage ( ImageT const &  inImage,
int const  binsize,
lsst::afw::math::Property const  flags = lsst::afw::math::MEAN 
)
Parameters
inImageThe image to bin
binsizeOutput pixels are binsize*binsize input pixels
flagshow to generate super-pixels

Definition at line 38 of file binImage.cc.

38  {
39  return binImage(in, binsize, binsize, flags);
40 }

◆ binImage() [2/2]

template<typename ImageT >
std::shared_ptr< ImageT > lsst::afw::math::binImage ( ImageT const &  inImage,
int const  binX,
int const  binY,
lsst::afw::math::Property const  flags = lsst::afw::math::MEAN 
)
Parameters
inImageThe image to bin
binXOutput pixels are binX*binY input pixels
binYOutput pixels are binX*binY input pixels
flagshow to generate super-pixels

Definition at line 43 of file binImage.cc.

44  {
45  if (flags != lsst::afw::math::MEAN) {
47  (boost::format("Only afwMath::MEAN is supported, saw 0x%x") % flags).str());
48  }
49  if (binX <= 0 || binY <= 0) {
51  (boost::format("Binning must be >= 0, saw %dx%d") % binX % binY).str());
52  }
53 
54  int const outWidth = in.getWidth() / binX;
55  int const outHeight = in.getHeight() / binY;
56 
58  std::shared_ptr<ImageT>(new ImageT(lsst::geom::Extent2I(outWidth, outHeight)));
59  out->setXY0(in.getXY0());
60  *out = typename ImageT::SinglePixel(0);
61 
62  for (int oy = 0, iy = 0; oy < out->getHeight(); ++oy) {
63  for (int i = 0; i != binY; ++i, ++iy) {
64  typename ImageT::x_iterator optr = out->row_begin(oy);
65  for (typename ImageT::x_iterator iptr = in.row_begin(iy), iend = iptr + binX * outWidth;
66  iptr < iend;) {
67  typename ImageT::SinglePixel val = *iptr;
68  ++iptr;
69  for (int j = 1; j != binX; ++j, ++iptr) {
70  val += *iptr;
71  }
72  *optr += val;
73  ++optr;
74  }
75  }
76  for (typename ImageT::x_iterator ptr = out->row_begin(oy), end = out->row_end(oy); ptr != end;
77  ++ptr) {
78  *ptr /= binX * binY;
79  }
80  }
81 
82  return out;
83 }

◆ convolve() [1/2]

template<typename OutImageT , typename InImageT , typename KernelT >
void lsst::afw::math::convolve ( OutImageT &  convolvedImage,
InImageT const &  inImage,
KernelT const &  kernel,
bool  doNormalize,
bool  doCopyEdge 
)

Definition at line 199 of file ConvolveImage.cc.

200  {
201  ConvolutionControl convolutionControl;
202  convolutionControl.setDoNormalize(doNormalize);
203  convolutionControl.setDoCopyEdge(doCopyEdge);
204  convolve(convolvedImage, inImage, kernel, convolutionControl);
205 }

◆ convolve() [2/2]

template<typename OutImageT , typename InImageT , typename KernelT >
void lsst::afw::math::convolve ( OutImageT &  convolvedImage,
InImageT const &  inImage,
KernelT const &  kernel,
ConvolutionControl const &  convolutionControl = ConvolutionControl() 
)

Convolve an Image or MaskedImage with a Kernel, setting pixels of an existing output image.

Various convolution kernels are available, including:

If a kernel is spatially varying, its spatial model is computed at each pixel position on the image (pixel position, not pixel index). At present (2009-09-24) this position is computed relative to the lower left corner of the sub-image, but it will almost certainly change to be the lower left corner of the parent image.

All convolution is performed in real space. This allows convolution to handle masked pixels and spatially varying kernels. Although convolution of an Image with a spatially invariant kernel could, in fact, be performed in Fourier space, the code does not do this.

Note that mask bits are smeared by convolution; all nonzero pixels in the kernel smear the mask, even pixels that have very small values. Larger kernels smear the mask more and are also slower to convolve. Use the smallest kernel that will do the job.

convolvedImage has a border of edge pixels which cannot be computed normally. Normally these pixels are set to the standard edge pixel, as returned by edgePixel(). However, if your code cannot handle nans in the image or infs in the variance, you may set doCopyEdge true, in which case the edge pixels are set to the corresponding pixels of the input image and (if there is a mask) the mask EDGE bit is set.

The border of edge pixels has size:

  • kernel.getCtr().getX() along the left edge
  • kernel.getCtr().getY() along the bottom edge
  • kernel.getWidth() - 1 - kernel.getCtr().getX() along the right edge
  • kernel.getHeight() - 1 - kernel.getCtr().getY() along the top edge You can obtain a bounding box for the good pixels in the convolved image from a bounding box for the entire image using the Kernel method shrinkBBox.

Convolution has been optimized for the various kinds of kernels, as follows (listed approximately in order of decreasing speed):

  • DeltaFunctionKernel convolution is a simple image shift.
  • SeparableKernel convolution is performed by convolving the input by one of the two functions, then the result by the other function. Thus convolution with a kernel of size nCols x nRows becomes convolution with a kernel of size nCols x 1, followed by convolution with a kernel of size 1 x nRows.
  • Convolution with spatially invariant versions of the other kernels is performed by computing the kernel image once and convolving with that. The code has been optimized for cache performance and so should be fairly efficient.
  • Convolution with a spatially varying LinearCombinationKernel is performed by convolving the image by each basis kernel and combining the result by solving the spatial model. This will be efficient provided the kernel does not contain too many or very large basis kernels.
  • Convolution with spatially varying AnalyticKernel is likely to be slow. The code simply computes the output one pixel at a time by computing the AnalyticKernel at that point and applying it to the input image. This is not favorable for cache performance (especially for large kernels) but avoids recomputing the AnalyticKernel. It is probably possible to do better.

Additional convolution functions include:

afw/examples offers programs that time convolution including timeConvolve and timeSpatiallyVaryingConvolve.

Parameters
[out]convolvedImageconvolved image; must be the same size as inImage
[in]inImageimage to convolve
[in]kernelconvolution kernel
[in]convolutionControlconvolution control parameters
Exceptions
lsst::pex::exceptions::InvalidParameterErrorif convolvedImage is not the same size as inImage
lsst::pex::exceptions::InvalidParameterErrorif inImage is smaller than kernel in columns and/or rows.
std::bad_allocwhen allocation of memory fails

Definition at line 190 of file ConvolveImage.cc.

191  {
192  detail::basicConvolve(convolvedImage, inImage, kernel, convolutionControl);
193  setEdgePixels(convolvedImage, kernel, inImage, convolutionControl.getDoCopyEdge(),
194  typename image::detail::image_traits<OutImageT>::image_category());
195  convolvedImage.setXY0(inImage.getXY0());
196 }

◆ convolveAtAPoint() [1/2]

template<typename OutImageT , typename InImageT >
OutImageT::SinglePixel lsst::afw::math::convolveAtAPoint ( typename InImageT::const_xy_locator  inImageLocator,
image::Image< Kernel::Pixel >::const_xy_locator  kernelLocator,
int  kWidth,
int  kHeight 
)
inline

Apply convolution kernel to an image at one point.

Note
This subroutine sacrifices convenience for performance. The user is expected to figure out the kernel center and adjust the supplied pixel accessors accordingly. For an example of how to do this see convolve().
Parameters
inImageLocatorlocator for image pixel that overlaps pixel (0,0) of kernel (the origin of the kernel, not its center)
kernelLocatorlocator for (0,0) pixel of kernel (the origin of the kernel, not its center)
kWidthnumber of columns in kernel
kHeightnumber of rows in kernel

Definition at line 259 of file ConvolveImage.h.

261  {
262  typename OutImageT::SinglePixel outValue = 0;
263  for (int kRow = 0; kRow != kHeight; ++kRow) {
265  kEnd = kernelLocator + image::detail::difference_type(kWidth, 0);
266  kernelLocator != kEnd; ++inImageLocator.x(), ++kernelLocator.x()) {
267  typename Kernel::Pixel const kVal = kernelLocator[0];
268  if (kVal != 0) {
269  outValue += *inImageLocator * kVal;
270  }
271  }
272 
273  inImageLocator += image::detail::difference_type(-kWidth, 1);
274  kernelLocator += image::detail::difference_type(-kWidth, 1);
275  }
276 
277  return outValue;
278 }

◆ convolveAtAPoint() [2/2]

template<typename OutImageT , typename InImageT >
OutImageT::SinglePixel lsst::afw::math::convolveAtAPoint ( typename InImageT::const_xy_locator  inImageLocator,
std::vector< Kernel::Pixel > const &  kernelXList,
std::vector< Kernel::Pixel > const &  kernelYList 
)
inline

Apply separable convolution kernel to an image at one point.

Note
This subroutine sacrifices convenience for performance. The user is expected to figure out the kernel center and adjust the supplied pixel accessors accordingly. For an example of how to do this see convolve().
Parameters
inImageLocatorlocator for image pixel that overlaps pixel (0,0) of kernel (the origin of the kernel, not its center)
kernelXListkernel column vector
kernelYListkernel row vector

Definition at line 295 of file ConvolveImage.h.

297  {
298  typedef typename std::vector<Kernel::Pixel>::const_iterator k_iter;
299 
300  typedef typename OutImageT::SinglePixel OutT;
301  OutT outValue = 0;
302  for (k_iter kernelYIter = kernelYList.begin(), yEnd = kernelYList.end(); kernelYIter != yEnd;
303  ++kernelYIter) {
304  OutT outValueY = 0;
305  for (k_iter kernelXIter = kernelXList.begin(), xEnd = kernelXList.end(); kernelXIter != xEnd;
306  ++kernelXIter, ++inImageLocator.x()) {
307  typename Kernel::Pixel const kValX = *kernelXIter;
308  if (kValX != 0) {
309  outValueY += *inImageLocator * kValX;
310  }
311  }
312 
313  double const kValY = *kernelYIter;
314  if (kValY != 0) {
315  outValue += outValueY * kValY;
316  }
317 
318  inImageLocator += image::detail::difference_type(-kernelXList.size(), 1);
319  }
320 
321  return outValue;
322 }

◆ declareChebyshevFunctions()

template<typename ReturnT >
void lsst::afw::math::declareChebyshevFunctions ( py::module &  mod,
const std::string suffix 
)

Definition at line 75 of file functionLibrary.cc.

75  {
76  /* Chebyshev1Function1 */
77  py::class_<Chebyshev1Function1<ReturnT>, std::shared_ptr<Chebyshev1Function1<ReturnT>>,
78  Function1<ReturnT>>
79  clsChebyshev1Function1(mod, ("Chebyshev1Function1" + suffix).c_str());
80 
81  clsChebyshev1Function1.def(py::init<std::vector<double>, double, double>(), "params"_a, "minX"_a = -1,
82  "maxX"_a = 1);
83  clsChebyshev1Function1.def(py::init<unsigned int, double, double>(), "order"_a, "minX"_a = -1,
84  "maxX"_a = 1);
85 
86  clsChebyshev1Function1.def("__call__", &Chebyshev1Function1<ReturnT>::operator(), "x"_a);
87  clsChebyshev1Function1.def("clone", &Chebyshev1Function1<ReturnT>::clone);
88  clsChebyshev1Function1.def("getMinX", &Chebyshev1Function1<ReturnT>::getMinX);
89  clsChebyshev1Function1.def("getMaxX", &Chebyshev1Function1<ReturnT>::getMaxX);
90  clsChebyshev1Function1.def("getOrder", &Chebyshev1Function1<ReturnT>::getOrder);
91  clsChebyshev1Function1.def("isLinearCombination", &Chebyshev1Function1<ReturnT>::isLinearCombination);
92  clsChebyshev1Function1.def("toString", &Chebyshev1Function1<ReturnT>::toString, "prefix"_a = "");
93 
94  /* Chebyshev1Function2 */
95  py::class_<Chebyshev1Function2<ReturnT>, std::shared_ptr<Chebyshev1Function2<ReturnT>>,
96  BasePolynomialFunction2<ReturnT>>
97  clsChebyshev1Function2(mod, ("Chebyshev1Function2" + suffix).c_str());
98 
99  clsChebyshev1Function2.def(py::init<std::vector<double>, lsst::geom::Box2D const &>(), "params"_a,
100  "xyRange"_a = lsst::geom::Box2D(lsst::geom::Point2D(-1.0, -1.0), lsst::geom::Point2D(1.0, 1.0)));
101  clsChebyshev1Function2.def(py::init<unsigned int, lsst::geom::Box2D const &>(), "order"_a,
102  "xyRange"_a = lsst::geom::Box2D(lsst::geom::Point2D(-1.0, -1.0), lsst::geom::Point2D(1.0, 1.0)));
103 
104  clsChebyshev1Function2.def("__call__", &Chebyshev1Function2<ReturnT>::operator(), "x"_a, "y"_a);
105  clsChebyshev1Function2.def("clone", &Chebyshev1Function2<ReturnT>::clone);
106  clsChebyshev1Function2.def("getXYRange", &Chebyshev1Function2<ReturnT>::getXYRange);
107  clsChebyshev1Function2.def("truncate", &Chebyshev1Function2<ReturnT>::truncate, "order"_a);
108  clsChebyshev1Function2.def("toString", &Chebyshev1Function2<ReturnT>::toString, "prefix"_a = "");
109  clsChebyshev1Function2.def("isPersistable", &Chebyshev1Function2<ReturnT>::isPersistable);
110 };

◆ declareGaussianFunctions()

template<typename ReturnT >
void lsst::afw::math::declareGaussianFunctions ( py::module &  mod,
const std::string suffix 
)

Definition at line 113 of file functionLibrary.cc.

113  {
114  /* GaussianFunction1 */
115  py::class_<GaussianFunction1<ReturnT>, std::shared_ptr<GaussianFunction1<ReturnT>>, Function1<ReturnT>>
116  clsGaussianFunction1(mod, ("GaussianFunction1" + suffix).c_str());
117 
118  clsGaussianFunction1.def(py::init<double>(), "sigma"_a);
119 
120  clsGaussianFunction1.def("__call__", &GaussianFunction1<ReturnT>::operator(), "x"_a);
121  clsGaussianFunction1.def("clone", &GaussianFunction1<ReturnT>::clone);
122  clsGaussianFunction1.def("toString", &GaussianFunction1<ReturnT>::toString, "prefix"_a = "");
123 
124  /* GaussianFunction2 */
125  py::class_<GaussianFunction2<ReturnT>, std::shared_ptr<GaussianFunction2<ReturnT>>, Function2<ReturnT>>
126  clsGaussianFunction2(mod, ("GaussianFunction2" + suffix).c_str());
127 
128  clsGaussianFunction2.def(py::init<double, double, double>(), "sigma1"_a, "sigma2"_a, "angle"_a = 0.0);
129 
130  clsGaussianFunction2.def("__call__", &GaussianFunction2<ReturnT>::operator(), "x"_a, "y"_a);
131  clsGaussianFunction2.def("clone", &GaussianFunction2<ReturnT>::clone);
132  clsGaussianFunction2.def("toString", &GaussianFunction2<ReturnT>::toString, "prefix"_a = "");
133  clsGaussianFunction2.def("isPersistable", &GaussianFunction2<ReturnT>::isPersistable);
134 
135  /* DoubleGaussianFunction2 */
136  py::class_<DoubleGaussianFunction2<ReturnT>, std::shared_ptr<DoubleGaussianFunction2<ReturnT>>,
137  Function2<ReturnT>>
138  clsDoubleGaussianFunction2(mod, ("DoubleGaussianFunction2" + suffix).c_str());
139 
140  clsDoubleGaussianFunction2.def(py::init<double, double, double>(), "sigma1"_a, "sigma2"_a = 0,
141  "ampl"_a = 0);
142 
143  clsDoubleGaussianFunction2.def("__call__", &DoubleGaussianFunction2<ReturnT>::operator(), "x"_a, "y"_a);
144  clsDoubleGaussianFunction2.def("clone", &DoubleGaussianFunction2<ReturnT>::clone);
145  clsDoubleGaussianFunction2.def("toString", &DoubleGaussianFunction2<ReturnT>::toString, "prefix"_a = "");
146  clsDoubleGaussianFunction2.def("isPersistable", &DoubleGaussianFunction2<ReturnT>::isPersistable);
147 };

◆ declareIntegerDeltaFunctions()

template<typename ReturnT >
void lsst::afw::math::declareIntegerDeltaFunctions ( py::module &  mod,
const std::string suffix 
)

Definition at line 150 of file functionLibrary.cc.

150  {
151  /* IntegerDeltaFunction1 */
152  py::class_<IntegerDeltaFunction1<ReturnT>, std::shared_ptr<IntegerDeltaFunction1<ReturnT>>,
153  Function1<ReturnT>>
154  clsIntegerDeltaFunction1(mod, ("IntegerDeltaFunction1" + suffix).c_str());
155 
156  clsIntegerDeltaFunction1.def(py::init<double>(), "xo"_a);
157 
158  clsIntegerDeltaFunction1.def("__call__", &IntegerDeltaFunction1<ReturnT>::operator(), "x"_a);
159  clsIntegerDeltaFunction1.def("clone", &IntegerDeltaFunction1<ReturnT>::clone);
160  clsIntegerDeltaFunction1.def("toString", &IntegerDeltaFunction1<ReturnT>::toString, "prefix"_a = "");
161 
162  /* IntegerDeltaFunction2 */
163  py::class_<IntegerDeltaFunction2<ReturnT>, std::shared_ptr<IntegerDeltaFunction2<ReturnT>>,
164  Function2<ReturnT>>
165  clsIntegerDeltaFunction2(mod, ("IntegerDeltaFunction2" + suffix).c_str());
166 
167  clsIntegerDeltaFunction2.def(py::init<double, double>(), "xo"_a, "yo"_a);
168 
169  clsIntegerDeltaFunction2.def("__call__", &IntegerDeltaFunction2<ReturnT>::operator(), "x"_a, "y"_a);
170  clsIntegerDeltaFunction2.def("clone", &IntegerDeltaFunction2<ReturnT>::clone);
171  clsIntegerDeltaFunction2.def("toString", &IntegerDeltaFunction2<ReturnT>::toString, "prefix"_a = "");
172 };

◆ declareLanczosFunctions()

template<typename ReturnT >
void lsst::afw::math::declareLanczosFunctions ( py::module &  mod,
const std::string suffix 
)

Definition at line 175 of file functionLibrary.cc.

175  {
176  /* LanczosFunction1 */
177  py::class_<LanczosFunction1<ReturnT>, std::shared_ptr<LanczosFunction1<ReturnT>>, Function1<ReturnT>>
178  clsLanczosFunction1(mod, ("LanczosFunction1" + suffix).c_str());
179 
180  clsLanczosFunction1.def(py::init<unsigned int, double>(), "n"_a, "xOffset"_a = 0.0);
181 
182  clsLanczosFunction1.def("__call__", &LanczosFunction1<ReturnT>::operator(), "x"_a);
183  clsLanczosFunction1.def("clone", &LanczosFunction1<ReturnT>::clone);
184  clsLanczosFunction1.def("getOrder", &LanczosFunction1<ReturnT>::getOrder);
185  clsLanczosFunction1.def("toString", &LanczosFunction1<ReturnT>::toString, "prefix"_a = "");
186 
187  /* LanczosFunction2 */
188  py::class_<LanczosFunction2<ReturnT>, std::shared_ptr<LanczosFunction2<ReturnT>>, Function2<ReturnT>>
189  clsLanczosFunction2(mod, ("LanczosFunction2" + suffix).c_str());
190 
191  clsLanczosFunction2.def(py::init<unsigned int, double, double>(), "n"_a, "xOffset"_a = 0.0,
192  "yOffset"_a = 0.0);
193 
194  clsLanczosFunction2.def("__call__", &LanczosFunction2<ReturnT>::operator(), "x"_a, "y"_a);
195  clsLanczosFunction2.def("clone", &LanczosFunction2<ReturnT>::clone);
196  clsLanczosFunction2.def("getOrder", &LanczosFunction2<ReturnT>::getOrder);
197  clsLanczosFunction2.def("toString", &LanczosFunction2<ReturnT>::toString, "prefix"_a = "");
198 };

◆ declarePolynomialFunctions()

template<typename ReturnT >
void lsst::afw::math::declarePolynomialFunctions ( py::module &  mod,
const std::string suffix 
)

Definition at line 43 of file functionLibrary.cc.

43  {
44  /* PolynomialFunction1 */
45  py::class_<PolynomialFunction1<ReturnT>, std::shared_ptr<PolynomialFunction1<ReturnT>>,
46  Function1<ReturnT>>
47  clsPolynomialFunction1(mod, ("PolynomialFunction1" + suffix).c_str());
48 
49  clsPolynomialFunction1.def(py::init<std::vector<double> const &>(), "params"_a);
50  clsPolynomialFunction1.def(py::init<unsigned int>(), "order"_a);
51 
52  clsPolynomialFunction1.def("__call__", &PolynomialFunction1<ReturnT>::operator(), "x"_a);
53  clsPolynomialFunction1.def("clone", &PolynomialFunction1<ReturnT>::clone);
54  clsPolynomialFunction1.def("isLinearCombination", &PolynomialFunction1<ReturnT>::isLinearCombination);
55  clsPolynomialFunction1.def("getOrder", &PolynomialFunction1<ReturnT>::getOrder);
56  clsPolynomialFunction1.def("toString", &PolynomialFunction1<ReturnT>::toString, "prefix"_a = "");
57 
58  /* PolynomialFunction2 */
59  py::class_<PolynomialFunction2<ReturnT>, std::shared_ptr<PolynomialFunction2<ReturnT>>,
60  BasePolynomialFunction2<ReturnT>>
61  clsPolynomialFunction2(mod, ("PolynomialFunction2" + suffix).c_str());
62 
63  clsPolynomialFunction2.def(py::init<std::vector<double> const &>(), "params"_a);
64  clsPolynomialFunction2.def(py::init<unsigned int>(), "order"_a);
65 
66  clsPolynomialFunction2.def("__call__", &PolynomialFunction2<ReturnT>::operator(), "x"_a, "y"_a);
67  clsPolynomialFunction2.def("clone", &PolynomialFunction2<ReturnT>::clone);
68  clsPolynomialFunction2.def("getOrder", &PolynomialFunction2<ReturnT>::getOrder);
69  clsPolynomialFunction2.def("getDFuncDParameters", &PolynomialFunction2<ReturnT>::getDFuncDParameters);
70  clsPolynomialFunction2.def("toString", &PolynomialFunction2<ReturnT>::toString, "prefix"_a = "");
71  clsPolynomialFunction2.def("isPersistable", &PolynomialFunction2<ReturnT>::isPersistable);
72 };

◆ declareStatistics()

template<typename Pixel >
void lsst::afw::math::declareStatistics ( py::module &  mod)

Definition at line 36 of file statistics.cc.

36  {
37  mod.def("makeStatistics",
38  (Statistics(*)(image::Image<Pixel> const &, image::Mask<image::MaskPixel> const &, int const,
39  StatisticsControl const &))makeStatistics<Pixel>,
40  "img"_a, "msk"_a, "flags"_a, "sctrl"_a = StatisticsControl());
41  mod.def("makeStatistics", (Statistics(*)(image::MaskedImage<Pixel> const &, int const,
42  StatisticsControl const &))makeStatistics<Pixel>,
43  "mimg"_a, "flags"_a, "sctrl"_a = StatisticsControl());
44  mod.def("makeStatistics",
45  (Statistics(*)(image::MaskedImage<Pixel> const &, image::Image<WeightPixel> const &, int const,
46  StatisticsControl const &))makeStatistics<Pixel>,
47  "mimg"_a, "weights"_a, "flags"_a, "sctrl"_a = StatisticsControl());
48  mod.def("makeStatistics",
49  (Statistics(*)(image::Mask<image::MaskPixel> const &, int const, StatisticsControl const &))
50  makeStatistics, // this is not a template, just a regular overload
51  "msk"_a,
52  "flags"_a, "sctrl"_a = StatisticsControl());
53  mod.def("makeStatistics", (Statistics(*)(image::Image<Pixel> const &, int const,
54  StatisticsControl const &))makeStatistics<Pixel>,
55  "img"_a, "flags"_a, "sctrl"_a = StatisticsControl());
56 }

◆ declareStatisticsVectorOverloads()

template<typename Pixel >
void lsst::afw::math::declareStatisticsVectorOverloads ( py::module &  mod)

Definition at line 59 of file statistics.cc.

59  {
60  mod.def("makeStatistics", (Statistics(*)(std::vector<Pixel> const &, int const,
61  StatisticsControl const &))makeStatistics<Pixel>,
62  "v"_a, "flags"_a, "sctrl"_a = StatisticsControl());
63  mod.def("makeStatistics", (Statistics(*)(std::vector<Pixel> const &, std::vector<WeightPixel> const &,
64  int const, StatisticsControl const &))makeStatistics<Pixel>,
65  "v"_a, "vweights"_a, "flags"_a, "sctrl"_a = StatisticsControl());
66 }

◆ edgePixel() [1/2]

template<typename ImageT >
ImageT::SinglePixel lsst::afw::math::edgePixel ( lsst::afw::image::detail::Image_tag  )

Return an off-the-edge pixel appropriate for a given Image type.

The value is quiet_NaN if that exists for the pixel type, else 0

Definition at line 200 of file ConvolveImage.h.

202  {
203  typedef typename ImageT::SinglePixel SinglePixelT;
206  : 0);
207 }

◆ edgePixel() [2/2]

template<typename MaskedImageT >
MaskedImageT::SinglePixel lsst::afw::math::edgePixel ( lsst::afw::image::detail::MaskedImage_tag  )

Return an off-the-edge pixel appropriate for a given MaskedImage type.

The components are:

  • image = quiet_NaN if that exists for the pixel type, else 0
  • mask = NO_DATA bit set
  • variance = infinity if that exists for the pixel type, else 0
Exceptions
lsst::pex::exceptions::LogicErrorThrown if the global mask plane dictionary does not have a NO_DATA bit.

Definition at line 221 of file ConvolveImage.h.

224  {
225  typedef typename MaskedImageT::Image::Pixel ImagePixelT;
226  typedef typename MaskedImageT::Variance::Pixel VariancePixelT;
227 
230  : 0;
231  auto maskPixel = MaskedImageT::Mask::getPlaneBitMask("NO_DATA");
234  : 0;
235  return typename MaskedImageT::SinglePixel(imagePixel, maskPixel, variancePixel);
236 }

◆ flipImage()

template<typename ImageT >
std::shared_ptr< ImageT > lsst::afw::math::flipImage ( ImageT const &  inImage,
bool  flipLR,
bool  flipTB 
)

Flip an image left–right and/or top–bottom.

Parameters
inImageThe image to flip
flipLRFlip left <--> right?
flipTBFlip top <--> bottom?

Definition at line 92 of file rotateImage.cc.

92  {
93  std::shared_ptr<ImageT> outImage(new ImageT(inImage, true)); // Output image
94 
95  if (flipLR) {
96  if (flipTB) {
97  for (int y = 0; y != inImage.getHeight(); ++y) {
98  typename ImageT::x_iterator optr =
99  outImage->x_at(inImage.getWidth() - 1, inImage.getHeight() - y - 1);
100  for (typename ImageT::x_iterator iptr = inImage.row_begin(y), end = inImage.row_end(y);
101  iptr != end; ++iptr, optr -= 1) {
102  *optr = *iptr;
103  }
104  }
105  } else {
106  for (int y = 0; y != inImage.getHeight(); ++y) {
107  typename ImageT::x_iterator optr = outImage->x_at(inImage.getWidth() - 1, y);
108  for (typename ImageT::x_iterator iptr = inImage.row_begin(y), end = inImage.row_end(y);
109  iptr != end; ++iptr, optr -= 1) {
110  *optr = *iptr;
111  }
112  }
113  }
114  } else {
115  if (flipTB) {
116  for (int y = 0; y != inImage.getHeight(); ++y) {
117  typename ImageT::x_iterator optr = outImage->row_begin(inImage.getHeight() - y - 1);
118  for (typename ImageT::x_iterator iptr = inImage.row_begin(y), end = inImage.row_end(y);
119  iptr != end; ++iptr, ++optr) {
120  *optr = *iptr;
121  }
122  }
123  } else {
124  ; // nothing to do
125  }
126  }
127 
128  return outImage;
129 }

◆ int1d()

template<class UF >
UF::result_type lsst::afw::math::int1d ( UF const &  func,
IntRegion< typename UF::result_type > &  reg,
typename UF::result_type const &  abserr = DEFABSERR,
typename UF::result_type const &  relerr = DEFRELERR 
)
inline

Front end for the 1d integrator.

Definition at line 765 of file Integrate.h.

767  {
768  typedef typename UF::result_type UfResult;
769  using namespace details;
770 
771  integ_dbg2 << "start int1d: " << reg.Left() << ".." << reg.Right() << std::endl;
772 
773  if ((reg.Left() <= -MOCK_INF && reg.Right() > 0) || (reg.Right() >= MOCK_INF && reg.Left() < 0)) {
774  reg.AddSplit(0);
775  }
776 
777  if (reg.NSplit() > 0) {
779  reg.SubDivide(&children);
780  integ_dbg2 << "Subdivided into " << children.size() << " children\n";
781  UfResult answer = UfResult();
782  UfResult err = 0;
783  for (size_t i = 0; i < children.size(); i++) {
784  IntRegion<UfResult> &child = children[i];
785  integ_dbg2 << "i = " << i;
786  integ_dbg2 << ": bounds = " << child.Left() << ", " << child.Right() << std::endl;
787  answer += int1d(func, child, abserr, relerr);
788  err += child.Err();
789  integ_dbg2 << "subint = " << child.Area() << " +- " << child.Err() << std::endl;
790  }
791  reg.SetArea(answer, err);
792  return answer;
793 
794  } else {
795  if (reg.Left() <= -MOCK_INF) {
796  integ_dbg2 << "left = -infinity, right = " << reg.Right() << std::endl;
797  assert(reg.Right() <= 0.0);
798  IntRegion<UfResult> modreg(1.0 / (reg.Right() - 1.0), 0.0, reg.getDbgout());
799  intGKP(Aux2<UF>(func), modreg, abserr, relerr);
800  reg.SetArea(modreg.Area(), modreg.Err());
801  } else if (reg.Right() >= MOCK_INF) {
802  integ_dbg2 << "left = " << reg.Left() << ", right = infinity\n";
803  assert(reg.Left() >= 0.0);
804  IntRegion<UfResult> modreg(0.0, 1.0 / (reg.Left() + 1.0), reg.getDbgout());
805  intGKP(Aux1<UF>(func), modreg, abserr, relerr);
806  reg.SetArea(modreg.Area(), modreg.Err());
807  } else {
808  integ_dbg2 << "left = " << reg.Left();
809  integ_dbg2 << ", right = " << reg.Right() << std::endl;
810  intGKP(func, reg, abserr, relerr);
811  }
812  integ_dbg2 << "done int1d answer = " << reg.Area();
813  integ_dbg2 << " +- " << reg.Err() << std::endl;
814  return reg.Area();
815  }
816 }

◆ int2d() [1/2]

template<class BF >
BF::result_type lsst::afw::math::int2d ( BF const &  func,
IntRegion< typename BF::result_type > &  reg,
IntRegion< typename BF::result_type > &  yreg,
typename BF::result_type const &  abserr = DEFABSERR,
typename BF::result_type const &  relerr = DEFRELERR 
)
inline

Front end for the 2d integrator.

Definition at line 855 of file Integrate.h.

858  {
859  using namespace details;
860  return int2d(func, reg, ConstantReg1<typename BF::result_type>(yreg), abserr, relerr);
861 }

◆ int2d() [2/2]

template<class BF , class YREG >
BF::result_type lsst::afw::math::int2d ( BF const &  func,
IntRegion< typename BF::result_type > &  reg,
YREG const &  yreg,
typename BF::result_type const &  abserr = DEFABSERR,
typename BF::result_type const &  relerr = DEFRELERR 
)
inline

Front end for the 2d integrator.

Definition at line 822 of file Integrate.h.

824  {
825  using namespace details;
826  integ_dbg2 << "Starting int2d: range = ";
827  integ_dbg2 << reg.Left() << ".." << reg.Right() << std::endl;
828  Int2DAuxType<BF, YREG> faux(func, yreg, abserr * 1.0e-3, relerr * 1.0e-3);
829  typename BF::result_type answer = int1d(faux, reg, abserr, relerr);
830  integ_dbg2 << "done int2d answer = " << answer << " +- " << reg.Err() << std::endl;
831  return answer;
832 }

◆ int3d() [1/2]

template<class TF >
TF::result_type lsst::afw::math::int3d ( TF const &  func,
IntRegion< typename TF::result_type > &  reg,
IntRegion< typename TF::result_type > &  yreg,
IntRegion< typename TF::result_type > &  zreg,
typename TF::result_type const &  abserr = DEFABSERR,
typename TF::result_type const &  relerr = DEFRELERR 
)
inline

Front end for the 3d integrator.

Definition at line 867 of file Integrate.h.

871  {
872  using namespace details;
873  return int3d(func, reg, ConstantReg1<typename TF::result_type>(yreg),
874  ConstantReg2<typename TF::result_type>(zreg), abserr, relerr);
875 }

◆ int3d() [2/2]

template<class TF , class YREG , class ZREG >
TF::result_type lsst::afw::math::int3d ( TF const &  func,
IntRegion< typename TF::result_type > &  reg,
YREG const &  yreg,
ZREG const &  zreg,
typename TF::result_type const &  abserr = DEFABSERR,
typename TF::result_type const &  relerr = DEFRELERR 
)
inline

Front end for the 3d integrator.

Definition at line 838 of file Integrate.h.

841  {
842  using namespace details;
843  integ_dbg2 << "Starting int3d: range = ";
844  integ_dbg2 << reg.Left() << ".." << reg.Right() << std::endl;
845  Int3DAuxType<TF, YREG, ZREG> faux(func, yreg, zreg, abserr * 1.e-3, relerr * 1.e-3);
846  typename TF::result_type answer = int1d(faux, reg, abserr, relerr);
847  integ_dbg2 << "done int3d answer = " << answer << " +- " << reg.Err() << std::endl;
848  return answer;
849 }

◆ integrate()

template<typename UnaryFunctionT >
UnaryFunctionT::result_type lsst::afw::math::integrate ( UnaryFunctionT  func,
typename UnaryFunctionT::argument_type const  a,
typename UnaryFunctionT::argument_type const  b,
double  eps = 1.0e-6 
)

The 1D integrator.

Note
This simply wraps the int1d function above and handles the instantiation of the intRegion.

Definition at line 886 of file Integrate.h.

889  {
890  typedef typename UnaryFunctionT::argument_type Arg;
891  IntRegion<Arg> region(a, b);
892 
893  return int1d(func, region, DEFABSERR, eps);
894 }

◆ integrate2d()

template<typename BinaryFunctionT >
BinaryFunctionT::result_type lsst::afw::math::integrate2d ( BinaryFunctionT  func,
typename BinaryFunctionT::first_argument_type const  x1,
typename BinaryFunctionT::first_argument_type const  x2,
typename BinaryFunctionT::second_argument_type const  y1,
typename BinaryFunctionT::second_argument_type const  y2,
double  eps = 1.0e-6 
)

The 2D integrator.

Note
Adapted from RHL's SDSS code

Definition at line 935 of file Integrate.h.

940  {
941  using namespace details;
942  // note the more stringent eps requirement to ensure the requested limit
943  // can be reached.
944  FunctionWrapper<BinaryFunctionT> fwrap(func, x1, x2, eps);
945  return integrate(fwrap, y1, y2, eps);
946 }

◆ integrateTn()

double lsst::afw::math::integrateTn ( int  n)

Definition at line 290 of file ChebyshevBoundedField.cc.

290  {
291  if (n % 2 == 1)
292  return 0;
293  else
294  return 2.0 / (1.0 - double(n * n));
295 }

◆ lookupMaxInterpStyle()

Interpolate::Style lsst::afw::math::lookupMaxInterpStyle ( int const  n)

Get the highest order Interpolation::Style available for 'n' points.

Parameters
nNumber of points

Definition at line 275 of file Interpolate.cc.

275  {
276  if (n < 1) {
277  throw LSST_EXCEPT(pex::exceptions::InvalidParameterError, "n must be greater than 0");
278  } else if (n > 4) {
279  return Interpolate::AKIMA_SPLINE;
280  } else {
281  static std::vector<Interpolate::Style> styles;
282  if (styles.empty()) {
283  styles.resize(5);
284 
285  styles[0] = Interpolate::UNKNOWN; // impossible to reach as we check for n < 1
286  styles[1] = Interpolate::CONSTANT;
287  styles[2] = Interpolate::LINEAR;
288  styles[3] = Interpolate::CUBIC_SPLINE;
289  styles[4] = Interpolate::CUBIC_SPLINE;
290  }
291  return styles[n];
292  }
293 }

◆ lookupMinInterpPoints()

int lsst::afw::math::lookupMinInterpPoints ( Interpolate::Style const  style)

Get the minimum number of points needed to use the requested interpolation style.

Parameters
styleThe style in question

Definition at line 314 of file Interpolate.cc.

314  {
315  static std::vector<int> minPoints;
316  if (minPoints.empty()) {
317  minPoints.resize(Interpolate::NUM_STYLES);
318  minPoints[Interpolate::CONSTANT] = 1;
319  minPoints[Interpolate::LINEAR] = 2;
320  minPoints[Interpolate::NATURAL_SPLINE] = 3;
321  minPoints[Interpolate::CUBIC_SPLINE] = 3;
322  minPoints[Interpolate::CUBIC_SPLINE_PERIODIC] = 3;
323  minPoints[Interpolate::AKIMA_SPLINE] = 5;
324  minPoints[Interpolate::AKIMA_SPLINE_PERIODIC] = 5;
325  }
326 
327  if (style >= 0 && style < Interpolate::NUM_STYLES) {
328  return minPoints[style];
329  } else {
330  throw LSST_EXCEPT(
331  pex::exceptions::OutOfRangeError,
332  str(boost::format("Style %d is out of range 0..%d") % style % (Interpolate::NUM_STYLES - 1)));
333  }
334 }

◆ makeApproximate()

template<typename PixelT >
std::shared_ptr< Approximate< PixelT > > lsst::afw::math::makeApproximate ( std::vector< double > const &  x,
std::vector< double > const &  y,
image::MaskedImage< PixelT > const &  im,
lsst::geom::Box2I const &  bbox,
ApproximateControl const &  ctrl 
)

Construct a new Approximate object, inferring the type from the type of the given MaskedImage.

Parameters
xthe x-values of points
ythe y-values of points
imThe values at (x, y)
bboxRange where approximation should be valid
ctrldesired approximation algorithm

Definition at line 279 of file Approximate.cc.

283  {
284  switch (ctrl.getStyle()) {
285  case ApproximateControl::CHEBYSHEV:
287  new ApproximateChebyshev<PixelT>(x, y, im, bbox, ctrl));
288  default:
290  str(boost::format("Unknown ApproximationStyle: %d") % ctrl.getStyle()));
291  }
292 }

◆ makeBackground()

template<typename ImageT >
std::shared_ptr<Background> lsst::afw::math::makeBackground ( ImageT const &  img,
BackgroundControl const &  bgCtrl 
)

A convenience function that uses function overloading to make the correct type of Background.

cf. std::make_pair()

Definition at line 526 of file Background.h.

526  {
527  return std::shared_ptr<Background>(new BackgroundMI(img, bgCtrl));
528 }

◆ makeInterpolate() [1/2]

std::shared_ptr< Interpolate > lsst::afw::math::makeInterpolate ( ndarray::Array< double const, 1 > const &  x,
ndarray::Array< double const, 1 > const &  y,
Interpolate::Style const  style = Interpolate::AKIMA_SPLINE 
)

Definition at line 353 of file Interpolate.cc.

355  {
356  return makeInterpolate(std::vector<double>(x.begin(), x.end()), std::vector<double>(y.begin(), y.end()),
357  style);
358 }

◆ makeInterpolate() [2/2]

std::shared_ptr< Interpolate > lsst::afw::math::makeInterpolate ( std::vector< double > const &  x,
std::vector< double > const &  y,
Interpolate::Style const  style = Interpolate::AKIMA_SPLINE 
)

A factory function to make Interpolate objects.

Parameters
xthe x-values of points
ythe values at x[]
styledesired interpolator
Examples
splineInterpolate.cc.

Definition at line 343 of file Interpolate.cc.

344  {
345  switch (style) {
346  case Interpolate::CONSTANT:
347  return std::shared_ptr<Interpolate>(new InterpolateConstant(x, y, style));
348  default: // use GSL
349  return std::shared_ptr<Interpolate>(new InterpolateGsl(x, y, style));
350  }
351 }

◆ makeStatistics() [1/10]

template<typename ImageT , typename MaskT , typename VarianceT >
Statistics makeStatistics ( ImageT const &  img,
MaskT const &  msk,
VarianceT const &  var,
int const  flags,
StatisticsControl const &  sctrl = StatisticsControl() 
)

Handle a straight front-end to the constructor.

Definition at line 366 of file Statistics.h.

367  {
368  return Statistics(img, msk, var, flags, sctrl);
369 }

◆ makeStatistics() [2/10]

template<typename Pixel >
Statistics makeStatistics ( lsst::afw::image::Image< Pixel > const &  img,
int const  flags,
StatisticsControl const &  sctrl = StatisticsControl() 
)

The makeStatistics() overload to handle regular (non-masked) Images.

Parameters
imgImage (or Image) whose properties we want
flagsDescribe what we want to calculate
sctrlControl calculation

Definition at line 420 of file Statistics.h.

424  {
425  // make a phony mask that will be compiled out
426  MaskImposter<lsst::afw::image::MaskPixel> const msk;
427  MaskImposter<WeightPixel> const var;
428  return Statistics(img, msk, var, flags, sctrl);
429 }

◆ makeStatistics() [3/10]

template<typename Pixel >
Statistics makeStatistics ( lsst::afw::image::Image< Pixel > const &  img,
lsst::afw::image::Mask< image::MaskPixel > const &  msk,
int const  flags,
StatisticsControl const &  sctrl = StatisticsControl() 
)

Handle a watered-down front-end to the constructor (no variance)

Examples
imageStatistics.cc.

Definition at line 354 of file Statistics.h.

356  {
357  MaskImposter<WeightPixel> var;
358  return Statistics(img, msk, var, flags, sctrl);
359 }

◆ makeStatistics() [4/10]

Statistics lsst::afw::math::makeStatistics ( lsst::afw::image::Mask< lsst::afw::image::MaskPixel > const &  msk,
int const  flags,
StatisticsControl const &  sctrl = StatisticsControl() 
)

Specialization to handle Masks.

Parameters
mskImage (or MaskedImage) whose properties we want
flagsDescribe what we want to calculate
sctrlControl how things are calculated

Definition at line 1113 of file Statistics.cc.

1114  {
1115  return Statistics(msk, msk, msk, flags, sctrl);
1116 }

◆ makeStatistics() [5/10]

template<typename Pixel >
Statistics makeStatistics ( lsst::afw::image::MaskedImage< Pixel > const &  mimg,
int const  flags,
StatisticsControl const &  sctrl = StatisticsControl() 
)

Handle MaskedImages, just pass the getImage() and getMask() values right on through.

Definition at line 376 of file Statistics.h.

377  {
378  if (sctrl.getWeighted() || sctrl.getCalcErrorFromInputVariance()) {
379  return Statistics(*mimg.getImage(), *mimg.getMask(), *mimg.getVariance(), flags, sctrl);
380  } else {
381  MaskImposter<WeightPixel> var;
382  return Statistics(*mimg.getImage(), *mimg.getMask(), var, flags, sctrl);
383  }
384 }

◆ makeStatistics() [6/10]

template<typename Pixel >
Statistics makeStatistics ( lsst::afw::image::MaskedImage< Pixel > const &  mimg,
lsst::afw::image::Image< WeightPixel > const &  weights,
int const  flags,
StatisticsControl const &  sctrl = StatisticsControl() 
)

Handle MaskedImages, just pass the getImage() and getMask() values right on through.

Definition at line 391 of file Statistics.h.

393  {
394  if (sctrl.getWeighted() || sctrl.getCalcErrorFromInputVariance() ||
395  (!sctrl.getWeightedIsSet() && (weights.getWidth() != 0 && weights.getHeight() != 0))) {
396  return Statistics(*mimg.getImage(), *mimg.getMask(), *mimg.getVariance(), weights, flags, sctrl);
397  } else {
398  MaskImposter<WeightPixel> var;
399  return Statistics(*mimg.getImage(), *mimg.getMask(), var, weights, flags, sctrl);
400  }
401 }

◆ makeStatistics() [7/10]

template<typename EntryT >
Statistics makeStatistics ( lsst::afw::math::MaskedVector< EntryT > const &  mv,
int const  flags,
StatisticsControl const &  sctrl = StatisticsControl() 
)

The makeStatistics() overload to handle lsst::afw::math::MaskedVector<>

Parameters
mvMaskedVector
flagsDescribe what we want to calculate
sctrlControl calculation

Definition at line 503 of file Statistics.h.

506  {
507  if (sctrl.getWeighted() || sctrl.getCalcErrorFromInputVariance()) {
508  return Statistics(*mv.getImage(), *mv.getMask(), *mv.getVariance(), flags, sctrl);
509  } else {
510  MaskImposter<WeightPixel> var;
511  return Statistics(*mv.getImage(), *mv.getMask(), var, flags, sctrl);
512  }
513 }

◆ makeStatistics() [8/10]

template<typename EntryT >
Statistics makeStatistics ( lsst::afw::math::MaskedVector< EntryT > const &  mv,
std::vector< WeightPixel > const &  vweights,
int const  flags,
StatisticsControl const &  sctrl = StatisticsControl() 
)

The makeStatistics() overload to handle lsst::afw::math::MaskedVector<>

Parameters
mvMaskedVector
vweightsweights
flagsDescribe what we want to calculate
sctrlControl calculation

Definition at line 520 of file Statistics.h.

524  {
525  ImageImposter<WeightPixel> weights(vweights);
526 
527  if (sctrl.getWeighted() || sctrl.getCalcErrorFromInputVariance()) {
528  return Statistics(*mv.getImage(), *mv.getMask(), *mv.getVariance(), weights, flags, sctrl);
529  } else {
530  MaskImposter<WeightPixel> var;
531  return Statistics(*mv.getImage(), *mv.getMask(), var, weights, flags, sctrl);
532  }
533 }

◆ makeStatistics() [9/10]

template<typename EntryT >
Statistics makeStatistics ( std::vector< EntryT > const &  v,
int const  flags,
StatisticsControl const &  sctrl = StatisticsControl() 
)

The makeStatistics() overload to handle std::vector<>

Parameters
vImage (or MaskedImage) whose properties we want
flagsDescribe what we want to calculate
sctrlControl calculation

Definition at line 469 of file Statistics.h.

472  {
473  ImageImposter<EntryT> img(v); // wrap the vector in a fake image
474  MaskImposter<lsst::afw::image::MaskPixel> msk; // instantiate a fake mask that will be compiled out.
475  MaskImposter<WeightPixel> var;
476  return Statistics(img, msk, var, flags, sctrl);
477 }

◆ makeStatistics() [10/10]

template<typename EntryT >
Statistics makeStatistics ( std::vector< EntryT > const &  v,
std::vector< WeightPixel > const &  vweights,
int const  flags,
StatisticsControl const &  sctrl = StatisticsControl() 
)

The makeStatistics() overload to handle std::vector<>

Parameters
vImage (or MaskedImage) whose properties we want
vweightsWeights
flagsDescribe what we want to calculate
sctrlControl calculation

Definition at line 484 of file Statistics.h.

488  {
489  ImageImposter<EntryT> img(v); // wrap the vector in a fake image
490  MaskImposter<lsst::afw::image::MaskPixel> msk; // instantiate a fake mask that will be compiled out.
491  MaskImposter<WeightPixel> var;
492 
493  ImageImposter<WeightPixel> weights(vweights);
494 
495  return Statistics(img, msk, var, weights, flags, sctrl);
496 }

◆ makeWarpingKernel()

std::shared_ptr< SeparableKernel > lsst::afw::math::makeWarpingKernel ( std::string  name)

Return a warping kernel given its name.

Intended for use with warpImage() and warpExposure().

Allowed names are:

A warping kernel is a subclass of SeparableKernel with the following properties (though for the sake of speed few, if any, of these are enforced):

  • Width and height are even. This is unusual for a kernel, but it is more efficient because if the extra pixel was included it would always have value 0.
  • The center pixels should be adjacent to the kernel center. Again, this avoids extra pixels that are sure to have value 0.
  • It has two parameters: fractional x and fractional row position on the source image. The fractional position is the offset of the pixel position on the source from the center of a nearby source pixel:
    • The pixel whose center is just below or to the left of the source position: 0 <= fractional x and y < 0 and the kernel center is the default (size-1)/2.
    • The pixel whose center is just above or to the right of the source position: -1.0 < fractional x and y <= 0 and the kernel center must be set to (size+1)/2.

Definition at line 161 of file warpExposure.cc.

161  {
162  typedef std::shared_ptr<SeparableKernel> KernelPtr;
163  boost::cmatch matches;
164  static const boost::regex LanczosRE("lanczos(\\d+)");
165  if (name == "bilinear") {
166  return KernelPtr(new BilinearWarpingKernel());
167  } else if (boost::regex_match(name.c_str(), matches, LanczosRE)) {
168  std::string orderStr(matches[1].first, matches[1].second);
169  int order;
170  std::istringstream(orderStr) >> order;
171  return KernelPtr(new LanczosWarpingKernel(order));
172  } else if (name == "nearest") {
173  return KernelPtr(new NearestWarpingKernel());
174  } else {
175  throw LSST_EXCEPT(pexExcept::InvalidParameterError, "unknown warping kernel name: \"" + name + "\"");
176  }
177 }

◆ minimize() [1/2]

template<typename ReturnT >
FitResults lsst::afw::math::minimize ( lsst::afw::math::Function1< ReturnT > const &  function,
std::vector< double > const &  initialParameterList,
std::vector< double > const &  stepSizeList,
std::vector< double > const &  measurementList,
std::vector< double > const &  varianceList,
std::vector< double > const &  xPositionList,
double  errorDef 
)

Find the minimum of a function(x)

Parameters
functionfunction(x) to be minimized
initialParameterListinitial guess for parameters
stepSizeListstep size for each parameter; use 0.0 to fix a parameter
measurementListmeasured values
varianceListvariance for each measurement
xPositionListx position of each measurement
errorDefwhat is this?
Returns
true if minimum is valid, false otherwise

Uses the Minuit fitting package with a standard definition of chiSq (see MinimizerFunctionBase1).

Exceptions
lsst::pex::exceptions::InvalidParameterErrorif any input vector is the wrong length

To do:

  • Document stepSizeList better
  • Document errorDef
  • Compute stepSize automatically? (if so, find a different way to fix parameters)

Definition at line 175 of file minimize.cc.

178  {
179  unsigned int const nParameters = function.getNParameters();
180  if (initialParameterList.size() != nParameters) {
181  throw LSST_EXCEPT(pex::exceptions::InvalidParameterError, "initialParameterList is the wrong length");
182  }
183  if (stepSizeList.size() != nParameters) {
184  throw LSST_EXCEPT(pex::exceptions::InvalidParameterError, "stepSizeList is the wrong length");
185  }
186  unsigned int const nMeasurements = measurementList.size();
187  if (varianceList.size() != nMeasurements) {
188  throw LSST_EXCEPT(pex::exceptions::InvalidParameterError, "varianceList is the wrong length");
189  }
190  if (xPositionList.size() != nMeasurements) {
191  throw LSST_EXCEPT(pex::exceptions::InvalidParameterError, "xPositionList is the wrong length");
192  }
193 
194  MinimizerFunctionBase1<ReturnT> minimizerFunc(function, measurementList, varianceList, xPositionList,
195  errorDef);
196 
197  ROOT::Minuit2::MnUserParameters fitPar;
198  std::vector<std::string> paramNames;
199  for (unsigned int i = 0; i < nParameters; ++i) {
200  paramNames.push_back((boost::format("p%d") % i).str());
201  fitPar.Add(paramNames[i].c_str(), initialParameterList[i], stepSizeList[i]);
202  }
203 
204  ROOT::Minuit2::MnMigrad migrad(minimizerFunc, fitPar);
205  ROOT::Minuit2::FunctionMinimum min = migrad();
206  ROOT::Minuit2::MnMinos minos(minimizerFunc, min);
207 
208  FitResults fitResults;
209  fitResults.chiSq = min.Fval();
210  fitResults.isValid = min.IsValid() && std::isfinite(fitResults.chiSq);
211  if (!fitResults.isValid) {
212  LOGL_WARN("afw.math.minimize", "Fit failed to converge");
213  }
214 
215  for (unsigned int i = 0; i < nParameters; ++i) {
216  fitResults.parameterList.push_back(min.UserState().Value(paramNames[i].c_str()));
217  if (fitResults.isValid) {
218  fitResults.parameterErrorList.push_back(minos(i));
219  } else {
220  double e = min.UserState().Error(paramNames[i].c_str());
221  std::pair<double, double> ep(-1 * e, e);
222  fitResults.parameterErrorList.push_back(ep);
223  }
224  }
225  return fitResults;
226 }

◆ minimize() [2/2]

template<typename ReturnT >
FitResults lsst::afw::math::minimize ( lsst::afw::math::Function2< ReturnT > const &  function,
std::vector< double > const &  initialParameterList,
std::vector< double > const &  stepSizeList,
std::vector< double > const &  measurementList,
std::vector< double > const &  varianceList,
std::vector< double > const &  xPositionList,
std::vector< double > const &  yPositionList,
double  errorDef 
)

Find the minimum of a function(x, y)

Uses the Minuit fitting package with a standard definition of chiSq. (see MinimizerFunctionBase2).

Parameters
functionfunction(x,y) to be minimized
initialParameterListinitial guess for parameters
stepSizeListstep size for each parameter; use 0.0 to fix a parameter
measurementListmeasured values
varianceListvariance for each measurement
xPositionListx position of each measurement
yPositionListy position of each measurement
errorDefwhat is this?
Returns
true if minimum is valid, false otherwise
Exceptions
lsst::pex::exceptions::InvalidParameterErrorif any input vector is the wrong length

To do:

  • Document stepSizeList better
  • Document errorDef
  • Compute stepSize automatically? (if so, find a different way to fix parameters)

Definition at line 229 of file minimize.cc.

232  {
233  unsigned int const nParameters = function.getNParameters();
234  if (initialParameterList.size() != nParameters) {
235  throw LSST_EXCEPT(pex::exceptions::InvalidParameterError, "initialParameterList is the wrong length");
236  }
237  if (stepSizeList.size() != nParameters) {
238  throw LSST_EXCEPT(pex::exceptions::InvalidParameterError, "stepSizeList is the wrong length");
239  }
240  unsigned int const nMeasurements = measurementList.size();
241  if (varianceList.size() != nMeasurements) {
242  throw LSST_EXCEPT(pex::exceptions::InvalidParameterError, "varianceList is the wrong length");
243  }
244  if (xPositionList.size() != nMeasurements) {
245  throw LSST_EXCEPT(pex::exceptions::InvalidParameterError, "xPositionList is the wrong length");
246  }
247  if (yPositionList.size() != nMeasurements) {
248  throw LSST_EXCEPT(pex::exceptions::InvalidParameterError, "yPositionList is the wrong length");
249  }
250 
251  MinimizerFunctionBase2<ReturnT> minimizerFunc(function, measurementList, varianceList, xPositionList,
252  yPositionList, errorDef);
253 
254  ROOT::Minuit2::MnUserParameters fitPar;
255  std::vector<std::string> paramNames;
256  for (unsigned int i = 0; i < nParameters; ++i) {
257  paramNames.push_back((boost::format("p%d") % i).str());
258  fitPar.Add(paramNames[i].c_str(), initialParameterList[i], stepSizeList[i]);
259  }
260 
261  ROOT::Minuit2::MnMigrad migrad(minimizerFunc, fitPar);
262  ROOT::Minuit2::FunctionMinimum min = migrad();
263  ROOT::Minuit2::MnMinos minos(minimizerFunc, min);
264 
265  FitResults fitResults;
266  fitResults.chiSq = min.Fval();
267  fitResults.isValid = min.IsValid() && std::isfinite(fitResults.chiSq);
268  if (!fitResults.isValid) {
269  LOGL_WARN("afw.math.minimize", "Fit failed to converge");
270  }
271 
272  for (unsigned int i = 0; i < nParameters; ++i) {
273  fitResults.parameterList.push_back(min.UserState().Value(paramNames[i].c_str()));
274  if (fitResults.isValid) {
275  fitResults.parameterErrorList.push_back(minos(i));
276  } else {
277  double e = min.UserState().Error(paramNames[i].c_str());
278  std::pair<double, double> ep(-1 * e, e);
279  fitResults.parameterErrorList.push_back(ep);
280  }
281  }
282  return fitResults;
283 }

◆ offsetImage()

template<typename ImageT >
std::shared_ptr< ImageT > lsst::afw::math::offsetImage ( ImageT const &  image,
float  dx,
float  dy,
std::string const &  algorithmName = "lanczos5",
unsigned int  buffer = 0 
)

Return an image offset by (dx, dy) using the specified algorithm.

Parameters
imageThe image to offset
dxmove the image this far in the column direction
dymove the image this far in the row direction
algorithmNameType of resampling Kernel to use
bufferWidth of buffer (border) around kernel image to allow for warping edge effects (pixels). Values < 0 are treated as 0. This is only used during computation; the final image has the same dimensions as the kernel.
Note
The image pixels are always offset by a fraction of a pixel and the image origin (XY0) picks is modified to handle the integer portion of the offset. In the special case that the offset in both x and y lies in the range (-1, 1) the origin is not changed. Otherwise the pixels are shifted by (-0.5, 0.5] pixels and the origin shifted accordingly.
Exceptions
lsst::pex::exceptions::InvalidParameterErrorif the algorithm is invalid

Definition at line 41 of file offsetImage.cc.

44  {
45  std::shared_ptr<SeparableKernel> offsetKernel = makeWarpingKernel(algorithmName);
46 
47  std::shared_ptr<ImageT> buffImage;
48  if (buffer > 0) {
49  // Paste input image into buffered image
50  lsst::geom::Extent2I const& dims = inImage.getDimensions();
51  std::shared_ptr<ImageT> buffered(new ImageT(dims.getX() + 2 * buffer, dims.getY() + 2 * buffer));
52  buffImage = buffered;
53  lsst::geom::Box2I box(lsst::geom::Point2I(buffer, buffer), dims);
54  buffImage->assign(inImage, box);
55  } else {
56  buffImage = std::make_shared<ImageT>(inImage);
57  }
58 
59  if (offsetKernel->getWidth() > buffImage->getWidth() ||
60  offsetKernel->getHeight() > buffImage->getHeight()) {
62  (boost::format("Image of size %dx%d is too small to offset using a %s kernel"
63  "(minimum %dx%d)") %
64  buffImage->getWidth() % buffImage->getHeight() % algorithmName %
65  offsetKernel->getWidth() % offsetKernel->getHeight())
66  .str());
67  }
68 
69  // std::shared_ptr<ImageT> convImage(new ImageT(buffImage, true)); // output image, a deep copy
70  std::shared_ptr<ImageT> convImage(new ImageT(buffImage->getDimensions())); // Convolved image
71 
72  int dOrigX, dOrigY;
73  double fracX, fracY;
74  // If the offset in both axes is in (-1, 1) use it as is, and don't shift the origin
75  if (dx > -1 && dx < 1 && dy > -1 && dy < 1) {
76  dOrigX = 0;
77  dOrigY = 0;
78  fracX = dx;
79  fracY = dy;
80  } else {
81  dOrigX = static_cast<int>(std::floor(dx + 0.5));
82  dOrigY = static_cast<int>(std::floor(dy + 0.5));
83  fracX = dx - dOrigX;
84  fracY = dy - dOrigY;
85  }
86 
87  // We seem to have to pass -fracX, -fracY to setKernelParameters, for reasons RHL doesn't understand
88  double dKerX = -fracX;
89  double dKerY = -fracY;
90 
91  //
92  // If the shift is -ve, the generated shift kernel (e.g. Lanczos5) is quite asymmetric, with the
93  // largest coefficients to the left of centre. We therefore move the centre of calculated shift kernel
94  // one to the right to center up the largest coefficients
95  //
96  if (dKerX < 0) {
97  offsetKernel->setCtr(offsetKernel->getCtr() + lsst::geom::Extent2I(1, 0));
98  }
99  if (dKerY < 0) {
100  offsetKernel->setCtr(offsetKernel->getCtr() + lsst::geom::Extent2I(0, 1));
101  }
102 
103  offsetKernel->setKernelParameters(std::make_pair(dKerX, dKerY));
104 
105  ConvolutionControl convolutionControl;
106  convolutionControl.setDoNormalize(true);
107  convolutionControl.setDoCopyEdge(true);
108  convolve(*convImage, *buffImage, *offsetKernel, convolutionControl);
109 
110  std::shared_ptr<ImageT> outImage;
111  if (buffer > 0) {
112  lsst::geom::Box2I box(lsst::geom::Point2I(buffer, buffer), inImage.getDimensions());
113  std::shared_ptr<ImageT> out(new ImageT(*convImage, box, afwImage::LOCAL, true));
114  outImage = out;
115  } else {
116  outImage = convImage;
117  }
118 
119  // adjust the origin; do this after convolution since convolution also sets XY0
120  outImage->setXY0(lsst::geom::Point2I(inImage.getX0() + dOrigX, inImage.getY0() + dOrigY));
121 
122  return outImage;
123 }

◆ operator*()

std::shared_ptr< BoundedField > lsst::afw::math::operator* ( double const  scale,
std::shared_ptr< BoundedField const >  bf 
)

Definition at line 254 of file BoundedField.cc.

254  {
255  return *bf * scale;
256 }

◆ printKernel()

void lsst::afw::math::printKernel ( lsst::afw::math::Kernel const &  kernel,
bool  doNormalize,
double  x = 0,
double  y = 0,
std::string  pixelFmt = "%7.3f" 
)

Print the pixel values of a Kernel to std::cout.

Rows increase upward and columns to the right; thus the lower left pixel is (0,0).

Parameters
kernelthe kernel
doNormalizeif true, normalize kernel
xx at which to evaluate kernel
yy at which to evaluate kernel
pixelFmtformat for pixel values

Definition at line 38 of file KernelFunctions.cc.

38  {
39  typedef Kernel::Pixel Pixel;
40 
41  image::Image<Pixel> kImage(kernel.getDimensions());
42  double kSum = kernel.computeImage(kImage, doNormalize, xPos, yPos);
43 
44  for (int y = kImage.getHeight() - 1; y >= 0; --y) {
45  for (image::Image<Pixel>::const_x_iterator ptr = kImage.row_begin(y); ptr != kImage.row_end(y);
46  ++ptr) {
47  std::cout << boost::format(pixelFmt) % *ptr << " ";
48  }
50  }
51 
52  if (doNormalize && std::abs(static_cast<double>(kSum) - 1.0) > 1.0e-5) {
53  std::cout << boost::format("Warning! Sum of all pixels = %9.5f != 1.0\n") % kSum;
54  }
56 }

◆ PYBIND11_MODULE() [1/9]

lsst::afw::math::PYBIND11_MODULE ( approximate  ,
mod   
)

Definition at line 56 of file approximate.cc.

56  {
57  py::class_<ApproximateControl, std::shared_ptr<ApproximateControl>> clsApproximateControl(
58  mod, "ApproximateControl");
59 
60  py::enum_<ApproximateControl::Style>(clsApproximateControl, "Style")
61  .value("UNKNOWN", ApproximateControl::Style::UNKNOWN)
62  .value("CHEBYSHEV", ApproximateControl::Style::CHEBYSHEV)
63  .value("NUM_STYLES", ApproximateControl::Style::NUM_STYLES)
64  .export_values();
65 
66  clsApproximateControl.def(py::init<ApproximateControl::Style, int, int, bool>(), "style"_a, "orderX"_a,
67  "orderY"_a = -1, "weighting"_a = true);
68 
69  clsApproximateControl.def("getStyle", &ApproximateControl::getStyle);
70  clsApproximateControl.def("setStyle", &ApproximateControl::setStyle);
71  clsApproximateControl.def("getOrderX", &ApproximateControl::getOrderX);
72  clsApproximateControl.def("setOrderX", &ApproximateControl::setOrderX);
73  clsApproximateControl.def("getOrderY", &ApproximateControl::getOrderY);
74  clsApproximateControl.def("setOrderY", &ApproximateControl::setOrderY);
75  clsApproximateControl.def("getWeighting", &ApproximateControl::getWeighting);
76  clsApproximateControl.def("setWeighting", &ApproximateControl::setWeighting);
77 
78  // Yes, really only float
79  declareApproximate<float>(mod, "F");
80 }

◆ PYBIND11_MODULE() [2/9]

lsst::afw::math::PYBIND11_MODULE ( background  ,
mod   
)

Definition at line 73 of file background.cc.

73  {
74  py::module::import("lsst.afw.image.image");
75 
76  /* Member types and enums */
77  py::enum_<UndersampleStyle>(mod, "UndersampleStyle")
78  .value("THROW_EXCEPTION", UndersampleStyle::THROW_EXCEPTION)
79  .value("REDUCE_INTERP_ORDER", UndersampleStyle::REDUCE_INTERP_ORDER)
80  .value("INCREASE_NXNYSAMPLE", UndersampleStyle::INCREASE_NXNYSAMPLE)
81  .export_values();
82 
83  py::class_<BackgroundControl, std::shared_ptr<BackgroundControl>> clsBackgroundControl(
84  mod, "BackgroundControl");
85 
86  /* Constructors */
87  clsBackgroundControl.def(py::init<int const, int const, StatisticsControl const, Property const,
88  ApproximateControl const>(),
89  "nxSample"_a, "nySample"_a, "sctrl"_a = StatisticsControl(), "prop"_a = MEANCLIP,
90  "actrl"_a = ApproximateControl(ApproximateControl::UNKNOWN, 1));
91  clsBackgroundControl.def(py::init<int const, int const, StatisticsControl const, std::string const &,
92  ApproximateControl const>(),
93  "nxSample"_a, "nySample"_a, "sctrl"_a, "prop"_a,
94  "actrl"_a = ApproximateControl(ApproximateControl::UNKNOWN, 1));
95  clsBackgroundControl.def(py::init<Interpolate::Style const, int const, int const, UndersampleStyle const,
96  StatisticsControl const, Property const, ApproximateControl const>(),
97  "style"_a, "nxSample"_a = 10, "nySample"_a = 10,
98  "undersampleStyle"_a = THROW_EXCEPTION, "sctrl"_a = StatisticsControl(),
99  "prop"_a = MEANCLIP,
100  "actrl"_a = ApproximateControl(ApproximateControl::UNKNOWN, 1));
101  clsBackgroundControl.def(
102  py::init<std::string const &, int const, int const, std::string const &, StatisticsControl const,
103  std::string const &, ApproximateControl const>(),
104  "style"_a, "nxSample"_a = 10, "nySample"_a = 10, "undersampleStyle"_a = "THROW_EXCEPTION",
105  "sctrl"_a = StatisticsControl(), "prop"_a = "MEANCLIP",
106  "actrl"_a = ApproximateControl(ApproximateControl::UNKNOWN, 1));
107 
108  /* Members */
109  clsBackgroundControl.def("setNxSample", &BackgroundControl::setNxSample);
110  clsBackgroundControl.def("setNySample", &BackgroundControl::setNySample);
111  clsBackgroundControl.def("setInterpStyle", (void (BackgroundControl::*)(Interpolate::Style const)) &
112  BackgroundControl::setInterpStyle);
113  clsBackgroundControl.def("setInterpStyle", (void (BackgroundControl::*)(std::string const &)) &
114  BackgroundControl::setInterpStyle);
115  clsBackgroundControl.def("setUndersampleStyle", (void (BackgroundControl::*)(UndersampleStyle const)) &
116  BackgroundControl::setUndersampleStyle);
117  clsBackgroundControl.def("setUndersampleStyle", (void (BackgroundControl::*)(std::string const &)) &
118  BackgroundControl::setUndersampleStyle);
119  clsBackgroundControl.def("getNxSample", &BackgroundControl::getNxSample);
120  clsBackgroundControl.def("getNySample", &BackgroundControl::getNySample);
121  clsBackgroundControl.def("getInterpStyle", &BackgroundControl::getInterpStyle);
122  clsBackgroundControl.def("getUndersampleStyle", &BackgroundControl::getUndersampleStyle);
123  clsBackgroundControl.def("getStatisticsControl",
124  (std::shared_ptr<StatisticsControl> (BackgroundControl::*)()) &
125  BackgroundControl::getStatisticsControl);
126  clsBackgroundControl.def("getStatisticsProperty", &BackgroundControl::getStatisticsProperty);
127  clsBackgroundControl.def("setStatisticsProperty", (void (BackgroundControl::*)(Property)) &
128  BackgroundControl::setStatisticsProperty);
129  clsBackgroundControl.def("setStatisticsProperty", (void (BackgroundControl::*)(std::string)) &
130  BackgroundControl::setStatisticsProperty);
131  clsBackgroundControl.def("setApproximateControl", &BackgroundControl::setApproximateControl);
132  clsBackgroundControl.def("getApproximateControl",
133  (std::shared_ptr<ApproximateControl> (BackgroundControl::*)()) &
134  BackgroundControl::getApproximateControl);
135 
136  /* Note that, in this case, the holder type must be unique_ptr to enable usage
137  * of py::nodelete, which in turn is needed because Background has a protected
138  * destructor. Adding py::nodelete prevents pybind11 from calling the destructor
139  * when the pointer is destroyed. Thus care needs to be taken to prevent leaks.
140  * Basically Background should only ever be used as a base class (without data
141  * members). */
142  py::class_<Background, std::unique_ptr<Background, py::nodelete>> clsBackground(mod, "Background");
143 
144  /* Members */
145  declareGetImage<float>(clsBackground, "F");
146 
147  clsBackground.def("getAsUsedInterpStyle", &Background::getAsUsedInterpStyle);
148  clsBackground.def("getAsUsedUndersampleStyle", &Background::getAsUsedUndersampleStyle);
149  clsBackground.def("getApproximate", &Background::getApproximate, "actrl"_a,
150  "undersampleStyle"_a = THROW_EXCEPTION);
151  clsBackground.def("getBackgroundControl", (std::shared_ptr<BackgroundControl> (Background::*)()) &
152  Background::getBackgroundControl);
153 
154  py::class_<BackgroundMI, std::shared_ptr<BackgroundMI>, Background> clsBackgroundMI(mod, "BackgroundMI");
155 
156  /* Constructors */
157  clsBackgroundMI.def(
159  "imageDimensions"_a, "statsImage"_a);
160 
161  /* Operators */
162  clsBackgroundMI.def("__iadd__", &BackgroundMI::operator+=);
163  clsBackgroundMI.def("__isub__", &BackgroundMI::operator-=);
164 
165  /* Members */
166  clsBackgroundMI.def("getStatsImage", &BackgroundMI::getStatsImage);
167  clsBackgroundMI.def("getImageBBox", &BackgroundMI::getImageBBox);
168 
169  // Yes, really only float
170  declareMakeBackground<image::Image<float>>(mod);
171  declareMakeBackground<image::MaskedImage<float>>(mod);
172 
173  mod.def("stringToUndersampleStyle", stringToUndersampleStyle, "style"_a);
174 }

◆ PYBIND11_MODULE() [3/9]

lsst::afw::math::PYBIND11_MODULE ( convolveImage  ,
mod   
)

Definition at line 74 of file convolveImage.cc.

74  {
75  py::class_<ConvolutionControl, std::shared_ptr<ConvolutionControl>> clsConvolutionControl(
76  mod, "ConvolutionControl");
77 
78  clsConvolutionControl.def(py::init<bool, bool, int>(), "doNormalize"_a = true, "doCopyEdge"_a = false,
79  "maxInterpolationDistance"_a = 10);
80 
81  clsConvolutionControl.def("getDoNormalize", &ConvolutionControl::getDoNormalize);
82  clsConvolutionControl.def("getDoCopyEdge", &ConvolutionControl::getDoCopyEdge);
83  clsConvolutionControl.def("getMaxInterpolationDistance",
84  &ConvolutionControl::getMaxInterpolationDistance);
85  clsConvolutionControl.def("setDoNormalize", &ConvolutionControl::setDoNormalize);
86  clsConvolutionControl.def("setDoCopyEdge", &ConvolutionControl::setDoCopyEdge);
87  clsConvolutionControl.def("setMaxInterpolationDistance",
88  &ConvolutionControl::setMaxInterpolationDistance);
89 
90  declareAll<double, double>(mod);
91  declareAll<double, float>(mod);
92  declareAll<double, int>(mod);
93  declareAll<double, std::uint16_t>(mod);
94  declareAll<float, float>(mod);
95  declareAll<float, int>(mod);
96  declareAll<float, std::uint16_t>(mod);
97  declareAll<int, int>(mod);
98  declareAll<std::uint16_t, std::uint16_t>(mod);
99 }

◆ PYBIND11_MODULE() [4/9]

lsst::afw::math::PYBIND11_MODULE ( function  ,
mod   
)

Definition at line 143 of file function.cc.

143  {
144  declareAllFunctions<float>(mod, "F");
145  declareAllFunctions<double>(mod, "D");
146 }

◆ PYBIND11_MODULE() [5/9]

lsst::afw::math::PYBIND11_MODULE ( functionLibrary  ,
mod   
)

Definition at line 200 of file functionLibrary.cc.

200  {
201  py::module::import("lsst.geom");
202  py::module::import("lsst.afw.math.function");
203 
204  declarePolynomialFunctions<float>(mod, "F");
205  declareChebyshevFunctions<float>(mod, "F");
206  declareGaussianFunctions<float>(mod, "F");
207  declareIntegerDeltaFunctions<float>(mod, "F");
208  declareLanczosFunctions<float>(mod, "F");
209 
210  declarePolynomialFunctions<double>(mod, "D");
211  declareChebyshevFunctions<double>(mod, "D");
212  declareGaussianFunctions<double>(mod, "D");
213  declareIntegerDeltaFunctions<double>(mod, "D");
214  declareLanczosFunctions<double>(mod, "D");
215 }

◆ PYBIND11_MODULE() [6/9]

lsst::afw::math::PYBIND11_MODULE ( offsetImage  ,
mod   
)

Definition at line 66 of file offsetImage.cc.

66  {
68 
69  /* Module level */
70  declareOffsetImage<lsst::afw::image::Image<int>>(mod);
71  declareOffsetImage<lsst::afw::image::Image<float>>(mod);
72  declareOffsetImage<lsst::afw::image::Image<double>>(mod);
73  declareOffsetImage<lsst::afw::image::MaskedImage<int>>(mod);
74  declareOffsetImage<lsst::afw::image::MaskedImage<float>>(mod);
75  declareOffsetImage<lsst::afw::image::MaskedImage<double>>(mod);
76 
77  declareRotateImageBy90<lsst::afw::image::Image<std::uint16_t>>(mod);
78  declareRotateImageBy90<lsst::afw::image::Image<int>>(mod);
79  declareRotateImageBy90<lsst::afw::image::Image<float>>(mod);
80  declareRotateImageBy90<lsst::afw::image::Image<double>>(mod);
81  declareRotateImageBy90<lsst::afw::image::MaskedImage<std::uint16_t>>(mod);
82  declareRotateImageBy90<lsst::afw::image::MaskedImage<int>>(mod);
83  declareRotateImageBy90<lsst::afw::image::MaskedImage<float>>(mod);
84  declareRotateImageBy90<lsst::afw::image::MaskedImage<double>>(mod);
85  declareRotateImageBy90<lsst::afw::image::Mask<MaskPixel>>(mod);
86 
87  declareFlipImage<lsst::afw::image::Image<std::uint16_t>>(mod);
88  declareFlipImage<lsst::afw::image::Image<int>>(mod);
89  declareFlipImage<lsst::afw::image::Image<float>>(mod);
90  declareFlipImage<lsst::afw::image::Image<double>>(mod);
91  declareFlipImage<lsst::afw::image::MaskedImage<std::uint16_t>>(mod);
92  declareFlipImage<lsst::afw::image::MaskedImage<int>>(mod);
93  declareFlipImage<lsst::afw::image::MaskedImage<float>>(mod);
94  declareFlipImage<lsst::afw::image::MaskedImage<double>>(mod);
95  declareFlipImage<lsst::afw::image::Mask<MaskPixel>>(mod);
96 
97  declareBinImage<lsst::afw::image::Image<std::uint16_t>>(mod);
98  declareBinImage<lsst::afw::image::Image<int>>(mod);
99  declareBinImage<lsst::afw::image::Image<float>>(mod);
100  declareBinImage<lsst::afw::image::Image<double>>(mod);
101  declareBinImage<lsst::afw::image::MaskedImage<std::uint16_t>>(mod);
102  declareBinImage<lsst::afw::image::MaskedImage<int>>(mod);
103  declareBinImage<lsst::afw::image::MaskedImage<float>>(mod);
104  declareBinImage<lsst::afw::image::MaskedImage<double>>(mod);
105 }

◆ PYBIND11_MODULE() [7/9]

lsst::afw::math::PYBIND11_MODULE ( spatialCell  ,
mod   
)

Definition at line 239 of file spatialCell.cc.

239  {
240  wrapSpatialCellCandidate(mod);
241  wrapSpatialCellCandidateIterator(mod);
242  wrapSpatialCell(mod);
243  wrapSpatialCellSet(mod);
244  wrapCandidateVisitor(mod);
245  wrapSpatialCellImageCandidate(mod);
246 
247  /* Test Members */
248  wrapTestClasses(mod);
249 }

◆ PYBIND11_MODULE() [8/9]

lsst::afw::math::PYBIND11_MODULE ( statistics  ,
mod   
)

Definition at line 68 of file statistics.cc.

68  {
69  /* Module level */
70  py::enum_<Property>(mod, "Property", py::arithmetic())
71  .value("NOTHING", Property::NOTHING)
72  .value("ERRORS", Property::ERRORS)
73  .value("NPOINT", Property::NPOINT)
74  .value("MEAN", Property::MEAN)
75  .value("STDEV", Property::STDEV)
76  .value("VARIANCE", Property::VARIANCE)
77  .value("MEDIAN", Property::MEDIAN)
78  .value("IQRANGE", Property::IQRANGE)
79  .value("MEANCLIP", Property::MEANCLIP)
80  .value("STDEVCLIP", Property::STDEVCLIP)
81  .value("VARIANCECLIP", Property::VARIANCECLIP)
82  .value("MIN", Property::MIN)
83  .value("MAX", Property::MAX)
84  .value("SUM", Property::SUM)
85  .value("MEANSQUARE", Property::MEANSQUARE)
86  .value("ORMASK", Property::ORMASK)
87  .value("NCLIPPED", Property::NCLIPPED)
88  .value("NMASKED", Property::NMASKED)
89  .export_values();
90 
91  mod.def("stringToStatisticsProperty", stringToStatisticsProperty);
92 
93  py::class_<StatisticsControl, std::shared_ptr<StatisticsControl>> clsStatisticsControl(
94  mod, "StatisticsControl");
95 
96  py::enum_<StatisticsControl::WeightsBoolean>(clsStatisticsControl, "WeightsBoolean")
97  .value("WEIGHTS_FALSE", StatisticsControl::WeightsBoolean::WEIGHTS_FALSE)
98  .value("WEIGHTS_TRUE", StatisticsControl::WeightsBoolean::WEIGHTS_TRUE)
99  .value("WEIGHTS_NONE", StatisticsControl::WeightsBoolean::WEIGHTS_NONE)
100  .export_values();
101 
102  clsStatisticsControl.def(py::init<double, int, lsst::afw::image::MaskPixel, bool,
103  typename StatisticsControl::WeightsBoolean>(),
104  "numSigmaClip"_a = 3.0, "numIter"_a = 3, "andMask"_a = 0x0, "isNanSafe"_a = true,
105  "useWeights"_a = StatisticsControl::WEIGHTS_NONE);
106 
107  clsStatisticsControl.def("getMaskPropagationThreshold", &StatisticsControl::getMaskPropagationThreshold);
108  clsStatisticsControl.def("setMaskPropagationThreshold", &StatisticsControl::setMaskPropagationThreshold);
109  clsStatisticsControl.def("getNumSigmaClip", &StatisticsControl::getNumSigmaClip);
110  clsStatisticsControl.def("getNumIter", &StatisticsControl::getNumIter);
111  clsStatisticsControl.def("getAndMask", &StatisticsControl::getAndMask);
112  clsStatisticsControl.def("getNoGoodPixelsMask", &StatisticsControl::getNoGoodPixelsMask);
113  clsStatisticsControl.def("getNanSafe", &StatisticsControl::getNanSafe);
114  clsStatisticsControl.def("getWeighted", &StatisticsControl::getWeighted);
115  clsStatisticsControl.def("getWeightedIsSet", &StatisticsControl::getWeightedIsSet);
116  clsStatisticsControl.def("getCalcErrorFromInputVariance",
117  &StatisticsControl::getCalcErrorFromInputVariance);
118  clsStatisticsControl.def("setNumSigmaClip", &StatisticsControl::setNumSigmaClip);
119  clsStatisticsControl.def("setNumIter", &StatisticsControl::setNumIter);
120  clsStatisticsControl.def("setAndMask", &StatisticsControl::setAndMask);
121  clsStatisticsControl.def("setNoGoodPixelsMask", &StatisticsControl::setNoGoodPixelsMask);
122  clsStatisticsControl.def("setNanSafe", &StatisticsControl::setNanSafe);
123  clsStatisticsControl.def("setWeighted", &StatisticsControl::setWeighted);
124  clsStatisticsControl.def("setCalcErrorFromInputVariance",
125  &StatisticsControl::setCalcErrorFromInputVariance);
126 
127  py::class_<Statistics> clsStatistics(mod, "Statistics");
128 
129  clsStatistics.def("getResult", &Statistics::getResult, "prop"_a = Property::NOTHING);
130  clsStatistics.def("getError", &Statistics::getError, "prop"_a = Property::NOTHING);
131  clsStatistics.def("getValue", &Statistics::getValue, "prop"_a = Property::NOTHING);
132  clsStatistics.def("getOrMask", &Statistics::getOrMask);
133 
134  declareStatistics<unsigned short>(mod);
135  declareStatistics<double>(mod);
136  declareStatistics<float>(mod);
137  declareStatistics<int>(mod);
138 
139  // Declare vector overloads separately to prevent casting errors
140  // that otherwise (mysteriously) occur when overloads are tried
141  // in order.
142  declareStatisticsVectorOverloads<unsigned short>(mod);
143  declareStatisticsVectorOverloads<double>(mod);
144  declareStatisticsVectorOverloads<float>(mod);
145  declareStatisticsVectorOverloads<int>(mod);
146 }

◆ PYBIND11_MODULE() [9/9]

lsst::afw::math::PYBIND11_MODULE ( warpExposure  ,
mod   
)

Definition at line 133 of file warpExposure.cc.

133  {
134  /* Module level */
135  auto clsLanczosWarpingKernel = declareWarpingKernel<LanczosWarpingKernel>(mod, "LanczosWarpingKernel");
136  declareSimpleWarpingKernel<BilinearWarpingKernel>(mod, "BilinearWarpingKernel");
137  declareSimpleWarpingKernel<NearestWarpingKernel>(mod, "NearestWarpingKernel");
138 
139  py::class_<WarpingControl, std::shared_ptr<WarpingControl>> clsWarpingControl(mod, "WarpingControl");
140 
141  declareWarpingFunctions<double, double>(mod);
142  declareWarpingFunctions<double, float>(mod);
143  declareWarpingFunctions<double, int>(mod);
144  declareWarpingFunctions<double, std::uint16_t>(mod);
145  declareWarpingFunctions<float, float>(mod);
146  declareWarpingFunctions<float, int>(mod);
147  declareWarpingFunctions<float, std::uint16_t>(mod);
148  declareWarpingFunctions<int, int>(mod);
149  declareWarpingFunctions<std::uint16_t, std::uint16_t>(mod);
150 
151  /* Member types and enums */
152 
153  /* Constructors */
154  clsLanczosWarpingKernel.def(py::init<int>(), "order"_a);
155 
156  clsWarpingControl.def(py::init<std::string, std::string, int, int, image::MaskPixel>(),
157  "warpingKernelName"_a, "maskWarpingKernelName"_a = "", "cacheSize"_a = 0,
158  "interpLength"_a = 0, "growFullMask"_a = 0);
159 
160  /* Operators */
161  clsLanczosWarpingKernel.def("getOrder", &LanczosWarpingKernel::getOrder);
162 
163  clsWarpingControl.def("getCacheSize", &WarpingControl::getCacheSize);
164  clsWarpingControl.def("setCacheSize", &WarpingControl::setCacheSize, "cacheSize"_a);
165  clsWarpingControl.def("getInterpLength", &WarpingControl::getInterpLength);
166  clsWarpingControl.def("setInterpLength", &WarpingControl::setInterpLength, "interpLength"_a);
167  clsWarpingControl.def("setWarpingKernelName", &WarpingControl::setWarpingKernelName,
168  "warpingKernelName"_a);
169  clsWarpingControl.def("getWarpingKernel", &WarpingControl::getWarpingKernel);
170  clsWarpingControl.def("setWarpingKernel", &WarpingControl::setWarpingKernel, "warpingKernel"_a);
171  clsWarpingControl.def("setMaskWarpingKernelName", &WarpingControl::setMaskWarpingKernelName,
172  "maskWarpingKernelName"_a);
173  clsWarpingControl.def("getMaskWarpingKernel", &WarpingControl::getMaskWarpingKernel);
174  clsWarpingControl.def("hasMaskWarpingKernel", &WarpingControl::hasMaskWarpingKernel);
175  clsWarpingControl.def("setMaskWarpingKernelName", &WarpingControl::setMaskWarpingKernelName,
176  "maskWarpingKernelName"_a);
177  clsWarpingControl.def("setMaskWarpingKernel", &WarpingControl::setMaskWarpingKernel,
178  "maskWarpingKernel"_a);
179  clsWarpingControl.def("getGrowFullMask", &WarpingControl::getGrowFullMask);
180  clsWarpingControl.def("setGrowFullMask", &WarpingControl::setGrowFullMask, "growFullMask"_a);
181 
182  /* Members */
183 }

◆ randomChisqImage()

template<typename ImageT >
void lsst::afw::math::randomChisqImage ( ImageT *  image,
Random rand,
double const  nu 
)

Set image to random numbers with a chi^2_{nu} distribution.

Parameters
[out]imageThe image to set
[in,out]randdefinition of random number algorithm, seed, etc.
[in]nunumber of degrees of freedom

Definition at line 135 of file RandomImage.cc.

135  {
136  lsst::afw::image::for_each_pixel(*image, do_chisq<typename ImageT::Pixel>(rand, nu));
137 }

◆ randomFlatImage()

template<typename ImageT >
void lsst::afw::math::randomFlatImage ( ImageT *  image,
Random rand,
double const  a,
double const  b 
)

Set image to random numbers uniformly distributed in the range [a, b)

Parameters
[out]imageThe image to set
[in,out]randdefinition of random number algorithm, seed, etc.
[in]a(inclusive) lower limit for random variates
[in]b(exclusive) upper limit for random variates

Definition at line 125 of file RandomImage.cc.

125  {
126  lsst::afw::image::for_each_pixel(*image, do_flat<typename ImageT::Pixel>(rand, a, b));
127 }

◆ randomGaussianImage()

template<typename ImageT >
void lsst::afw::math::randomGaussianImage ( ImageT *  image,
Random rand 
)

Set image to random numbers with a gaussian N(0, 1) distribution.

Parameters
[out]imageThe image to set
[in,out]randdefinition of random number algorithm, seed, etc.

Definition at line 130 of file RandomImage.cc.

130  {
131  lsst::afw::image::for_each_pixel(*image, do_gaussian<typename ImageT::Pixel>(rand));
132 }

◆ randomPoissonImage()

template<typename ImageT >
void lsst::afw::math::randomPoissonImage ( ImageT *  image,
Random rand,
double const  mu 
)

Set image to random numbers with a Poisson distribution with mean mu (n.b.

not per-pixel)

Parameters
[out]imageThe image to set
[in,out]randdefinition of random number algorithm, seed, etc.
[in]mumean of distribution

Definition at line 140 of file RandomImage.cc.

140  {
141  lsst::afw::image::for_each_pixel(*image, do_poisson<typename ImageT::Pixel>(rand, mu));
142 }

◆ randomUniformImage()

template<typename ImageT >
void lsst::afw::math::randomUniformImage ( ImageT *  image,
Random rand 
)

Set image to random numbers uniformly distributed in the range [0, 1)

Parameters
[out]imageThe image to set
[in,out]randdefinition of random number algorithm, seed, etc.

Definition at line 110 of file RandomImage.cc.

110  {
111  lsst::afw::image::for_each_pixel(*image, do_uniform<typename ImageT::Pixel>(rand));
112 }

◆ randomUniformIntImage()

template<typename ImageT >
void lsst::afw::math::randomUniformIntImage ( ImageT *  image,
Random rand,
unsigned long  n 
)

Set image to random integers uniformly distributed in the range 0 ...

n - 1

Parameters
[out]imageThe image to set
[in,out]randdefinition of random number algorithm, seed, etc.
[in]n(exclusive) upper limit for random variates

Definition at line 120 of file RandomImage.cc.

120  {
121  lsst::afw::image::for_each_pixel(*image, do_uniformInt<typename ImageT::Pixel>(rand, n));
122 }

◆ randomUniformPosImage()

template<typename ImageT >
void lsst::afw::math::randomUniformPosImage ( ImageT *  image,
Random rand 
)

Set image to random numbers uniformly distributed in the range (0, 1)

Parameters
[out]imageThe image to set
[in,out]randdefinition of random number algorithm, seed, etc.

Definition at line 115 of file RandomImage.cc.

115  {
116  lsst::afw::image::for_each_pixel(*image, do_uniformPos<typename ImageT::Pixel>(rand));
117 }

◆ rotateImageBy90()

template<typename ImageT >
std::shared_ptr< ImageT > lsst::afw::math::rotateImageBy90 ( ImageT const &  image,
int  nQuarter 
)

Rotate an image by an integral number of quarter turns.

Parameters
imageThe image to rotate
nQuarterthe desired number of quarter turns

Definition at line 39 of file rotateImage.cc.

39  {
40  std::shared_ptr<ImageT> outImage; // output image
41 
42  while (nQuarter < 0) {
43  nQuarter += 4;
44  }
45 
46  switch (nQuarter % 4) {
47  case 0:
48  outImage.reset(new ImageT(inImage, true)); // a deep copy of inImage
49  break;
50  case 1:
51  outImage.reset(new ImageT(lsst::geom::Extent2I(inImage.getHeight(), inImage.getWidth())));
52 
53  for (int y = 0; y != inImage.getHeight(); ++y) {
54  typename ImageT::y_iterator optr = outImage->col_begin(inImage.getHeight() - y - 1);
55  for (typename ImageT::x_iterator iptr = inImage.row_begin(y), end = inImage.row_end(y);
56  iptr != end; ++iptr, ++optr) {
57  *optr = *iptr;
58  }
59  }
60 
61  break;
62  case 2:
63  outImage.reset(new ImageT(inImage.getDimensions()));
64 
65  for (int y = 0; y != inImage.getHeight(); ++y) {
66  typename ImageT::x_iterator optr =
67  outImage->x_at(inImage.getWidth() - 1, inImage.getHeight() - y - 1);
68  for (typename ImageT::x_iterator iptr = inImage.row_begin(y), end = inImage.row_end(y);
69  iptr != end; ++iptr, optr -= 1) {
70  *optr = *iptr;
71  }
72  }
73  break;
74  case 3:
75  outImage.reset(new ImageT(lsst::geom::Extent2I(inImage.getHeight(), inImage.getWidth())));
76 
77  for (int y = 0; y != inImage.getHeight(); ++y) {
78  typename ImageT::y_iterator optr = outImage->y_at(y, inImage.getWidth() - 1);
79  for (typename ImageT::x_iterator iptr = inImage.row_begin(y), end = inImage.row_end(y);
80  iptr != end; ++iptr, optr -= 1) {
81  *optr = *iptr;
82  }
83  }
84 
85  break;
86  }
87 
88  return outImage;
89 }

◆ scaledPlus()

template<typename OutImageT , typename InImageT >
void lsst::afw::math::scaledPlus ( OutImageT &  outImage,
double  c1,
InImageT const &  inImage1,
double  c2,
InImageT const &  inImage2 
)

Compute the scaled sum of two images.

outImage = c1 inImage1 + c2 inImage2

For example to linearly interpolate between two images set: c1 = 1.0 - fracDist c2 = fracDist where fracDist is the fractional distance of outImage from inImage1: location of outImage - location of inImage1 fracDist = ----------------------------------------— location of inImage2 - location of inImage1

Parameters
[out]outImageoutput image
[in]c1coefficient for image 1
[in]inImage1input image 1
[in]c2coefficient for image 2
[in]inImage2input image 2
Exceptions
lsst::pex::exceptions::InvalidParameterErrorif outImage is not same dimensions as inImage1 and inImage2.

Definition at line 162 of file ConvolveImage.cc.

163  {
164  if (outImage.getDimensions() != inImage1.getDimensions()) {
166  os << "outImage dimensions = ( " << outImage.getWidth() << ", " << outImage.getHeight() << ") != ("
167  << inImage1.getWidth() << ", " << inImage1.getHeight() << ") = inImage1 dimensions";
169  } else if (inImage1.getDimensions() != inImage2.getDimensions()) {
171  os << "inImage1 dimensions = ( " << inImage1.getWidth() << ", " << inImage1.getHeight() << ") != ("
172  << inImage2.getWidth() << ", " << inImage2.getHeight() << ") = inImage2 dimensions";
174  }
175 
176  typedef typename InImageT::const_x_iterator InConstXIter;
177  typedef typename OutImageT::x_iterator OutXIter;
178  for (int y = 0; y != inImage1.getHeight(); ++y) {
179  InConstXIter const end1 = inImage1.row_end(y);
180  InConstXIter inIter1 = inImage1.row_begin(y);
181  InConstXIter inIter2 = inImage2.row_begin(y);
182  OutXIter outIter = outImage.row_begin(y);
183  for (; inIter1 != end1; ++inIter1, ++inIter2, ++outIter) {
184  *outIter = (*inIter1 * c1) + (*inIter2 * c2);
185  }
186  }
187 }

◆ statisticsStack() [1/18]

template<typename PixelT >
void lsst::afw::math::statisticsStack ( image::Image< PixelT > &  out,
std::vector< std::shared_ptr< image::Image< PixelT >>> &  images,
Property  flags,
StatisticsControl const &  sctrl,
WeightVector const &  wvector 
)

Definition at line 360 of file Stack.cc.

361  {
362  checkObjectsAndWeights(images, wvector);
363  checkOnlyOneFlag(flags);
364  checkImageSizes(out, images);
365 
366  if (wvector.empty()) {
367  return computeImageStack<PixelT, false>(out, images, flags, sctrl);
368  } else {
369  return computeImageStack<PixelT, true>(out, images, flags, sctrl, wvector);
370  }
371 }

◆ statisticsStack() [2/18]

template<typename PixelT >
std::shared_ptr<image::MaskedImage<PixelT> > lsst::afw::math::statisticsStack ( image::Image< PixelT > const &  image,
Property  flags,
char  dimension,
StatisticsControl const &  sctrl 
)

A function to compute statistics on the rows or columns of an image.

Definition at line 445 of file Stack.cc.

446  {
447  int x0 = image.getX0();
448  int y0 = image.getY0();
449  typedef image::MaskedImage<PixelT> MImage;
451 
452  // do each row or column, one at a time
453  // - create a subimage with a bounding box, and get the stats and assign the value to the output image
454  if (dimension == 'x') {
455  imgOut = std::shared_ptr<MImage>(new MImage(lsst::geom::Extent2I(1, image.getHeight())));
456  int y = y0;
457  typename MImage::y_iterator oEnd = imgOut->col_end(0);
458  for (typename MImage::y_iterator oPtr = imgOut->col_begin(0); oPtr != oEnd; ++oPtr, ++y) {
461  image::Image<PixelT> subImage(image, bbox);
462  Statistics stat = makeStatistics(subImage, flags | ERRORS, sctrl);
463  *oPtr = typename image::MaskedImage<PixelT>::Pixel(stat.getValue(), 0x0,
464  stat.getError() * stat.getError());
465  }
466 
467  } else if (dimension == 'y') {
468  imgOut = std::shared_ptr<MImage>(new MImage(lsst::geom::Extent2I(image.getWidth(), 1)));
469  int x = x0;
470  typename MImage::x_iterator oEnd = imgOut->row_end(0);
471  for (typename MImage::x_iterator oPtr = imgOut->row_begin(0); oPtr != oEnd; ++oPtr, ++x) {
474  image::Image<PixelT> subImage(image, bbox);
475  Statistics stat = makeStatistics(subImage, flags | ERRORS, sctrl);
476  *oPtr = typename image::MaskedImage<PixelT>::Pixel(stat.getValue(), 0x0,
477  stat.getError() * stat.getError());
478  }
479  } else {
481  "Can only run statisticsStack in x or y for single image.");
482  }
483 
484  return imgOut;
485 }

◆ statisticsStack() [3/18]

template<typename PixelT >
void lsst::afw::math::statisticsStack ( image::MaskedImage< PixelT > &  out,
std::vector< std::shared_ptr< image::MaskedImage< PixelT >>> &  images,
Property  flags,
StatisticsControl const &  sctrl,
WeightVector const &  wvector,
image::MaskPixel  clipped,
image::MaskPixel  excuse 
)

Definition at line 251 of file Stack.cc.

254  {
255  checkObjectsAndWeights(images, wvector);
256  checkOnlyOneFlag(flags);
257  checkImageSizes(out, images);
258 
259  if (sctrl.getWeighted()) {
260  if (wvector.empty()) {
261  return computeMaskedImageStack<PixelT, true, true>(out, images, flags, sctrl, clipped,
262  excuse); // use variance
263  } else {
264  return computeMaskedImageStack<PixelT, true, false>(out, images, flags, sctrl, clipped, excuse,
265  wvector); // use wvector
266  }
267  } else {
268  if (!wvector.empty()) {
269  LOGL_WARN(_log,
270  "Weights passed on to statisticsStack are ignored as sctrl.getWeighted() is False."
271  "Set sctrl.setWeighted(True) for them to be used.");
272  }
273  return computeMaskedImageStack<PixelT, false, false>(out, images, flags, sctrl, clipped, excuse);
274  }
275 }

◆ statisticsStack() [4/18]

template<typename PixelT >
void lsst::afw::math::statisticsStack ( image::MaskedImage< PixelT > &  out,
std::vector< std::shared_ptr< image::MaskedImage< PixelT >>> &  images,
Property  flags,
StatisticsControl const &  sctrl,
WeightVector const &  wvector,
image::MaskPixel  clipped,
std::vector< std::pair< image::MaskPixel, image::MaskPixel >> const &  maskMap 
)

Definition at line 278 of file Stack.cc.

281  {
282  checkObjectsAndWeights(images, wvector);
283  checkOnlyOneFlag(flags);
284  checkImageSizes(out, images);
285 
286  if (sctrl.getWeighted()) {
287  if (wvector.empty()) {
288  return computeMaskedImageStack<PixelT, true, true>(out, images, flags, sctrl, clipped,
289  maskMap); // use variance
290  } else {
291  return computeMaskedImageStack<PixelT, true, false>(out, images, flags, sctrl, clipped, maskMap,
292  wvector); // use wvector
293  }
294  } else {
295  return computeMaskedImageStack<PixelT, false, false>(out, images, flags, sctrl, clipped, maskMap);
296  }
297 }

◆ statisticsStack() [5/18]

template<typename PixelT >
std::shared_ptr<image::MaskedImage<PixelT> > lsst::afw::math::statisticsStack ( image::MaskedImage< PixelT > const &  image,
Property  flags,
char  dimension,
StatisticsControl const &  sctrl 
)

A function to compute statistics on the rows or columns of an image.

Definition at line 488 of file Stack.cc.

490  {
491  int const x0 = image.getX0();
492  int const y0 = image.getY0();
493  typedef image::MaskedImage<PixelT> MImage;
495 
496  // do each row or column, one at a time
497  // - create a subimage with a bounding box, and get the stats and assign the value to the output image
498  if (dimension == 'x') {
499  imgOut = std::shared_ptr<MImage>(new MImage(lsst::geom::Extent2I(1, image.getHeight())));
500  int y = 0;
501  typename MImage::y_iterator oEnd = imgOut->col_end(0);
502  for (typename MImage::y_iterator oPtr = imgOut->col_begin(0); oPtr != oEnd; ++oPtr, ++y) {
506  Statistics stat = makeStatistics(subImage, flags | ERRORS, sctrl);
507  *oPtr = typename image::MaskedImage<PixelT>::Pixel(stat.getValue(), 0x0,
508  stat.getError() * stat.getError());
509  }
510 
511  } else if (dimension == 'y') {
512  imgOut = std::shared_ptr<MImage>(new MImage(lsst::geom::Extent2I(image.getWidth(), 1)));
513  int x = 0;
514  typename MImage::x_iterator oEnd = imgOut->row_end(0);
515  for (typename MImage::x_iterator oPtr = imgOut->row_begin(0); oPtr != oEnd; ++oPtr, ++x) {
519  Statistics stat = makeStatistics(subImage, flags | ERRORS, sctrl);
520  *oPtr = typename image::MaskedImage<PixelT>::Pixel(stat.getValue(), 0x0,
521  stat.getError() * stat.getError());
522  }
523  } else {
525  "Can only run statisticsStack in x or y for single image.");
526  }
527 
528  return imgOut;
529 }

◆ statisticsStack() [6/18]

template<typename PixelT >
void lsst::afw::math::statisticsStack ( lsst::afw::image::Image< PixelT > &  out,
std::vector< std::shared_ptr< lsst::afw::image::Image< PixelT >>> &  images,
Property  flags,
StatisticsControl const &  sctrl = StatisticsControl(),
std::vector< lsst::afw::image::VariancePixel > const &  wvector = std::vectorlsst::afw::image::VariancePixel >(0) 
)

@ brief compute statistical stack of Image.

Write to output image in-situ

Parameters
outOutput image
imagesImages to process
flagsstatistics requested
sctrlControl structure
wvectorvector containing weights

◆ statisticsStack() [7/18]

template<typename PixelT >
std::shared_ptr<lsst::afw::image::MaskedImage<PixelT> > lsst::afw::math::statisticsStack ( lsst::afw::image::Image< PixelT > const &  image,
Property  flags,
char  dimension,
StatisticsControl const &  sctrl = StatisticsControl() 
)

A function to compute statistics on the rows or columns of an image.

Definition at line 445 of file Stack.cc.

446  {
447  int x0 = image.getX0();
448  int y0 = image.getY0();
449  typedef image::MaskedImage<PixelT> MImage;
451 
452  // do each row or column, one at a time
453  // - create a subimage with a bounding box, and get the stats and assign the value to the output image
454  if (dimension == 'x') {
455  imgOut = std::shared_ptr<MImage>(new MImage(lsst::geom::Extent2I(1, image.getHeight())));
456  int y = y0;
457  typename MImage::y_iterator oEnd = imgOut->col_end(0);
458  for (typename MImage::y_iterator oPtr = imgOut->col_begin(0); oPtr != oEnd; ++oPtr, ++y) {
461  image::Image<PixelT> subImage(image, bbox);
462  Statistics stat = makeStatistics(subImage, flags | ERRORS, sctrl);
463  *oPtr = typename image::MaskedImage<PixelT>::Pixel(stat.getValue(), 0x0,
464  stat.getError() * stat.getError());
465  }
466 
467  } else if (dimension == 'y') {
468  imgOut = std::shared_ptr<MImage>(new MImage(lsst::geom::Extent2I(image.getWidth(), 1)));
469  int x = x0;
470  typename MImage::x_iterator oEnd = imgOut->row_end(0);
471  for (typename MImage::x_iterator oPtr = imgOut->row_begin(0); oPtr != oEnd; ++oPtr, ++x) {
474  image::Image<PixelT> subImage(image, bbox);
475  Statistics stat = makeStatistics(subImage, flags | ERRORS, sctrl);
476  *oPtr = typename image::MaskedImage<PixelT>::Pixel(stat.getValue(), 0x0,
477  stat.getError() * stat.getError());
478  }
479  } else {
481  "Can only run statisticsStack in x or y for single image.");
482  }
483 
484  return imgOut;
485 }

◆ statisticsStack() [8/18]

template<typename PixelT >
void lsst::afw::math::statisticsStack ( lsst::afw::image::MaskedImage< PixelT > &  out,
std::vector< std::shared_ptr< lsst::afw::image::MaskedImage< PixelT >>> &  images,
Property  flags,
StatisticsControl const &  sctrl,
std::vector< lsst::afw::image::VariancePixel > const &  wvector,
image::MaskPixel  clipped,
std::vector< std::pair< image::MaskPixel, image::MaskPixel >> const &  maskMap 
)

A function to compute some statistics of a stack of Masked Images.

Parameters
[out]outOutput MaskedImage.
[in]imagesMaskedImages to process.
[in]flagsStatistics requested.
[in]sctrlControl structure.
[in]wvectorVector of weights.
[in]clippedMask to set for pixels that were clipped (NOT rejected due to masks).
[in]maskMapVector of pairs of mask pixel values; any pixel on an input with any of the bits in .first will result in all of the bits in .second being set on the corresponding pixel on the output.

If none of the input images are valid for some pixel, the afwMath::StatisticsControl::getNoGoodPixelsMask() bit(s) are set.

All the work is done in the function computeMaskedImageStack.

◆ statisticsStack() [9/18]

template<typename PixelT >
void lsst::afw::math::statisticsStack ( lsst::afw::image::MaskedImage< PixelT > &  out,
std::vector< std::shared_ptr< lsst::afw::image::MaskedImage< PixelT >>> &  images,
Property  flags,
StatisticsControl const &  sctrl = StatisticsControl(),
std::vector< lsst::afw::image::VariancePixel > const &  wvector = std::vectorlsst::afw::image::VariancePixel >(0),
image::MaskPixel  clipped = 0,
image::MaskPixel  excuse = 0 
)

@ brief compute statistical stack of MaskedImage.

Write to output image in-situ

Parameters
outOutput image
imagesMaskedImages to process
flagsstatistics requested
sctrlcontrol structure
wvectorvector containing weights
clippedbitmask to set if any input was clipped or masked
excusebitmask to excuse from marking as clipped

◆ statisticsStack() [10/18]

template<typename PixelT >
std::shared_ptr<lsst::afw::image::MaskedImage<PixelT> > lsst::afw::math::statisticsStack ( lsst::afw::image::MaskedImage< PixelT > const &  image,
Property  flags,
char  dimension,
StatisticsControl const &  sctrl = StatisticsControl() 
)

A function to compute statistics on the rows or columns of an image.

Definition at line 488 of file Stack.cc.

490  {
491  int const x0 = image.getX0();
492  int const y0 = image.getY0();
493  typedef image::MaskedImage<PixelT> MImage;
495 
496  // do each row or column, one at a time
497  // - create a subimage with a bounding box, and get the stats and assign the value to the output image
498  if (dimension == 'x') {
499  imgOut = std::shared_ptr<MImage>(new MImage(lsst::geom::Extent2I(1, image.getHeight())));
500  int y = 0;
501  typename MImage::y_iterator oEnd = imgOut->col_end(0);
502  for (typename MImage::y_iterator oPtr = imgOut->col_begin(0); oPtr != oEnd; ++oPtr, ++y) {
506  Statistics stat = makeStatistics(subImage, flags | ERRORS, sctrl);
507  *oPtr = typename image::MaskedImage<PixelT>::Pixel(stat.getValue(), 0x0,
508  stat.getError() * stat.getError());
509  }
510 
511  } else if (dimension == 'y') {
512  imgOut = std::shared_ptr<MImage>(new MImage(lsst::geom::Extent2I(image.getWidth(), 1)));
513  int x = 0;
514  typename MImage::x_iterator oEnd = imgOut->row_end(0);
515  for (typename MImage::x_iterator oPtr = imgOut->row_begin(0); oPtr != oEnd; ++oPtr, ++x) {
519  Statistics stat = makeStatistics(subImage, flags | ERRORS, sctrl);
520  *oPtr = typename image::MaskedImage<PixelT>::Pixel(stat.getValue(), 0x0,
521  stat.getError() * stat.getError());
522  }
523  } else {
525  "Can only run statisticsStack in x or y for single image.");
526  }
527 
528  return imgOut;
529 }

◆ statisticsStack() [11/18]

template<typename PixelT >
std::shared_ptr<image::Image<PixelT> > lsst::afw::math::statisticsStack ( std::vector< std::shared_ptr< image::Image< PixelT >>> &  images,
Property  flags,
StatisticsControl const &  sctrl,
WeightVector const &  wvector 
)

Definition at line 348 of file Stack.cc.

350  {
351  if (images.size() == 0) {
352  throw LSST_EXCEPT(pexExcept::LengthError, "Please specify at least one image to stack");
353  }
354  std::shared_ptr<image::Image<PixelT>> out(new image::Image<PixelT>(images[0]->getDimensions()));
355  statisticsStack(*out, images, flags, sctrl, wvector);
356  return out;
357 }

◆ statisticsStack() [12/18]

template<typename PixelT >
std::shared_ptr<image::MaskedImage<PixelT> > lsst::afw::math::statisticsStack ( std::vector< std::shared_ptr< image::MaskedImage< PixelT >>> &  images,
Property  flags,
StatisticsControl const &  sctrl,
WeightVector const &  wvector,
image::MaskPixel  clipped,
image::MaskPixel  excuse 
)

Definition at line 223 of file Stack.cc.

226  {
227  if (images.size() == 0) {
228  throw LSST_EXCEPT(pexExcept::LengthError, "Please specify at least one image to stack");
229  }
231  new image::MaskedImage<PixelT>(images[0]->getDimensions()));
232  statisticsStack(*out, images, flags, sctrl, wvector, clipped, excuse);
233  return out;
234 }

◆ statisticsStack() [13/18]

template<typename PixelT >
std::shared_ptr<image::MaskedImage<PixelT> > lsst::afw::math::statisticsStack ( std::vector< std::shared_ptr< image::MaskedImage< PixelT >>> &  images,
Property  flags,
StatisticsControl const &  sctrl,
WeightVector const &  wvector,
image::MaskPixel  clipped,
std::vector< std::pair< image::MaskPixel, image::MaskPixel >> const &  maskMap 
)

Definition at line 237 of file Stack.cc.

240  {
241  if (images.size() == 0) {
242  throw LSST_EXCEPT(pexExcept::LengthError, "Please specify at least one image to stack");
243  }
245  new image::MaskedImage<PixelT>(images[0]->getDimensions()));
246  statisticsStack(*out, images, flags, sctrl, wvector, clipped, maskMap);
247  return out;
248 }

◆ statisticsStack() [14/18]

template<typename PixelT >
std::shared_ptr<lsst::afw::image::Image<PixelT> > lsst::afw::math::statisticsStack ( std::vector< std::shared_ptr< lsst::afw::image::Image< PixelT >>> &  images,
Property  flags,
StatisticsControl const &  sctrl = StatisticsControl(),
std::vector< lsst::afw::image::VariancePixel > const &  wvector = std::vectorlsst::afw::image::VariancePixel >(0) 
)

A function to compute some statistics of a stack of Images.

Parameters
imagesImages to process
flagsstatistics requested
sctrlControl structure
wvectorvector containing weights

◆ statisticsStack() [15/18]

template<typename PixelT >
std::shared_ptr<lsst::afw::image::MaskedImage<PixelT> > lsst::afw::math::statisticsStack ( std::vector< std::shared_ptr< lsst::afw::image::MaskedImage< PixelT >>> &  images,
Property  flags,
StatisticsControl const &  sctrl,
std::vector< lsst::afw::image::VariancePixel > const &  wvector,
image::MaskPixel  clipped,
std::vector< std::pair< image::MaskPixel, image::MaskPixel >> const &  maskMap 
)

A function to compute some statistics of a stack of Masked Images.

Parameters
[in]imagesMaskedImages to process.
[in]flagsStatistics requested.
[in]sctrlControl structure.
[in]wvectorVector of weights.
[in]clippedMask to set for pixels that were clipped (NOT rejected due to masks).
[in]maskMapVector of pairs of mask pixel values; any pixel on an input with any of the bits in .first will result in all of the bits in .second being set on the corresponding pixel on the output.

If none of the input images are valid for some pixel, the afwMath::StatisticsControl::getNoGoodPixelsMask() bit(s) are set.

All the work is done in the function computeMaskedImageStack.

◆ statisticsStack() [16/18]

template<typename PixelT >
std::shared_ptr<lsst::afw::image::MaskedImage<PixelT> > lsst::afw::math::statisticsStack ( std::vector< std::shared_ptr< lsst::afw::image::MaskedImage< PixelT >>> &  images,
Property  flags,
StatisticsControl const &  sctrl = StatisticsControl(),
std::vector< lsst::afw::image::VariancePixel > const &  wvector = std::vectorlsst::afw::image::VariancePixel >(0),
image::MaskPixel  clipped = 0,
image::MaskPixel  excuse = 0 
)

A function to compute some statistics of a stack of Masked Images.

If none of the input images are valid for some pixel, the afwMath::StatisticsControl::getNoGoodPixelsMask() bit(s) are set.

Delegates to the more general version of statisticsStack taking a maskMap.

Parameters
imagesMaskedImages to process
flagsstatistics requested
sctrlcontrol structure
wvectorvector containing weights
clippedbitmask to set if any input was clipped or masked
excusebitmask to excuse from marking as clipped

◆ statisticsStack() [17/18]

template<typename PixelT >
std::vector<PixelT> lsst::afw::math::statisticsStack ( std::vector< std::vector< PixelT >> &  vectors,
Property  flags,
StatisticsControl const &  sctrl,
WeightVector const &  wvector 
)

Definition at line 425 of file Stack.cc.

427  {
428  checkObjectsAndWeights(vectors, wvector);
429  checkOnlyOneFlag(flags);
430 
431  if (wvector.empty()) {
432  return computeVectorStack<PixelT, false>(vectors, flags, sctrl);
433  } else {
434  return computeVectorStack<PixelT, true>(vectors, flags, sctrl, wvector);
435  }
436 }

◆ statisticsStack() [18/18]

template<typename PixelT >
std::vector<PixelT> lsst::afw::math::statisticsStack ( std::vector< std::vector< PixelT >> &  vectors,
Property  flags,
StatisticsControl const &  sctrl = StatisticsControl(),
std::vector< lsst::afw::image::VariancePixel > const &  wvector = std::vectorlsst::afw::image::VariancePixel >(0) 
)

A function to compute some statistics of a stack of std::vectors.

Parameters
vectorsVectors to process
flagsstatistics requested
sctrlcontrol structure
wvectorvector containing weights

◆ stringToInterpStyle()

Interpolate::Style lsst::afw::math::stringToInterpStyle ( std::string const &  style)

Conversion function to switch a string to an Interpolate::Style.

Parameters
styledesired type of interpolation

Definition at line 257 of file Interpolate.cc.

257  {
258  static std::map<std::string, Interpolate::Style> gslInterpTypeStrings;
259  if (gslInterpTypeStrings.empty()) {
260  gslInterpTypeStrings["CONSTANT"] = Interpolate::CONSTANT;
261  gslInterpTypeStrings["LINEAR"] = Interpolate::LINEAR;
262  gslInterpTypeStrings["CUBIC_SPLINE"] = Interpolate::CUBIC_SPLINE;
263  gslInterpTypeStrings["NATURAL_SPLINE"] = Interpolate::NATURAL_SPLINE;
264  gslInterpTypeStrings["CUBIC_SPLINE_PERIODIC"] = Interpolate::CUBIC_SPLINE_PERIODIC;
265  gslInterpTypeStrings["AKIMA_SPLINE"] = Interpolate::AKIMA_SPLINE;
266  gslInterpTypeStrings["AKIMA_SPLINE_PERIODIC"] = Interpolate::AKIMA_SPLINE_PERIODIC;
267  }
268 
269  if (gslInterpTypeStrings.find(style) == gslInterpTypeStrings.end()) {
270  throw LSST_EXCEPT(pex::exceptions::InvalidParameterError, "Interp style not found: " + style);
271  }
272  return gslInterpTypeStrings[style];
273 }

◆ stringToStatisticsProperty()

Property lsst::afw::math::stringToStatisticsProperty ( std::string const  property)

Conversion function to switch a string to a Property (see Statistics.h)

Definition at line 747 of file Statistics.cc.

747  {
748  static std::map<std::string, Property> statisticsProperty;
749  if (statisticsProperty.size() == 0) {
750  statisticsProperty["NOTHING"] = NOTHING;
751  statisticsProperty["ERRORS"] = ERRORS;
752  statisticsProperty["NPOINT"] = NPOINT;
753  statisticsProperty["MEAN"] = MEAN;
754  statisticsProperty["STDEV"] = STDEV;
755  statisticsProperty["VARIANCE"] = VARIANCE;
756  statisticsProperty["MEDIAN"] = MEDIAN;
757  statisticsProperty["IQRANGE"] = IQRANGE;
758  statisticsProperty["MEANCLIP"] = MEANCLIP;
759  statisticsProperty["STDEVCLIP"] = STDEVCLIP;
760  statisticsProperty["VARIANCECLIP"] = VARIANCECLIP;
761  statisticsProperty["MIN"] = MIN;
762  statisticsProperty["MAX"] = MAX;
763  statisticsProperty["SUM"] = SUM;
764  statisticsProperty["MEANSQUARE"] = MEANSQUARE;
765  statisticsProperty["ORMASK"] = ORMASK;
766  statisticsProperty["NCLIPPED"] = NCLIPPED;
767  statisticsProperty["NMASKED"] = NMASKED;
768  }
769  return statisticsProperty[property];
770 }

◆ stringToUndersampleStyle()

UndersampleStyle lsst::afw::math::stringToUndersampleStyle ( std::string const &  style)

Conversion function to switch a string to an UndersampleStyle.

Definition at line 117 of file Background.cc.

117  {
118  static std::map<std::string, UndersampleStyle> undersampleStrings;
119  if (undersampleStrings.size() == 0) {
120  undersampleStrings["THROW_EXCEPTION"] = THROW_EXCEPTION;
121  undersampleStrings["REDUCE_INTERP_ORDER"] = REDUCE_INTERP_ORDER;
122  undersampleStrings["INCREASE_NXNYSAMPLE"] = INCREASE_NXNYSAMPLE;
123  }
124 
125  if (undersampleStrings.find(style) == undersampleStrings.end()) {
126  throw LSST_EXCEPT(ex::InvalidParameterError, "Understample style not defined: " + style);
127  }
128  return undersampleStrings[style];
129 }

◆ warpCenteredImage()

template<typename DestImageT , typename SrcImageT >
int lsst::afw::math::warpCenteredImage ( DestImageT &  destImage,
SrcImageT const &  srcImage,
lsst::geom::LinearTransform const &  linearTransform,
lsst::geom::Point2D const &  centerPosition,
WarpingControl const &  control,
typename DestImageT::SinglePixel  padValue = lsst::afw::math::edgePixel<DestImageT>(                typename lsst::afw::image::detail::image_traits<DestImageT>::image_category()) 
)

Warp an image with a LinearTranform about a specified point.

This enables warping an image of e.g. a PSF without translating the centroid.

Parameters
destImageremapped image
srcImagesource image
linearTransformlinear transformation to apply
centerPositionpixel position for location of linearTransform
controlcontrol parameters
padValueuse this value for undefined (edge) pixels

Definition at line 510 of file warpExposure.cc.

513  {
514  // force src and dest to be the same size and xy0
515  if ((destImage.getWidth() != srcImage.getWidth()) || (destImage.getHeight() != srcImage.getHeight()) ||
516  (destImage.getXY0() != srcImage.getXY0())) {
517  std::ostringstream errStream;
518  errStream << "src and dest images must have same size and xy0.";
520  }
521 
522  // set the xy0 coords to 0,0 to make life easier
523  SrcImageT srcImageCopy(srcImage, true);
524  srcImageCopy.setXY0(0, 0);
525  destImage.setXY0(0, 0);
526  lsst::geom::Extent2D cLocal =
527  lsst::geom::Extent2D(centerPosition) - lsst::geom::Extent2D(srcImage.getXY0());
528 
529  // for the affine transform, the centerPosition will not only get sheared, but also
530  // moved slightly. So we'll include a translation to move it back by an amount
531  // centerPosition - translatedCenterPosition
532  lsst::geom::AffineTransform affTran(linearTransform, cLocal - linearTransform(cLocal));
534 
535 // now warp
536 #if 0
537  static float t = 0.0;
538  float t_before = 1.0*clock()/CLOCKS_PER_SEC;
539  int n = warpImage(destImage, srcImageCopy, affTran, control, padValue);
540  float t_after = 1.0*clock()/CLOCKS_PER_SEC;
541  float dt = t_after - t_before;
542  t += dt;
543  std::cout <<srcImage.getWidth()<<"x"<<srcImage.getHeight()<<": "<< dt <<" "<< t <<std::endl;
544 #else
545  int n = warpImage(destImage, srcImageCopy, *affineTransform22, control, padValue);
546 #endif
547 
548  // fix the origin and we're done.
549  destImage.setXY0(srcImage.getXY0());
550 
551  return n;
552 }

◆ warpExposure()

template<typename DestExposureT , typename SrcExposureT >
int lsst::afw::math::warpExposure ( DestExposureT &  destExposure,
SrcExposureT const &  srcExposure,
WarpingControl const &  control,
typename DestExposureT::MaskedImageT::SinglePixel  padValue = lsst::afw::math::edgePixel<typename DestExposureT::MaskedImageT>(                        typename lsst::afw::image::detail::image_traits<                                typename DestExposureT::MaskedImageT>::image_category()) 
)

Warp (remap) one exposure to another.

This is a convenience wrapper around warpImage().

Parameters
destExposureRemapped exposure. Wcs and xy0 are read, MaskedImage is set, and PhotoCalib, Filter and VisitInfo are copied from srcExposure. All other attributes are left alone (including Detector and Psf)
srcExposureSource exposure
controlcontrol parameters
padValueuse this value for undefined (edge) pixels

Definition at line 238 of file warpExposure.cc.

239  {
240  if (!destExposure.hasWcs()) {
241  throw LSST_EXCEPT(pexExcept::InvalidParameterError, "destExposure has no Wcs");
242  }
243  if (!srcExposure.hasWcs()) {
244  throw LSST_EXCEPT(pexExcept::InvalidParameterError, "srcExposure has no Wcs");
245  }
246  typename DestExposureT::MaskedImageT mi = destExposure.getMaskedImage();
247  destExposure.setPhotoCalib(srcExposure.getPhotoCalib());
248  destExposure.setFilter(srcExposure.getFilter());
249  destExposure.getInfo()->setVisitInfo(srcExposure.getInfo()->getVisitInfo());
250  return warpImage(mi, *destExposure.getWcs(), srcExposure.getMaskedImage(), *srcExposure.getWcs(), control,
251  padValue);
252 }

◆ warpImage() [1/2]

template<typename DestImageT , typename SrcImageT >
int lsst::afw::math::warpImage ( DestImageT &  destImage,
geom::SkyWcs const &  destWcs,
SrcImageT const &  srcImage,
geom::SkyWcs const &  srcWcs,
WarpingControl const &  control,
typename DestImageT::SinglePixel  padValue = lsst::afw::math::edgePixel<DestImageT>(                      typename lsst::afw::image::detail::image_traits<DestImageT>::image_category()) 
)

Warp an Image or MaskedImage to a new Wcs.

See also convenience function warpExposure() to warp an Exposure.

Edge pixels are set to padValue; these are pixels that cannot be computed because they are too near the edge of srcImage or miss srcImage entirely.

Returns
the number of valid pixels in destImage (those that are not edge pixels).

Algorithm Without Interpolation:

For each integer pixel position in the remapped Exposure:

  • The associated pixel position on srcImage is determined using the destination and source WCS
  • The warping kernel's parameters are set based on the fractional part of the pixel position on srcImage
  • The warping kernel is applied to srcImage at the integer portion of the pixel position to compute the remapped pixel value
  • A flux-conservation factor is determined from the source and destination WCS and is applied to the remapped pixel

The scaling of intensity for relative area of source and destination uses two minor approximations:

  • The area of the sky marked out by a pixel on the destination image corresponds to a parallellogram on the source image.
  • The area varies slowly enough across the image that we can get away with computing the source area shifted by half a pixel up and to the left of the true area.

Algorithm With Interpolation:

Interpolation simply reduces the number of times WCS is used to map between destination and source pixel position. This computation is only made at a grid of points on the destination image, separated by interpLen pixels along rows and columns. All other source pixel positions are determined by linear interpolation between those grid points. Everything else remains the same.

Exceptions
lsst::pex::exceptions::InvalidParameterErrorif destImage overlaps srcImage
std::bad_allocwhen allocation of CPU memory fails
Todo:
Should support an additional color-based position correction in the remapping (differential chromatic refraction). This can be done either object-by-object or pixel-by-pixel.
Todo:
Need to deal with oversampling and/or weight maps. If done we can use faster kernels than sinc.
Warning
The code that tests for image overlap is not guranteed to work correctly, based on the C++ standard. It is, in theory, possible for the code to report a "false positive", meaning that it may claim that images overlap when they do not. We don't believe that any of our current compilers have this problem. If, in the future, this becomes a problem then we will probably have to remove the test and rely on users being careful.
Parameters
destImageremapped image
destWcsWCS of remapped image
srcImagesource image
srcWcsWCS of source image
controlcontrol parameters
padValueuse this value for undefined (edge) pixels

Definition at line 283 of file warpExposure.cc.

285  {
286  auto srcToDest = geom::makeWcsPairTransform(srcWcs, destWcs);
287  return warpImage(destImage, srcImage, *srcToDest, control, padValue);
288 }

◆ warpImage() [2/2]

template<typename DestImageT , typename SrcImageT >
int lsst::afw::math::warpImage ( DestImageT &  destImage,
SrcImageT const &  srcImage,
geom::TransformPoint2ToPoint2 const &  srcToDest,
WarpingControl const &  control,
typename DestImageT::SinglePixel  padValue = lsst::afw::math::edgePixel<DestImageT>(                      typename lsst::afw::image::detail::image_traits<DestImageT>::image_category()) 
)

A variant of warpImage that uses a Transform<Point2Endpoint, Point2Endpoint> instead of a pair of WCS to describe the transformation.

Parameters
[in,out]destImageDestination image; all pixels are set
[in]srcImageSource image
[in]srcToDestTransformation from source to destination pixels, in parent coordinates; the inverse must be defined (and is the only direction used). makeWcsPairTransform(srcWcs, destWcs) is one way to compute this transform.
[in]controlWarning control parameters
[in]padValueValue used for pixels in the destination image that are outside the region of pixels that can be computed from the source image
Returns
the number of good pixels

Definition at line 291 of file warpExposure.cc.

293  {
294  if (imagesOverlap(destImage, srcImage)) {
295  throw LSST_EXCEPT(pexExcept::InvalidParameterError, "destImage overlaps srcImage; cannot warp");
296  }
297  if (destImage.getBBox(image::LOCAL).isEmpty()) {
298  return 0;
299  }
300  // if src image is too small then don't try to warp
301  std::shared_ptr<SeparableKernel> warpingKernelPtr = control.getWarpingKernel();
302  try {
303  warpingKernelPtr->shrinkBBox(srcImage.getBBox(image::LOCAL));
305  for (int y = 0, height = destImage.getHeight(); y < height; ++y) {
306  for (typename DestImageT::x_iterator destPtr = destImage.row_begin(y), end = destImage.row_end(y);
307  destPtr != end; ++destPtr) {
308  *destPtr = padValue;
309  }
310  }
311  return 0;
312  }
313  int interpLength = control.getInterpLength();
314 
315  std::shared_ptr<LanczosWarpingKernel const> const lanczosKernelPtr =
316  std::dynamic_pointer_cast<LanczosWarpingKernel>(warpingKernelPtr);
317 
318  int numGoodPixels = 0;
319 
320  // compute a transform from local destination pixels to parent source pixels
321  auto const parentDestToParentSrc = srcToDest.inverted();
322  std::vector<double> const localDestToParentDestVec = {static_cast<double>(destImage.getX0()),
323  static_cast<double>(destImage.getY0())};
324  auto const localDestToParentDest = geom::TransformPoint2ToPoint2(ast::ShiftMap(localDestToParentDestVec));
325  auto const localDestToParentSrc = localDestToParentDest.then(*parentDestToParentSrc);
326 
327  // Get the source MaskedImage and a pixel accessor to it.
328  int const srcWidth = srcImage.getWidth();
329  int const srcHeight = srcImage.getHeight();
330  LOGL_DEBUG("TRACE2.afw.math.warp", "source image width=%d; height=%d", srcWidth, srcHeight);
331 
332  int const destWidth = destImage.getWidth();
333  int const destHeight = destImage.getHeight();
334  LOGL_DEBUG("TRACE2.afw.math.warp", "remap image width=%d; height=%d", destWidth, destHeight);
335 
336  // Set each pixel of destExposure's MaskedImage
337  LOGL_DEBUG("TRACE3.afw.math.warp", "Remapping masked image");
338 
339  int const maxCol = destWidth - 1;
340  int const maxRow = destHeight - 1;
341 
342  detail::WarpAtOnePoint<DestImageT, SrcImageT> warpAtOnePoint(srcImage, control, padValue);
343 
344  if (interpLength > 0) {
345  // Use interpolation. Note that 1 produces the same result as no interpolation
346  // but uses this code branch, thus providing an easy way to compare the two branches.
347 
348  // Estimate for number of horizontal interpolation band edges, to reserve memory in vectors
349  int const numColEdges = 2 + ((destWidth - 1) / interpLength);
350 
351  // A list of edge column indices for interpolation bands;
352  // starts at -1, increments by interpLen (except the final interval), and ends at destWidth-1
353  std::vector<int> edgeColList;
354  edgeColList.reserve(numColEdges);
355 
356  // A list of 1/column width for horizontal interpolation bands; the first value is garbage.
357  // The inverse is used for speed because the values are always multiplied.
358  std::vector<double> invWidthList;
359  invWidthList.reserve(numColEdges);
360 
361  // Compute edgeColList and invWidthList
362  edgeColList.push_back(-1);
363  invWidthList.push_back(0.0);
364  for (int prevEndCol = -1; prevEndCol < maxCol; prevEndCol += interpLength) {
365  int endCol = prevEndCol + interpLength;
366  if (endCol > maxCol) {
367  endCol = maxCol;
368  }
369  edgeColList.push_back(endCol);
370  assert(endCol - prevEndCol > 0);
371  invWidthList.push_back(1.0 / static_cast<double>(endCol - prevEndCol));
372  }
373  assert(edgeColList.back() == maxCol);
374 
375  // A list of delta source positions along the edge columns of the horizontal interpolation bands
376  std::vector<lsst::geom::Extent2D> yDeltaSrcPosList(edgeColList.size());
377 
378  // A cache of pixel positions on the source corresponding to the previous or current row
379  // of the destination image.
380  // The first value is for column -1 because the previous source position is used to compute relative
381  // area To simplify the indexing, use an iterator that starts at begin+1, thus: srcPosView =
382  // srcPosList.begin() + 1 srcPosView[col-1] and lower indices are for this row srcPosView[col] and
383  // higher indices are for the previous row
384  std::vector<lsst::geom::Point2D> srcPosList(1 + destWidth);
385  std::vector<lsst::geom::Point2D>::iterator const srcPosView = srcPosList.begin() + 1;
386 
387  std::vector<lsst::geom::Point2D> endColPosList;
388  endColPosList.reserve(numColEdges);
389 
390  // Initialize srcPosList for row -1
391  for (int colBand = 0, endBand = edgeColList.size(); colBand < endBand; ++colBand) {
392  int const endCol = edgeColList[colBand];
393  endColPosList.emplace_back(lsst::geom::Point2D(endCol, -1));
394  }
395  auto rightSrcPosList = localDestToParentSrc->applyForward(endColPosList);
396  srcPosView[-1] = rightSrcPosList[0];
397  for (int colBand = 1, endBand = edgeColList.size(); colBand < endBand; ++colBand) {
398  int const prevEndCol = edgeColList[colBand - 1];
399  int const endCol = edgeColList[colBand];
400  lsst::geom::Point2D leftSrcPos = srcPosView[prevEndCol];
401 
402  lsst::geom::Extent2D xDeltaSrcPos =
403  (rightSrcPosList[colBand] - leftSrcPos) * invWidthList[colBand];
404 
405  for (int col = prevEndCol + 1; col <= endCol; ++col) {
406  srcPosView[col] = srcPosView[col - 1] + xDeltaSrcPos;
407  }
408  }
409 
410  int endRow = -1;
411  while (endRow < maxRow) {
412  // Next horizontal interpolation band
413 
414  int prevEndRow = endRow;
415  endRow = prevEndRow + interpLength;
416  if (endRow > maxRow) {
417  endRow = maxRow;
418  }
419  assert(endRow - prevEndRow > 0);
420  double interpInvHeight = 1.0 / static_cast<double>(endRow - prevEndRow);
421 
422  // Set yDeltaSrcPosList for this horizontal interpolation band
423  std::vector<lsst::geom::Point2D> destRowPosList;
424  destRowPosList.reserve(edgeColList.size());
425  for (int colBand = 0, endBand = edgeColList.size(); colBand < endBand; ++colBand) {
426  int endCol = edgeColList[colBand];
427  destRowPosList.emplace_back(lsst::geom::Point2D(endCol, endRow));
428  }
429  auto bottomSrcPosList = localDestToParentSrc->applyForward(destRowPosList);
430  for (int colBand = 0, endBand = edgeColList.size(); colBand < endBand; ++colBand) {
431  int endCol = edgeColList[colBand];
432  yDeltaSrcPosList[colBand] =
433  (bottomSrcPosList[colBand] - srcPosView[endCol]) * interpInvHeight;
434  }
435 
436  for (int row = prevEndRow + 1; row <= endRow; ++row) {
437  typename DestImageT::x_iterator destXIter = destImage.row_begin(row);
438  srcPosView[-1] += yDeltaSrcPosList[0];
439  for (int colBand = 1, endBand = edgeColList.size(); colBand < endBand; ++colBand) {
440  // Next vertical interpolation band
441 
442  int const prevEndCol = edgeColList[colBand - 1];
443  int const endCol = edgeColList[colBand];
444 
445  // Compute xDeltaSrcPos; remember that srcPosView contains
446  // positions for this row in prevEndCol and smaller indices,
447  // and positions for the previous row for larger indices (including endCol)
448  lsst::geom::Point2D leftSrcPos = srcPosView[prevEndCol];
449  lsst::geom::Point2D rightSrcPos = srcPosView[endCol] + yDeltaSrcPosList[colBand];
450  lsst::geom::Extent2D xDeltaSrcPos = (rightSrcPos - leftSrcPos) * invWidthList[colBand];
451 
452  for (int col = prevEndCol + 1; col <= endCol; ++col, ++destXIter) {
453  lsst::geom::Point2D leftSrcPos = srcPosView[col - 1];
454  lsst::geom::Point2D srcPos = leftSrcPos + xDeltaSrcPos;
455  double relativeArea = computeRelativeArea(srcPos, leftSrcPos, srcPosView[col]);
456 
457  srcPosView[col] = srcPos;
458 
459  if (warpAtOnePoint(
460  destXIter, srcPos, relativeArea,
461  typename image::detail::image_traits<DestImageT>::image_category())) {
462  ++numGoodPixels;
463  }
464  } // for col
465  } // for col band
466  } // for row
467  } // while next row band
468 
469  } else {
470  // No interpolation
471 
472  // prevSrcPosList = source positions from the previous row; these are used to compute pixel area;
473  // to begin, compute sources positions corresponding to destination row = -1
475  destPosList.reserve(1 + destWidth);
476  for (int col = -1; col < destWidth; ++col) {
477  destPosList.emplace_back(lsst::geom::Point2D(col, -1));
478  }
479  auto prevSrcPosList = localDestToParentSrc->applyForward(destPosList);
480 
481  for (int row = 0; row < destHeight; ++row) {
482  destPosList.clear();
483  for (int col = -1; col < destWidth; ++col) {
484  destPosList.emplace_back(lsst::geom::Point2D(col, row));
485  }
486  auto srcPosList = localDestToParentSrc->applyForward(destPosList);
487 
488  typename DestImageT::x_iterator destXIter = destImage.row_begin(row);
489  for (int col = 0; col < destWidth; ++col, ++destXIter) {
490  // column index = column + 1 because the first entry in srcPosList is for column -1
491  auto srcPos = srcPosList[col + 1];
492  double relativeArea =
493  computeRelativeArea(srcPos, prevSrcPosList[col], prevSrcPosList[col + 1]);
494 
495  if (warpAtOnePoint(destXIter, srcPos, relativeArea,
496  typename image::detail::image_traits<DestImageT>::image_category())) {
497  ++numGoodPixels;
498  }
499  } // for col
500  // move points from srcPosList to prevSrcPosList (we don't care about what ends up in srcPosList
501  // because it will be reallocated anyway)
502  swap(srcPosList, prevSrcPosList);
503  } // for row
504  } // if interp
505 
506  return numGoodPixels;
507 }

◆ wrapTestClasses()

void lsst::afw::math::wrapTestClasses ( py::module &  mod)

<

<

<

<

<

<

Definition at line 156 of file spatialCell.cc.

156  {
157  /*
158  * Test class for SpatialCellCandidate
159  */
160  class TestCandidate : public SpatialCellCandidate {
161  public:
162  TestCandidate(float const xCenter,
163  float const yCenter,
164  float const flux
165  )
166  : SpatialCellCandidate(xCenter, yCenter), _flux(flux) {}
167 
169  virtual double getCandidateRating() const { return _flux; }
170  virtual void setCandidateRating(double flux) { _flux = flux; }
171 
172  private:
173  double _flux;
174  };
175 
177  class TestCandidateVisitor : public CandidateVisitor {
178  public:
179  TestCandidateVisitor() : CandidateVisitor(), _n(0) {}
180 
181  // Called by SpatialCellSet::visitCandidates before visiting any Candidates
182  void reset() { _n = 0; }
183 
184  // Called by SpatialCellSet::visitCandidates for each Candidate
185  void processCandidate(SpatialCellCandidate *candidate) { ++_n; }
186 
187  int getN() const { return _n; }
188 
189  private:
190  int _n; // number of TestCandidates
191  };
192 
193  class TestImageCandidate : public SpatialCellImageCandidate {
194  public:
195  typedef image::MaskedImage<float> MaskedImageT;
196 
197  TestImageCandidate(float const xCenter,
198  float const yCenter,
199  float const flux
200  )
201  : SpatialCellImageCandidate(xCenter, yCenter), _flux(flux) {}
202 
204  double getCandidateRating() const { return _flux; }
205 
207  std::shared_ptr<MaskedImageT const> getMaskedImage() const {
208  if (!_image) {
209  _image = std::make_shared<MaskedImageT>(lsst::geom::ExtentI(getWidth(), getHeight()));
210  *_image->getImage() = _flux;
211  }
212  return _image;
213  }
214 
215  private:
216  mutable std::shared_ptr<MaskedImageT> _image;
217  double _flux;
218  };
219 
220  py::class_<TestCandidate, std::shared_ptr<TestCandidate>, SpatialCellCandidate> clsTestCandidate(
221  mod, ("TestCandidate"));
222  clsTestCandidate.def(py::init<float const, float const, float const>());
223  clsTestCandidate.def("getCandidateRating", &TestCandidate::getCandidateRating);
224  clsTestCandidate.def("setCandidateRating", &TestCandidate::setCandidateRating);
225 
226  py::class_<TestCandidateVisitor, std::shared_ptr<TestCandidateVisitor>, CandidateVisitor>
227  clsTestCandidateVisitor(mod, ("TestCandidateVisitor"));
228  clsTestCandidateVisitor.def(py::init<>());
229  clsTestCandidateVisitor.def("getN", &TestCandidateVisitor::getN);
230 
231  py::class_<TestImageCandidate, std::shared_ptr<TestImageCandidate>, SpatialCellImageCandidate>
232  clsTestImageCandidate(mod, "TestImageCandidate");
233  clsTestImageCandidate.def(py::init<float const, float const, float const>(), "xCenter"_a, "yCenter"_a,
234  "flux"_a);
235  clsTestImageCandidate.def("getCandidateRating", &TestImageCandidate::getCandidateRating);
236  clsTestImageCandidate.def("getMaskedImage", &TestImageCandidate::getMaskedImage);
237 };

Variable Documentation

◆ DEFABSERR

double const lsst::afw::math::DEFABSERR = 1.e-15

Definition at line 272 of file Integrate.h.

◆ DEFRELERR

double const lsst::afw::math::DEFRELERR = 1.e-6

Definition at line 273 of file Integrate.h.

◆ deltafunction_kernel_tag_

deltafunction_kernel_tag lsst::afw::math::deltafunction_kernel_tag_

Used as default value in argument lists.

Definition at line 52 of file Kernel.cc.

◆ generic_kernel_tag_

generic_kernel_tag lsst::afw::math::generic_kernel_tag_

Used as default value in argument lists.

Definition at line 51 of file Kernel.cc.

◆ IS_NOTHROW_INIT

template<typename T >
constexpr bool lsst::afw::math::IS_NOTHROW_INIT = noexcept(static_cast<T>(1.0))
constexpr

Test that a Function's return value is nothrow-castable to T.

std::complex is an example of a numeric type that does not satisfy this requirement.

Definition at line 51 of file Function.h.

◆ MOCK_INF

double const lsst::afw::math::MOCK_INF = 1.e10

Definition at line 171 of file Integrate.h.

y
int y
Definition: SpanSet.cc:49
lsst::afw::math::IQRANGE
@ IQRANGE
estimate sample inter-quartile range
Definition: Statistics.h:71
lsst::afw::image
Backwards-compatibility support for depersisting the old Calib (FluxMag0/FluxMag0Err) objects.
Definition: imageAlgorithm.dox:1
std::vector::resize
T resize(T... args)
lsst::afw::math::makeInterpolate
std::shared_ptr< Interpolate > makeInterpolate(std::vector< double > const &x, std::vector< double > const &y, Interpolate::Style const style=Interpolate::AKIMA_SPLINE)
A factory function to make Interpolate objects.
Definition: Interpolate.cc:343
std::floor
T floor(T... args)
lsst::afw::image::LOCAL
@ LOCAL
Definition: ImageBase.h:94
lsst::afw::math::UndersampleStyle
UndersampleStyle
Definition: Background.h:47
lsst::afw::math::REDUCE_INTERP_ORDER
@ REDUCE_INTERP_ORDER
Definition: Background.h:47
lsst::afw::math::MaskedVector::getMask
lsst::afw::image::MaskedImage< EntryT >::MaskPtr getMask() const
Definition: MaskedVector.h:91
std::string
STL class.
std::shared_ptr< ImageT >
lsst::afw::image::Mask
Represent a 2-dimensional array of bitmask pixels.
Definition: Mask.h:77
lsst::afw::table._match.second
second
Definition: _match.py:76
std::pair< double, double >
std::vector::reserve
T reserve(T... args)
lsst::meas::modelfit::Pixel
float Pixel
Typedefs to be used for pixel values.
Definition: common.h:37
std::numeric_limits::quiet_NaN
T quiet_NaN(T... args)
lsst::afw::math::int3d
TF::result_type int3d(TF const &func, IntRegion< typename TF::result_type > &reg, IntRegion< typename TF::result_type > &yreg, IntRegion< typename TF::result_type > &zreg, typename TF::result_type const &abserr=DEFABSERR, typename TF::result_type const &relerr=DEFRELERR)
Front end for the 3d integrator.
Definition: Integrate.h:867
std::vector
STL class.
std::map::find
T find(T... args)
std::vector::size
T size(T... args)
lsst::sphgeom::abs
Angle abs(Angle const &a)
Definition: Angle.h:106
LOGL_WARN
#define LOGL_WARN(logger, message...)
Definition: Log.h:536
lsst::afw::table._match.first
first
Definition: _match.py:74
lsst::afw::math::makeWarpingKernel
std::shared_ptr< SeparableKernel > makeWarpingKernel(std::string name)
Return a warping kernel given its name.
Definition: warpExposure.cc:161
std::istringstream
STL class.
lsst::afw::math::THROW_EXCEPTION
@ THROW_EXCEPTION
Definition: Background.h:47
lsst::afw::math::DEFABSERR
double const DEFABSERR
Definition: Integrate.h:272
lsst::afw::math::stringToStatisticsProperty
Property stringToStatisticsProperty(std::string const property)
Conversion function to switch a string to a Property (see Statistics.h)
Definition: Statistics.cc:747
std::vector::back
T back(T... args)
lsst.pex.config.history.format
def format(config, name=None, writeSourceLine=True, prefix="", verbose=False)
Definition: history.py:174
val
ImageT val
Definition: CR.cc:146
lsst::afw::geom.transform.transformContinued.name
string name
Definition: transformContinued.py:32
lsst::geom::truncate
Extent< int, N > truncate(Extent< double, N > const &input) noexcept
Return the component-wise truncation (round towards zero).
Definition: Extent.cc:100
lsst::afw::image::ImageBase::getHeight
int getHeight() const
Return the number of rows in the image.
Definition: ImageBase.h:296
std::shared_ptr::reset
T reset(T... args)
end
int end
Definition: BoundedField.cc:105
std::vector::clear
T clear(T... args)
lsst::afw::math::int1d
UF::result_type int1d(UF const &func, IntRegion< typename UF::result_type > &reg, typename UF::result_type const &abserr=DEFABSERR, typename UF::result_type const &relerr=DEFRELERR)
Front end for the 1d integrator.
Definition: Integrate.h:765
std::vector::push_back
T push_back(T... args)
lsst::geom::AffineTransform
An affine coordinate transformation consisting of a linear transformation and an offset.
Definition: AffineTransform.h:75
lsst::afw::math::Statistics::makeStatistics
Statistics makeStatistics(lsst::afw::image::Image< Pixel > const &img, lsst::afw::image::Mask< image::MaskPixel > const &msk, int const flags, StatisticsControl const &sctrl=StatisticsControl())
Handle a watered-down front-end to the constructor (no variance)
Definition: Statistics.h:354
lsst::afw::math::MEANCLIP
@ MEANCLIP
estimate sample N-sigma clipped mean (N set in StatisticsControl, default=3)
Definition: Statistics.h:72
std::clock
T clock(T... args)
lsst::afw::math::VARIANCECLIP
@ VARIANCECLIP
estimate sample N-sigma clipped variance (N set in StatisticsControl, default=3)
Definition: Statistics.h:74
lsst::afw::math::int2d
BF::result_type int2d(BF const &func, IntRegion< typename BF::result_type > &reg, IntRegion< typename BF::result_type > &yreg, typename BF::result_type const &abserr=DEFABSERR, typename BF::result_type const &relerr=DEFRELERR)
Front end for the 2d integrator.
Definition: Integrate.h:855
lsst::afw::image::MaskedImage
A class to manipulate images, masks, and variance as a single object.
Definition: MaskedImage.h:73
std::isfinite
T isfinite(T... args)
lsst.pex::exceptions::DomainError
Reports arguments outside the domain of an operation.
Definition: Runtime.h:57
lsst::afw::math::MEAN
@ MEAN
estimate sample mean
Definition: Statistics.h:67
std::numeric_limits::infinity
T infinity(T... args)
std::cout
lsst::afw::math::STDEVCLIP
@ STDEVCLIP
estimate sample N-sigma clipped stdev (N set in StatisticsControl, default=3)
Definition: Statistics.h:73
integ_dbg2
#define integ_dbg2
Definition: Integrate.h:183
x
double x
Definition: ChebyshevBoundedField.cc:277
ast::ShiftMap
ShiftMap is a linear Mapping which shifts each axis by a specified constant value.
Definition: ShiftMap.h:40
lsst.pex::exceptions::LengthError
Reports attempts to exceed implementation-defined length limits for some classes.
Definition: Runtime.h:76
lsst::afw::math::MOCK_INF
double const MOCK_INF
Definition: Integrate.h:171
lsst::afw::math::NCLIPPED
@ NCLIPPED
number of clipped points
Definition: Statistics.h:81
lsst::afw::geom::TransformPoint2ToPoint2
Transform< Point2Endpoint, Point2Endpoint > TransformPoint2ToPoint2
Definition: Transform.h:300
ptr
uint64_t * ptr
Definition: RangeSet.cc:88
lsst::afw::math::details::intGKP
void intGKP(UF const &func, IntRegion< typename UF::result_type > &reg, typename UF::result_type const epsabs, typename UF::result_type const epsrel, std::map< typename UF::result_type, typename UF::result_type > *fxmap=0)
An adaptive integration algorithm which computes the integral of f over the region reg.
Definition: Integrate.h:463
std::int32_t
lsst::afw::math::ORMASK
@ ORMASK
get the or-mask of all pixels used.
Definition: Statistics.h:80
lsst::afw::image::MaskPixel
std::int32_t MaskPixel
default type for Masks and MaskedImage Masks
Definition: LsstImageTypes.h:34
std::map
STL class.
lsst::afw::typehandling::PolymorphicValue::swap
void swap(PolymorphicValue &lhs, PolymorphicValue &rhs) noexcept
Swap specialization for PolymorphicValue.
Definition: PolymorphicValue.h:152
b
table::Key< int > b
Definition: TransmissionCurve.cc:467
lsst::afw::image::MaskedImage::Pixel
lsst::afw::image::pixel::Pixel< ImagePixelT, MaskPixelT, VariancePixelT > Pixel
A Pixel in the MaskedImage.
Definition: MaskedImage.h:108
lsst::afw::math::ERRORS
@ ERRORS
Include errors of requested quantities.
Definition: Statistics.h:65
lsst::afw::image::MaskedImage::getVariance
VariancePtr getVariance() const
Return a (shared_ptr to) the MaskedImage's variance.
Definition: MaskedImage.h:1079
LSST_EXCEPT
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition: Exception.h:48
lsst::afw::math::convolve
void convolve(OutImageT &convolvedImage, InImageT const &inImage, KernelT const &kernel, ConvolutionControl const &convolutionControl=ConvolutionControl())
Convolve an Image or MaskedImage with a Kernel, setting pixels of an existing output image.
Definition: ConvolveImage.cc:190
lsst::afw::math::warpImage
int warpImage(DestImageT &destImage, geom::SkyWcs const &destWcs, SrcImageT const &srcImage, geom::SkyWcs const &srcWcs, WarpingControl const &control, typename DestImageT::SinglePixel padValue=lsst::afw::math::edgePixel< DestImageT >(typename lsst::afw::image::detail::image_traits< DestImageT >::image_category()))
Warp an Image or MaskedImage to a new Wcs.
Definition: warpExposure.cc:283
lsst::afw::image::for_each_pixel
void for_each_pixel(Image< LhsT > &lhs, pixelOp0< LhsT > const &func)
Set each pixel in an Image<LhsT> to func()
Definition: ImageAlgorithm.h:97
std::ostringstream
STL class.
lsst.pipe.tasks.insertFakes.flux
flux
Definition: insertFakes.py:455
os
std::ostream * os
Definition: Schema.cc:746
lsst::afw::math::MEANSQUARE
@ MEANSQUARE
find mean value of square of pixel values
Definition: Statistics.h:79
std::vector::emplace_back
T emplace_back(T... args)
lsst::afw::math::NPOINT
@ NPOINT
number of sample points
Definition: Statistics.h:66
std::endl
T endl(T... args)
lsst.pex::exceptions::InvalidParameterError
Reports invalid arguments.
Definition: Runtime.h:66
row
int row
Definition: CR.cc:145
lsst::afw::math::STDEV
@ STDEV
estimate sample standard deviation
Definition: Statistics.h:68
lsst::afw::math::detail::basicConvolve
void basicConvolve(OutImageT &convolvedImage, InImageT const &inImage, lsst::afw::math::Kernel const &kernel, lsst::afw::math::ConvolutionControl const &convolutionControl)
Low-level convolution function that does not set edge pixels.
Definition: BasicConvolve.cc:142
lsst::afw::geom::makeWcsPairTransform
std::shared_ptr< TransformPoint2ToPoint2 > makeWcsPairTransform(SkyWcs const &src, SkyWcs const &dst)
A Transform obtained by putting two SkyWcs objects "back to back".
Definition: SkyWcs.cc:151
lsst::afw::math::MaskedVector::getImage
lsst::afw::image::MaskedImage< EntryT >::ImagePtr getImage() const
Definition: MaskedVector.h:88
a
table::Key< int > a
Definition: TransmissionCurve.cc:466
LOGL_DEBUG
#define LOGL_DEBUG(logger, message...)
Definition: Log.h:504
col
int col
Definition: CR.cc:144
std::vector::begin
T begin(T... args)
lsst::afw::math::MIN
@ MIN
estimate sample minimum
Definition: Statistics.h:76
min
int min
Definition: BoundedField.cc:103
lsst::afw::math::wrapTestClasses
void wrapTestClasses(py::module &mod)
Definition: spatialCell.cc:156
lsst::geom::Extent2I
Extent< int, 2 > Extent2I
Definition: Extent.h:397
lsst::geom::Point< double, 2 >
lsst::afw::geom::details
Definition: SpanSet.h:48
lsst::geom::Box2I
An integer coordinate rectangle.
Definition: Box.h:55
lsst::afw.display.ds9.scale
def scale(algorithm, min, max=None, frame=None)
Definition: ds9.py:109
lsst::afw::math::MaskedVector::getVariance
lsst::afw::image::MaskedImage< EntryT >::VariancePtr getVariance() const
Definition: MaskedVector.h:94
lsst::afw::math::integrate
UnaryFunctionT::result_type integrate(UnaryFunctionT func, typename UnaryFunctionT::argument_type const a, typename UnaryFunctionT::argument_type const b, double eps=1.0e-6)
The 1D integrator.
Definition: Integrate.h:886
lsst::geom::Extent2D
Extent< double, 2 > Extent2D
Definition: Extent.h:400
std::vector::empty
T empty(T... args)
lsst::afw::image::MaskedImage::getImage
ImagePtr getImage() const
Return a (shared_ptr to) the MaskedImage's image.
Definition: MaskedImage.h:1046
std::ostringstream::str
T str(T... args)
lsst::afw::math::MAX
@ MAX
estimate sample maximum
Definition: Statistics.h:77
lsst::afw::math::VARIANCE
@ VARIANCE
estimate sample variance
Definition: Statistics.h:69
std::make_pair
T make_pair(T... args)
lsst::afw::math::binImage
std::shared_ptr< ImageT > binImage(ImageT const &inImage, int const binX, int const binY, lsst::afw::math::Property const flags=lsst::afw::math::MEAN)
Definition: binImage.cc:43
lsst::afw::math::Property
Property
control what is calculated
Definition: Statistics.h:63
std::vector::end
T end(T... args)
lsst::afw::image::imagesOverlap
bool imagesOverlap(ImageBase< T1 > const &image1, ImageBase< T2 > const &image2)
Return true if the pixels for two images or masks overlap in memory.
Definition: Image.cc:700
lsst::afw::math::NOTHING
@ NOTHING
We don't want anything.
Definition: Statistics.h:64
lsst::afw::math::stringToUndersampleStyle
UndersampleStyle stringToUndersampleStyle(std::string const &style)
Conversion function to switch a string to an UndersampleStyle.
Definition: Background.cc:117
lsst::geom::Box2D
A floating-point coordinate rectangle geometry.
Definition: Box.h:413
lsst::afw::image::Image
A class to represent a 2-dimensional array of pixels.
Definition: Image.h:58
lsst::utils.tests.init
def init()
Definition: tests.py:59
lsst::afw::math::statisticsStack
std::shared_ptr< image::MaskedImage< PixelT > > statisticsStack(image::MaskedImage< PixelT > const &image, Property flags, char dimension, StatisticsControl const &sctrl)
A function to compute statistics on the rows or columns of an image.
Definition: Stack.cc:488
lsst::afw::math::convolve
void convolve(OutImageT &convolvedImage, InImageT const &inImage, KernelT const &kernel, bool doNormalize, bool doCopyEdge)
Definition: ConvolveImage.cc:199
lsst::afw::math::INCREASE_NXNYSAMPLE
@ INCREASE_NXNYSAMPLE
Definition: Background.h:47
lsst::afw::image::MaskedImage::getMask
MaskPtr getMask() const
Return a (shared_ptr to) the MaskedImage's mask.
Definition: MaskedImage.h:1058
lsst::afw::geom::makeTransform
std::shared_ptr< TransformPoint2ToPoint2 > makeTransform(lsst::geom::AffineTransform const &affine)
Wrap an lsst::geom::AffineTransform as a Transform.
Definition: transformFactory.cc:154
lsst::afw::image.slicing.clone
clone
Definition: slicing.py:257
lsst::geom::Extent< int, 2 >
std::numeric_limits
lsst::afw::math::SUM
@ SUM
find sum of pixels in the image
Definition: Statistics.h:78
lsst::afw::math::NMASKED
@ NMASKED
number of masked points
Definition: Statistics.h:82
lsst::afw::image::ImageBase::getWidth
int getWidth() const
Return the number of columns in the image.
Definition: ImageBase.h:294
bbox
AmpInfoBoxKey bbox
Definition: Amplifier.cc:117
lsst::afw::math::MEDIAN
@ MEDIAN
estimate sample median
Definition: Statistics.h:70