lsst.gauss2d gbf99507273+b0138be388
 
Loading...
Searching...
No Matches
lsst::gauss2d::GaussianEvaluator< T, Data, Indices > Class Template Reference

A class that evaluates 2D Gaussians and renders them in images. More...

#include <evaluate.h>

Inheritance diagram for lsst::gauss2d::GaussianEvaluator< T, Data, Indices >:
lsst::gauss2d::Object

Public Types

typedef Image< T, Data > DataT
 
typedef ImageArray< T, Data > ImageArrayT
 
typedef Image< idx_type, Indices > IndicesT
 

Public Member Functions

 GaussianEvaluator (int x=0, const std::shared_ptr< const ConvolvedGaussians > gaussians=nullptr)
 
 GaussianEvaluator (const std::shared_ptr< const ConvolvedGaussians > gaussians, const std::shared_ptr< const Image< T, Data > > data=nullptr, const std::shared_ptr< const Image< T, Data > > sigma_inv=nullptr, const std::shared_ptr< Image< T, Data > > output=nullptr, const std::shared_ptr< Image< T, Data > > residual=nullptr, const std::shared_ptr< ImageArrayT > grads=nullptr, const std::shared_ptr< const Image< idx_type, Indices > > grad_param_map=nullptr, const std::shared_ptr< const Image< T, Data > > grad_param_factor=nullptr, const std::shared_ptr< const Image< idx_type, Indices > > extra_param_map=nullptr, const std::shared_ptr< const Image< T, Data > > extra_param_factor=nullptr, const std::shared_ptr< const Image< T, Data > > background=nullptr)
 Construct a GaussianEvaluator, inferring outputs from inputs.
 
Data const & IMAGE_NULL_CONST () const
 
Indices const & INDICES_NULL_CONST () const
 
ImageArray< T, Data > const & IMAGEARRAY_NULL_CONST () const
 
const CoordinateSystemget_coordsys () const
 
size_t get_n_cols () const
 
size_t get_n_rows () const
 
size_t get_size () const
 
double loglike_pixel (bool to_add=false)
 
std::string repr (bool name_keywords=false, std::string_view namespace_separator=Object::CC_NAMESPACE_SEPARATOR) const override
 
std::string str () const override
 Return a brief, human-readable string representation of this.
 

Additional Inherited Members

- Static Public Member Functions inherited from lsst::gauss2d::Object
static std::string_view null_str (const std::string_view &namespace_separator)
 
- Static Public Attributes inherited from lsst::gauss2d::Object
static constexpr std::string_view CC_NAMESPACE_SEPARATOR = "::"
 The C++ namespace separator.
 
static constexpr std::string_view NULL_STR_GENERAL = "None"
 
static constexpr std::string_view PY_NAMESPACE_SEPARATOR = "."
 

Detailed Description

template<typename T, class Data, class Indices>
class lsst::gauss2d::GaussianEvaluator< T, Data, Indices >

A class that evaluates 2D Gaussians and renders them in images.

This class is designed for repeated re-evaluation of Gaussian mixture models by caching references to the inputs and outputs.

Template Parameters
TThe data type (e.g. float, int)
DataThe data array class
IndicesThe index array class (usually a size_t array)

Constructor & Destructor Documentation

◆ GaussianEvaluator()

template<typename T, class Data, class Indices>
lsst::gauss2d::GaussianEvaluator< T, Data, Indices >::GaussianEvaluator ( const std::shared_ptr< const ConvolvedGaussians > gaussians,
const std::shared_ptr< const Image< T, Data > > data = nullptr,
const std::shared_ptr< const Image< T, Data > > sigma_inv = nullptr,
const std::shared_ptr< Image< T, Data > > output = nullptr,
const std::shared_ptr< Image< T, Data > > residual = nullptr,
const std::shared_ptr< ImageArrayT > grads = nullptr,
const std::shared_ptr< const Image< idx_type, Indices > > grad_param_map = nullptr,
const std::shared_ptr< const Image< T, Data > > grad_param_factor = nullptr,
const std::shared_ptr< const Image< idx_type, Indices > > extra_param_map = nullptr,
const std::shared_ptr< const Image< T, Data > > extra_param_factor = nullptr,
const std::shared_ptr< const Image< T, Data > > background = nullptr )
inline

Construct a GaussianEvaluator, inferring outputs from inputs.

Parameters
gaussiansN x 6 matrix of Gaussian parameters [cen_x, cen_y, flux, sigma_x, sigma_y, rho]
coordsysCoordinate system for all images.
data2D input Data matrix.
sigma_inv2D inverse sigma (sqrt variance) map of the same size as data.
output2D output matrix of the same size as ImageD.
residual2D output matrix for residual ((data-model)/sigma) of the same size as data.
gradsOutput for gradients. Can either an M x 1 vector or M x Data 3D Jacobian matrix, where M <= N x 6 to allow for condensing gradients based on grad_param_map.
grad_param_mapNx6 matrix of indices of grad to add each gradient to. For example, if four gaussians share the same cen_x, one could set grad_param_map[0:4,0] = 0. All values must have index < grad.size().
grad_param_factorNx6 matrix of multiplicative factors for each gradient term. For example, if a Gaussian is a sub-component of a multi-Gaussian component with a total flux parameter but fixed ratios, as in multi-Gaussian Sersic models.
extra_param_mapNx2 matrix of indices to add to an extra (meta)parameter. The first item is the index of the Gaussian to add and the second is the index of the metaparameter.
extra_param_factorNx3 matrix of multiplicative factors for each extra gradient term. The factors are ordered L, sigma_x, sigma_y.
backgroundA background model image. Only 1x1 (constant level) backgrounds are supported.

Member Function Documentation

◆ loglike_pixel()

template<typename T, class Data, class Indices>
double lsst::gauss2d::GaussianEvaluator< T, Data, Indices >::loglike_pixel ( bool to_add = false)
inline

Compute the model and/or log-likelihood and/or gradient (d(log-likelihood)/dx) and/or Jacobian (dmodel/dx) for a Gaussian mixture model.

This function calls a series of templated functions with explicit instantiations. This is solely for the purpose of avoiding having to manually write a series of nested conditionals. My hope is that the templating will insert no-op functions wherever there's nothing to do instead of a needless branch inside each pixel's loop, and that the compiler will actually inline everything for maximum performance. Whether that actually happens or not is anyone's guess.

TODO: Consider override to compute LL and Jacobian, even if it's only useful for debug purposes.

Returns
The log likelihood.

◆ repr()

template<typename T, class Data, class Indices>
std::string lsst::gauss2d::GaussianEvaluator< T, Data, Indices >::repr ( bool name_keywords = false,
std::string_view namespace_separator = Object::CC_NAMESPACE_SEPARATOR ) const
inlineoverridevirtual

Return a full, callable string representation of this.

Parameters
name_keywordsWhether to prefix arguments with "{name}=", where name is the arg name in the header (as with keyword arguments in Python).
namespace_separatorThe string to use to delimit namespaces, i.e. :: in C++ and . in Python.
Returns
A callable string representation of this, which should return an an identical object to this.
Note
The representation with name_keywords=false must be callable in C++. The representation with name_keywords=true should be callable in Python, if there are any bindings.

Implements lsst::gauss2d::Object.

◆ str()

template<typename T, class Data, class Indices>
std::string lsst::gauss2d::GaussianEvaluator< T, Data, Indices >::str ( ) const
inlineoverridevirtual

Return a brief, human-readable string representation of this.

Implements lsst::gauss2d::Object.


The documentation for this class was generated from the following file: